/* ========================================================= */
/* --- EXCELLUX CRM: PHASE 1 - GLOBAL FOUNDATION ---         */
/* ========================================================= */

/* --- 1. GLOBAL VARIABLES --- */
:root {
    /* Color Palette: Light, Airy SaaS Look */
    --bg-main: #F9FAFB;       /* Very subtle gray-blue for the app background */
    --bg-surface: #FFFFFF;    /* Pure white for cards, tables, and panels */
    --bg-hover: #F3F4F6;      /* Extremely faint gray for interactive hovers */
    
    /* Typography Colors */
    --text-main: #111827;     /* Deep slate (Premium alternative to pure black) */
    --text-muted: #6B7280;    /* Muted gray for subtitles and secondary text */
    
    /* Brand Accents (Based on reference UI) */
    --brand-primary: #2563EB; /* Premium SaaS Blue */
    --brand-primary-hover: #1D4ED8;
    --brand-gradient: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
    
    /* Status Colors (Subtle & Modern) */
    --status-success-bg: #D1FAE5;
    --status-success-text: #059669;
    --status-warning-bg: #FEF3C7;
    --status-warning-text: #D97706;
    --status-danger-bg: #FEE2E2;
    --status-danger-text: #DC2626;
    
    /* Geometry & Depth */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* Faint ridge */
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); /* Card elevation */
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025); /* Floating elevation */
    --border-light: #E5E7EB;  /* Invisible unless needed */
    
    /* Animation */
    --transition-fast: 0.15s ease-in-out;
}

/* --- 2. BASE RESETS & TYPOGRAPHY --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased; /* Critical for premium text rendering */
    -moz-osx-font-smoothing: grayscale;
}

/* Section Toggling */
.crm-section {
    display: none;
    animation: fadeAndSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.crm-section.active {
    display: block;
}

@keyframes fadeAndSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 3. APP LAYOUT GRID --- */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.main-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.po-container {
    padding: 0 32px 32px 32px;
    max-width: 1600px; /* Prevents stretching on ultra-wide monitors */
    margin: 0 auto;
    width: 100%;
}

/* --- 4. THE SIDEBAR --- */
.crm-sidebar {
    width: 80px;
    background: #111827; /* Very dark slate, matching the Leads reference */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 24px;
    z-index: 100;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    padding: 0 12px;
}

.crm-tab {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: #9CA3AF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.crm-tab i {
    font-size: 20px;
}

.crm-tab:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.05);
}

.crm-tab.active {
    background: var(--brand-primary);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* --- 5. THE HEADER --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: var(--bg-main);
    position: sticky;
    top: 0;
    z-index: 50;
    /* Optional: Add a backdrop-filter blur if you want a translucent glass effect */
}

.header-title h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.025em; /* Tighter tracking for modern headers */
    color: var(--text-main);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-light);
    text-transform: uppercase;
}

/* --- 6. GLOBAL BUTTONS --- */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--brand-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: var(--brand-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: #D1D5DB;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

/* --- 7. SECTION HEADERS & CONTROLS --- */
.section-header {
    margin-bottom: 32px;
}

.section-header .header-text h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.section-header .header-text p {
    font-size: 13px;
    color: var(--text-muted);
}

.pipeline-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

/* Search Input inside Controls */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.search-wrapper i {
    position: absolute;
    left: 14px;
    color: #9CA3AF;
    font-size: 14px;
}
.search-wrapper input {
    padding: 10px 14px 10px 36px;
    width: 280px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    font-size: 13px;
    color: var(--text-main);
    transition: all var(--transition-fast);
    outline: none;
}
.search-wrapper input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); /* Soft focus ring */
}

/* ========================================================= */
/* --- EXCELLUX CRM: PHASE 2 - DATA VIEWS & DASHBOARDS ---   */
/* ========================================================= */

/* --- 1. GLOBAL FORMS & INPUTS --- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.form-group.full-width {
    grid-column: 1 / -1;
}

.ledger-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: block;
}

.ledger-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-main);
    background: var(--bg-surface);
    transition: all var(--transition-fast);
    outline: none;
    font-family: inherit;
}

.ledger-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); /* Signature SaaS focus ring */
}

