/* IAAP Agent Admin Dashboard - Complete Styles */

:root {
    /* Color Palette */
    --admin-primary: #1e293b;
    --admin-primary-hover: #334155;
    --admin-accent: #3b82f6;
    --admin-accent-hover: #2563eb;

    /* Backgrounds */
    --bg-admin-main: #f3f4f6;
    --bg-admin-sidebar: #0f172a;
    --bg-admin-surface: #ffffff;

    /* Text Colors */
    --text-admin-sidebar: #94a3b8;
    --text-admin-sidebar-active: #ffffff;
    --text-admin-primary: #0f172a;
    --text-admin-secondary: #64748b;
    --text-admin-main: #1e293b;
    --text-admin-inverse: #ffffff;

    /* Borders & Setup */
    --border-admin: #e2e8f0;
    --border-admin-sidebar: rgba(255, 255, 255, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    height: 100%;
    font-family: var(--font-family);
    background-color: var(--bg-admin-main);
    color: var(--text-admin-primary);
}

.admin-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-admin-sidebar);
    color: var(--text-admin-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-admin-sidebar);
}

.brand-logo {
    background-color: var(--admin-accent);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 12px;
}

.brand-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

.nav-group {
    margin-bottom: 2rem;
}

.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-left: 0.75rem;
    color: rgba(148, 163, 184, 0.7);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem;
    color: var(--text-admin-sidebar);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-admin-sidebar-active);
}

.nav-item.active {
    background-color: var(--admin-accent);
    color: white;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1.25rem 1rem;
    border-top: 1px solid var(--border-admin-sidebar);
}

.tenant-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tenant-avatar {
    width: 36px;
    height: 36px;
    background-color: #475569;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.tenant-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    margin-bottom: 2px;
}

.tenant-plan {
    font-size: 0.75rem;
    color: var(--admin-accent);
    font-weight: 500;
}

/* Main Content Area */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-header {
    height: var(--header-height);
    background-color: var(--bg-admin-surface);
    border-bottom: 1px solid var(--border-admin);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    background-color: var(--bg-admin-main);
    color: var(--text-admin-primary);
    border: 1px solid var(--border-admin);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.preview-btn:hover {
    background-color: var(--border-admin);
}

.content-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

/* Dynamic Modules */
.admin-module {
    display: block;
    animation: fadeIn 0.3s ease;
    flex: 1;
}

.admin-module.active {
    display: flex;
    flex-direction: column;
}

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

/* Stats Grid (Dashboard) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-admin-surface);
    border: 1px solid var(--border-admin);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.stat-title {
    font-size: 0.875rem;
    color: var(--text-admin-secondary);
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-admin-primary);
    margin-bottom: 0.5rem;
}

.stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
}

.stat-trend.positive {
    color: #10b981;
}

.stat-trend.neutral {
    color: var(--text-admin-secondary);
}

/* Dashboard Rows & Panels */
.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.panel {
    background-color: var(--bg-admin-surface);
    border: 1px solid var(--border-admin);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

/* Setting Cards */
.setting-card {
    background-color: var(--bg-admin-surface);
    border: 1px solid var(--border-admin);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.setting-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-admin);
    background-color: #fafafa;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.setting-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-admin-primary);
}

.setting-card-header p {
    font-size: 0.8125rem;
    color: var(--text-admin-secondary);
    margin-top: 4px;
    margin-bottom: 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-admin);
    gap: 2rem;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row.vertical {
    flex-direction: column;
    gap: 1rem;
}

.setting-info {
    flex: 1;
    max-width: 60%;
}

.setting-info h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-admin-primary);
}

.setting-info p {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-admin-secondary);
    margin: 0;
}

.setting-action {
    flex-shrink: 0;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.setting-row.vertical .setting-action {
    align-items: stretch;
    width: 100%;
}

.setting-row.vertical .setting-info {
    max-width: 100%;
}

/* Panel Header */
.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-admin);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.panel-body {
    padding: 1.5rem;
    flex: 1;
}

