/* ==========================================
   LUMINVS INBOX - BRAND COLOR PALETTE & SYSTEM
   ========================================== */
:root {
    --bg-dark-app: #0b141a;
    --bg-dark-sidebar: #111b21;
    --bg-dark-header: #202c33;
    --bg-dark-input: #2a3942;
    --bg-hover-item: #202c33;
    --bg-active-item: #2a3942;
    
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-muted: #667781;
    
    --brand-primary: #10b981; /* Glowing Emerald */
    --brand-primary-hover: #059669;
    --brand-whatsapp-green: #005c4b; /* WhatsApp dark mode outgoing green */
    --brand-inbound-bubble: #202c33;
    
    --border-color: #222e35;
    --transition-quick: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    --chat-bg-blend: rgba(11, 20, 26, 0.94);
    --text-outbound: #e9edef;
    --text-outbound-meta: rgba(233, 237, 239, 0.6);
    --close-btn-filter: invert(1);
}

body.light-theme {
    --bg-dark-app: #efeae2; /* Soft WhatsApp light grey-beige */
    --bg-dark-sidebar: #ffffff;
    --bg-dark-header: #f0f2f5;
    --bg-dark-input: #ffffff;
    --bg-hover-item: #f5f6f6;
    --bg-active-item: #efeae2;
    
    --text-primary: #111b21;
    --text-secondary: #3b4a54;
    --text-muted: #667781;
    
    --brand-primary: #00a884; /* Standard WhatsApp light emerald green */
    --brand-primary-hover: #008f72;
    --brand-whatsapp-green: #d9fdd3; /* Soft green outgoing bubble */
    --brand-inbound-bubble: #ffffff; /* White incoming bubble */
    
    --border-color: #e9edef;
    
    --chat-bg-blend: rgba(239, 234, 226, 0.96);
    --text-outbound: #111b21;
    --text-outbound-meta: #667781;
    --close-btn-filter: none;
}

/* ==========================================
   BASE & RESET LAYOUTS
   ========================================== */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark-app);
    color: var(--text-primary);
    overflow: hidden;
}

/* ==========================================
   SCROLLBAR STYLES (CUSTOM WEBKIT)
   ========================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(80, 100, 110, 0.4);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(80, 100, 110, 0.6);
}

/* ==========================================
   APP SHELL LAYOUT
   ========================================== */
.app-wrapper {
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ==========================================
   SIDEBAR STYLES (LEFT PANEL)
   ========================================== */
.sidebar {
    background-color: var(--bg-dark-sidebar);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    background-color: var(--bg-dark-sidebar);
    height: 60px;
    border-bottom: 1px solid var(--border-color);
}

.app-logo-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--brand-primary);
    box-shadow: 0 0 10px var(--brand-primary);
    display: inline-block;
    animation: pulse-glow 2s infinite alternate;
}

.app-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Search bar styling */
.search-container {
    background-color: var(--bg-dark-sidebar);
}

.settings-collapse {
    background-color: var(--bg-dark-sidebar);
}

.settings-panel {
    background-color: var(--bg-dark-sidebar);
}

.settings-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-card {
    background-color: var(--bg-dark-header);
    border: 1px solid var(--border-color);
    padding: 12px;
}

.settings-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-code {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.18);
    color: #f472b6;
    font-size: 0.8rem;
    word-break: break-all;
}

.search-input-group {
    background-color: var(--bg-dark-header);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: var(--transition-quick);
}

.search-input-group:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 1px var(--brand-primary);
}

.search-input-group .input-group-text {
    color: var(--text-secondary);
    border: none;
}

.search-input-group .form-control {
    color: var(--text-primary);
    border: none;
    font-size: 0.9rem;
    box-shadow: none !important;
}

.search-input-group .form-control::placeholder {
    color: var(--text-muted);
}

/* Conversation list items */
.conversation-list {
    background-color: var(--bg-dark-sidebar);
}

.conversation-item {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-quick);
    cursor: pointer;
}

.conversation-item:hover {
    background-color: var(--bg-hover-item);
}

.conversation-item.active {
    background-color: var(--bg-active-item);
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #51636b;
    flex-shrink: 0;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.avatar-letter {
    user-select: none;
}

.contact-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.last-message-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.direction-indicator {
    color: var(--brand-primary);
    font-weight: 600;
}

.sidebar-footer {
    height: 50px;
    font-size: 0.75rem;
    background-color: var(--bg-dark-sidebar);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   CHAT VIEWPORT STYLES (RIGHT PANEL)
   ========================================== */
.chat-viewport {
    background-color: var(--bg-dark-app);
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.chat-viewport.is-loading {
    opacity: 0.45;
    transform: translateY(6px);
    pointer-events: none;
}

.chat-header {
    background-color: var(--bg-dark-header);
    height: 60px;
    border-bottom: 1px solid var(--border-color);
}

.active-contact-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.active-contact-phone {
    font-size: 0.8rem;
}

.btn-icon-only {
    background: transparent;
    border: none;
    border-radius: 50%;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-quick);
}

.btn-icon-only:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-primary) !important;
}

.icon-btn {
    fill: var(--text-secondary);
}