/* --- 2. THE PIPELINE TABLE --- */
.table-container {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden; /* Keeps the border-radius clean */
}

.premium-list-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.premium-list-table th {
    padding: 16px 24px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
    background: #F8FAFC; /* Slightly different from surface to separate header */
}

.premium-list-table td {
    padding: 16px 24px;
    font-size: 14px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    transition: background var(--transition-fast);
}

.premium-list-table tbody tr {
    transition: transform var(--transition-fast);
}

/* Premium Row Hover Effect */
.premium-list-table tbody tr:hover td {
    background: var(--bg-hover);
    cursor: pointer;
}

/* Remove bottom border on last row so it doesn't clash with container */
.premium-list-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- 3. BADGES, PILLS & AVATARS --- */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px; /* Perfect pill shape */
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Status Colors mapped directly to your JS logic */
.status-pill.new { background: #E0E7FF; color: #4338CA; } /* Indigo */
.status-pill.hot { background: var(--status-success-bg); color: var(--status-success-text); }
.status-pill.dead { background: var(--status-danger-bg); color: var(--status-danger-text); }
.status-pill.archived { background: var(--bg-hover); color: var(--text-muted); }

.lead-tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin: 2px 4px 2px 0;
}

/* Fake circular avatars (will be injected by JS) */
.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    margin-right: 12px;
}

/* --- 4. ANALYTICS KPI DASHBOARD --- */
.analytics-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.premium-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.premium-card:hover {
    transform: translateY(-4px); /* Slight lift on hover */
    box-shadow: var(--shadow-md);
}

.kpi-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* Soft colored icon squares */
.kpi-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.kpi-icon-wrapper.blue { background: #DBEAFE; color: #1D4ED8; }
.kpi-icon-wrapper.green { background: #D1FAE5; color: #047857; }
.kpi-icon-wrapper.red { background: #FEE2E2; color: #B91C1C; }
.kpi-icon-wrapper.purple { background: #F3E8FF; color: #7E22CE; }

.kpi-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.kpi-trend {
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}
.trend-up { color: var(--status-success-text); }
.trend-down { color: var(--status-danger-text); }
.neutral { color: var(--text-muted); }

/* Analytics Charts Layout */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* 66% width for line chart, 33% for doughnut */
    gap: 24px;
}
@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: 1fr; } /* Stack on smaller screens */
}

.chart-header h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.chart-subtitle { font-size: 12px; color: var(--text-muted); }
.canvas-container { position: relative; height: 320px; width: 100%; margin-top: 20px; }

/* --- 5. MARKETING HUB FILTERS & GRID --- */
.marketing-filters {
    display: flex;
    gap: 32px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
}

.filter-group { display: flex; flex-direction: column; gap: 12px; }
.filter-label { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.5px; }

.filter-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-pill {
    padding: 6px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.filter-pill:hover { background: var(--bg-hover); color: var(--text-main); }
.filter-pill.active { background: var(--text-main); border-color: var(--text-main); color: #fff; } /* High contrast active state */

/* iOS Style Toggle Switch Container */
.marketing-toggles {
    display: flex;
    gap: 4px;
    background: #E5E7EB;
    padding: 4px;
    border-radius: var(--radius-md);
    width: max-content;
    margin-bottom: 24px;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.toggle-btn.active {
    background: var(--bg-surface);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

/* Template Cards Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

/* ========================================================= */
/* --- EXCELLUX CRM: PHASE 3 - INTERACTIVE UI & MODALS ---   */
/* ========================================================= */

/* --- 1. ACTION DESK: THE 3-PANE LAYOUT --- */
.action-desk-container {
    display: flex;
    height: calc(100vh - 160px); /* Fill remaining space below header */
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden; /* Contains the columns cleanly */
}

/* Left Pane: Chat List */
.action-leads-col {
    width: 320px;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    background: #F8FAFC; /* Very faint gray to differentiate from chat center */
}

.action-search-bar {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    position: relative;
}
.action-search-bar i {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    font-size: 13px;
}
.action-search-bar input {
    width: 100%;
    padding: 10px 14px 10px 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}
.action-search-bar input:focus {
    border-color: var(--brand-primary);
}

.action-leads-list {
    flex: 1;
    overflow-y: auto;
}

/* Chat List Items */
.chat-list-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
}
.chat-list-item:hover {
    background: var(--bg-hover);
}
.chat-list-item.active {
    background: #EFF6FF; /* Very faint brand blue */
    border-left: 3px solid var(--brand-primary);
}

/* Center Pane: Active Chat */
.action-chat-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
}

.workspace-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 48px;
    color: #E5E7EB;
    margin-bottom: 16px;
}
.workspace-empty h3 { font-size: 18px; font-weight: 600; color: var(--text-main); margin-bottom: 8px;}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
}
.chat-header-info {
    display: flex;
    align-items: center;
}
.chat-header h3 { font-size: 16px; font-weight: 600; margin: 0 0 4px 0; }
.referral-badge { font-size: 10px; background: #FEF3C7; color: #D97706; padding: 2px 8px; border-radius: 12px; font-weight: 600; }

.chat-history-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    background: #F9FAFB; /* Subtly different from header/input to mimic iMessage/WhatsApp */
}

/* --- 2. CHAT BUBBLES --- */
.chat-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    position: relative;
}
.bubble-in {
    background: #FFFFFF;
    color: var(--text-main);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px; /* Sharp corner pointing to speaker */
    align-self: flex-start;
}
.bubble-out {
    background: var(--brand-primary);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.bubble-system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: none;
    margin: 8px 0 24px 0;
}