.panel-body.bleed {
    padding: 0;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-admin-secondary);
    text-align: center;
    border: 2px dashed var(--border-admin);
    border-radius: var(--radius-sm);
    background-color: #fcfcfc;
}

.empty-state svg {
    margin-bottom: 1rem;
}

/* Live Lead Feed */
.lead-feed {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

.lead-item {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-admin);
    transition: background-color 0.2s;
}

.lead-item:hover {
    background-color: var(--bg-admin-main);
    cursor: pointer;
}

.lead-item:last-child {
    border-bottom: none;
}

.lead-meta {
    font-size: 0.75rem;
    color: var(--text-admin-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.lead-desc {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 8px;
}

.lead-contact {
    font-size: 0.8125rem;
    color: var(--admin-accent);
    font-family: monospace;
    background-color: var(--bg-admin-main);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

/* Form Controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-admin-primary);
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-admin);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.875rem;
    color: var(--text-admin-primary);
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn-primary {
    background-color: var(--admin-accent);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background-color: var(--admin-accent-hover);
}

.btn-secondary {
    background-color: var(--bg-admin-main);
    color: var(--text-admin-primary);
    border: 1px solid var(--border-admin);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--border-admin);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef9c3;
    color: #854d0e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-neutral {
    background: #f1f5f9;
    color: #475569;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

/* Tables */
.admin-table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-admin);
    background: white;
}

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

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-admin);
    font-size: 13px;
    color: var(--text-admin-main);
}

.admin-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 500;
}

.admin-table tbody tr {
    transition: background-color 0.2s;
}

.admin-table tbody tr:hover {
    background-color: #f8fafc;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 992px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        height: auto;
        flex-shrink: 0;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 0.5rem;
        white-space: nowrap;
    }

    .nav-group {
        margin-bottom: 0;
        display: flex;
        align-items: center;
    }

    .nav-title {
        display: none;
    }

    .nav-item {
        padding: 0.5rem 1rem;
        margin-bottom: 0;
        margin-right: 0.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}


/* Slide Panel Styles */
.slide-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.slide-panel {
    display: none;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 500px;
    background: white;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.slide-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-admin);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
}

.slide-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.slide-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-admin);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-admin-main);
    border-radius: var(--radius-md);
}

.filter-bar select,
.filter-bar input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-admin);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    background: white;
}

/* Analytics Filter Bar - Flex Layout */
.analytics-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--border-admin);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.analytics-filter-bar .filter-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}

.analytics-filter-bar .quick-filters {
    display: flex;
    gap: 6px;
    margin-right: 4px;
}

.analytics-filter-bar .quick-filter-btn {
    height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    background-color: white;
    border: 1px solid #d1d5db;
    color: var(--text-admin-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.analytics-filter-bar .quick-filter-btn:hover {
    border-color: var(--admin-accent);
    color: var(--admin-accent);
    background-color: #eff6ff;
}

.analytics-filter-bar .quick-filter-btn.active {
    background-color: var(--admin-accent);
    border-color: var(--admin-accent);
    color: white;
}

.analytics-filter-bar .filter-inputs .form-control {
    width: 130px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background-color: white;
    font-size: 13px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.analytics-filter-bar .filter-separator {
    color: var(--text-admin-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 0 2px;
    flex-shrink: 0;
}

.analytics-filter-bar .btn-export {
    height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    background-color: white;
    border: 1px solid #d1d5db;
    color: var(--text-admin-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
}

.analytics-filter-bar .btn-export:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.analytics-filter-bar .btn-export::before {
    content: "↓";
    font-size: 11px;
}

.analytics-filter-bar .filter-inputs .form-control:hover {
    border-color: #9ca3af;
}

.analytics-filter-bar .filter-inputs .form-control:focus {
    border-color: var(--admin-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Transcript Container */
.transcript-container {
    max-height: 400px;
    overflow-y: auto;
}

/* Responsive for slide panel */
@media (max-width: 1024px) {
    .slide-panel {
        width: 100%;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .slider {
    background-color: var(--admin-accent);
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(20px);
}