/* Chat timeline message area */
.chat-history {
    background-image: linear-gradient(var(--chat-bg-blend), var(--chat-bg-blend)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%2322333b' fill-opacity='0.15'%3E%3Cpath fill-rule='evenodd' d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm1-61c3.16 0 6-2.84 6-6s-2.84-6-6-6-6 2.84-6 6 2.84 6 6 6zm-.5 17c.828 0 1.5-.672 1.5-1.5s-.672-1.5-1.5-1.5-1.5.672-1.5 1.5.672 1.5 1.5 1.5zm-.5 30c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm25-45c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zm-5-18c.828 0 1.5-.672 1.5-1.5s-.672-1.5-1.5-1.5-1.5.672-1.5 1.5.672 1.5 1.5 1.5zm-33 46c.828 0 1.5-.672 1.5-1.5s-.672-1.5-1.5-1.5-1.5.672-1.5 1.5.672 1.5 1.5 1.5zm43-17c.828 0 1.5-.672 1.5-1.5s-.672-1.5-1.5-1.5-1.5.672-1.5 1.5.672 1.5 1.5 1.5z'/%3E%3C/g%3E%3C/svg%3E");
    background-size: cover;
    background-attachment: scroll;
}

/* Chat bubble aesthetics */
.message-bubble {
    font-size: 0.92rem;
    line-height: 1.45;
    position: relative;
    max-width: 70%;
    animation: pop-bubble 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.message-bubble.inbound {
    background-color: var(--brand-inbound-bubble);
    color: var(--text-primary);
    border-top-left-radius: 0 !important;
}

.message-bubble.outbound {
    background-color: var(--brand-whatsapp-green);
    color: var(--text-outbound);
    border-top-right-radius: 0 !important;
}

.playable-media {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
}

.playable-media-label {
    font-size: 0.82rem;
    opacity: 0.88;
}

.media-transcript {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.media-transcript-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.8;
    margin-bottom: 4px;
}

.media-transcript-text {
    font-size: 0.86rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.chat-audio-player,
.chat-video-player {
    width: 100%;
    max-width: 320px;
}

.chat-video-player {
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
}

.message-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.message-bubble.outbound .message-meta {
    color: var(--text-outbound-meta);
}

.icon-status {
    width: 14px;
    height: 14px;
    color: #53bdeb; /* Light blue read receipt check */
}

.message-status-icon.pending .icon-status {
    color: var(--text-muted);
}

.message-status-icon.failed .icon-status {
    color: #ef4444 !important;
}

/* Chat footer input bar */
.chat-input-bar {
    background-color: var(--bg-dark-header);
    min-height: 60px;
}

.chat-input {
    background-color: var(--bg-dark-input) !important;
    border: 1px solid transparent !important;
    color: var(--text-primary) !important;
    font-size: 0.95rem;
    padding: 10px 16px;
    border-radius: 20px !important;
    transition: var(--transition-quick) !important;
}

.chat-input:focus {
    box-shadow: none !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    background-color: var(--bg-dark-input) !important;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

#btn-send-message {
    transition: var(--transition-quick);
}

#btn-send-message:hover {
    transform: scale(1.08);
    background-color: var(--brand-primary-hover);
}

#btn-send-message:active {
    transform: scale(0.95);
}

/* ==========================================
   PLACEHOLDER VIEWPORT (NO CONV SELECTED)
   ========================================== */
.placeholder-screen {
    background-color: var(--bg-dark-app);
}

.placeholder-branding {
    position: relative;
    width: 80px;
    height: 80px;
}

.brand-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(16, 185, 129, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.brand-ring::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px solid var(--brand-primary);
    border-color: var(--brand-primary) transparent transparent transparent;
    animation: rotate 3s linear infinite;
}

.brand-core {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover));
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.webhook-helper-card {
    background-color: var(--bg-dark-sidebar);
    max-width: 450px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* ==========================================
   ANIMATIONS & KEYFRAMES
   ========================================== */
@keyframes pulse-glow {
    from {
        box-shadow: 0 0 4px var(--brand-primary);
    }
    to {
        box-shadow: 0 0 12px var(--brand-primary);
    }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pop-bubble {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive configurations */
@media (max-width: 767.98px) {
    .sidebar {
        height: 40vh;
        overflow-y: auto;
    }
    .chat-viewport {
        height: 60vh;
    }
    .conversation-item {
        padding: 10px 15px;
    }
}

/* Theme Toggle Button hover styles */
#theme-toggle {
    transition: var(--transition-quick);
}
#theme-toggle:hover {
    background-color: var(--bg-hover-item);
    color: var(--brand-primary) !important;
}

/* Custom Modal adaptations for light/dark theme */
.custom-modal {
    background-color: var(--bg-dark-sidebar) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}
.border-bottom-custom {
    border-bottom: 1px solid var(--border-color) !important;
}
.border-top-custom {
    border-top: 1px solid var(--border-color) !important;
}
.text-secondary-custom {
    color: var(--text-secondary) !important;
}
.custom-input {
    background-color: var(--bg-dark-input) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}
.custom-input:focus {
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 1px var(--brand-primary) !important;
}

/* Force Bootstrap border tags to follow our active theme color variables */
.border-end, .border-top, .border-bottom, .border-start, .border-dark-subtle {
    border-color: var(--border-color) !important;
}