/* --- MARKETING HUB: 3D FLIP CARD TEMPLATES --- */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.template-card {
    background: transparent;
    perspective: 1000px; /* Required for 3D effect */
    height: 240px; 
    cursor: pointer;
}

/* The inner container that actually rotates */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* Flip on hover */
.template-card:hover .card-inner {
    transform: rotateY(180deg);
    box-shadow: var(--shadow-lg);
}

/* Base styles for both faces */
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Safari */
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    background: var(--bg-surface);
    overflow: hidden;
}

/* --- FRONT FACE --- */
.card-front {
    display: flex;
    flex-direction: column;
}

.template-media {
    height: 160px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-hover);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-media-placeholder i {
    font-size: 32px;
    color: #9CA3AF;
}

.front-content {
    padding: 12px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.template-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tag-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* --- BACK FACE --- */
.card-back {
    transform: rotateY(180deg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    background: #F8FAFC; /* Slightly cooler gray for depth */
}

.template-desc {
    font-size: 12px;
    color: var(--text-main);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.template-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.template-footer .btn-row {
    display: flex;
    gap: 8px;
}

/* --- 3. CHAT INPUT & AI REPLIES --- */
.chat-input-area {
    padding: 16px 24px 24px 24px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
}

.smart-replies-container {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* The Glowing AI Chips */
.ai-chip {
    background: #F3E8FF; /* Soft purple */
    color: #7E22CE;
    border: 1px solid #E9D5FF;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-chip:hover {
    background: #E9D5FF;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(126, 34, 206, 0.15); /* Purple glow */
}

/* Pill-shaped Input Bar */
.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-hover);
    border-radius: 9999px; /* Complete pill shape */
    padding: 6px 6px 6px 16px;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}
.input-wrapper:focus-within {
    border-color: var(--border-light);
    background: var(--bg-surface);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-size: 14px;
    outline: none;
    color: var(--text-main);
}

/* Circular Send/Action Buttons inside Input */
.icon-btn, .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.icon-btn { background: transparent; color: var(--text-muted); font-size: 16px; }
.icon-btn:hover { background: #E5E7EB; color: var(--text-main); }
.send-btn { background: var(--brand-primary); color: white; margin-left: 8px; }
.send-btn:hover { background: var(--brand-primary-hover); transform: scale(1.05); }

/* The Sparkle Button */
.ai-sparkle-btn { color: #8B5CF6; }
.ai-sparkle-btn:hover { background: #F3E8FF; color: #7E22CE; }

/* Right Pane: Context Context */
.action-context-col {
    width: 280px;
    border-left: 1px solid var(--border-light);
    padding: 24px;
    background: var(--bg-surface);
    overflow-y: auto;
}
.context-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.context-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.context-group label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}
.context-group .data-val {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}
.highlight-green { color: var(--status-success-text) !important; font-weight: 700 !important; }


/* --- 4. MODALS & OVERLAYS --- */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(17, 24, 39, 0.6); /* Darker, sleek overlay */
    backdrop-filter: blur(4px); /* Premium glass effect */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--transition-fast);
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp var(--transition-fast);
    overflow: hidden;
}

/* Modal Sizing Variants */
.modal-md { max-width: 600px; }
.modal-lg { max-width: 900px; }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #F9FAFB;
}
.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}
.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #9CA3AF;
    cursor: pointer;
    transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--text-main); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
}
.scrollable-body {
    flex: 1;
    overflow-y: auto;
}

.modal-footer-actions {
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    background: #F9FAFB;
}
.modal-toolbar {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 16px;
    background: var(--bg-surface);
}

/* Utilities for Modal Flex */
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.margin-bottom-lg { margin-bottom: 32px; }
.text-purple { color: #7E22CE; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px;}

/* Lead Meta Info Box inside Modal */
.lead-meta-box {
    background: var(--bg-hover);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.meta-row { margin-bottom: 8px; }
.meta-row:last-child { margin-bottom: 0; }
.meta-row.split { display: flex; justify-content: space-between; align-items: center; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================================= */
/* --- EXCELLUX CRM: FEATURE ADDITIONS (QUOTES & MEDIA) ---  */
/* ========================================================= */

/* --- 1. VALUE PILL (HOVER TO REVEAL) --- */
.value-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    background: #F0FDF4; /* Very faint green */
    color: #16A34A; /* Emerald green */
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    overflow: hidden;
    min-width: 110px;
    transition: all var(--transition-fast);
    border: 1px solid #BBF7D0;
}

.value-pill .amount {
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    display: block;
}

.value-pill::after {
    content: "View Quote";
    position: absolute;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.value-pill:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}

.value-pill:hover .amount {
    opacity: 0;
    transform: translateY(-15px);
}

.value-pill:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* --- 2. MANAGE MEDIA: ZOOMING THUMBNAILS --- */
.media-thumbnail-wrapper {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    position: relative;
    z-index: 1;
}

.media-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    cursor: zoom-in;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    transform-origin: center left; /* Ensures it zooms out towards the right, not off the screen */
}

/* The 2.5x Scale on Hover */
.media-thumbnail:hover {
    transform: scale(2.5);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    z-index: 100;
    position: relative;
    border-color: var(--bg-surface); /* Cleans up the edge while zoomed */
}

/* ========================================================= */
/* --- EXCELLUX CRM: ROADMAP 2.0 (BROADCASTS & MINI-CARDS) - */
/* ========================================================= */

/* --- 1. BROADCAST MODAL: AUDIENCE TAG PILLS --- */
#broadcastAudienceTags label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all var(--transition-fast);
}

#broadcastAudienceTags label:hover {
    border-color: var(--brand-primary);
    background: #EEF2FF; /* Very faint indigo */
}

#broadcastAudienceTags input[type="checkbox"] {
    accent-color: var(--brand-primary);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* --- 2. ACTION DESK: MINI FLIP-CARDS --- */
.mini-grid {
    /* Tighter grid for smaller modal */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.mini-grid .template-card {
    height: 180px; /* Shorter card */
}

.mini-grid .template-media {
    height: 100px; /* Smaller image */
}

.mini-grid .front-content {
    padding: 8px 12px;
}

.mini-grid .template-title {
    font-size: 12px; /* Scaled down text */
}

.mini-grid .lead-tag {
    font-size: 9px;
    padding: 2px 6px;
}

.mini-grid .card-back {
    padding: 12px;
}

.mini-grid .template-desc {
    font-size: 10px;
    -webkit-line-clamp: 3; /* Show less text on back */
}

.mini-grid .cast-btn {
    padding: 6px 8px;
    font-size: 10px;
    border-radius: 20px; /* Pill shaped button */
}

/* --- 3. ACTION DESK: INBOUND CHAT IMAGES --- */
.chat-image-attachment {
    max-width: 100%;
    max-height: 250px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: zoom-in;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(0,0,0,0.05);
    display: block; /* Prevents inline spacing bugs */
}

.chat-image-attachment:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Add a slight background for system messages so they stand out */
.bubble-system {
    background: #F3F4F6;
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px dashed var(--border-light);
}