/* ==========================================
   DR. TEA ADMIN — Light Theme
   ========================================== */

:root {
    --admin-sidebar-width: 250px;
    --admin-sidebar-collapsed: 60px;
    --admin-header-height: 60px;
    --admin-primary: #17355D;
    --admin-accent: #2860AB;
    --admin-bg: #f4f6f9;
    --admin-surface: #ffffff;
    --admin-border: #e2e8f0;
    --admin-text: #1a202c;
    --admin-text-muted: #718096;
}

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

body { background: var(--admin-bg); margin: 0; }

/* ==========================================
   OVERLAYS
   ========================================== */
#overlay-loading {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(255,255,255,.7);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .3s;
}
#overlay-loading.show { opacity: 1; pointer-events: all; }

/* ==========================================
   SIDEBAR
   ========================================== */
.admin-sidebar {
    width: var(--admin-sidebar-width);
    background: var(--admin-surface);
    border-right: 1px solid var(--admin-border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width .2s ease;
    overflow-x: hidden;
    overflow-y: auto;
}
.admin-sidebar.collapsed { width: var(--admin-sidebar-collapsed); }
.admin-sidebar.collapsed .sidebar-label,
.admin-sidebar.collapsed .sidebar-section-title,
.admin-sidebar.collapsed .sidebar-logo-text { display: none; }
.admin-sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding-inline: 0;
}

.sidebar-logo {
    height: var(--admin-header-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    border-bottom: 1px solid var(--admin-border);
    flex-shrink: 0;
    gap: .75rem;
}
.sidebar-logo-icon {
    width: 32px; height: 32px;
    background: var(--admin-primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.sidebar-logo-text {
    font-weight: 600;
    font-size: 15px;
    color: var(--admin-text);
    white-space: nowrap;
}

.admin-sidebar .sidebar-nav {
    list-style: none;
    padding: .5rem 0 !important;
    margin: 0;
    flex: 1;
}
.sidebar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--admin-text-muted);
    padding: 1rem 1rem .4rem;
    font-weight: 600;
}
.admin-sidebar .sidebar-link {
    display: flex !important;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem !important;
    margin: 1px .5rem;
    border-radius: 6px;
    border-left: none !important;
    background: transparent !important;
    color: var(--admin-text-muted) !important;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all .15s;
    cursor: pointer;
}
.admin-sidebar .sidebar-link:hover {
    background: var(--admin-bg) !important;
    color: var(--admin-text) !important;
}
.admin-sidebar .sidebar-link.active {
    background: var(--admin-primary) !important;
    color: white !important;
}
.admin-sidebar .sidebar-link.active i {
    color: white !important;
}
.admin-sidebar .sidebar-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--admin-text-muted) !important;
}
.admin-sidebar .sidebar-link:hover i {
    color: var(--admin-text) !important;
}
.admin-sidebar .sidebar-link.active i,
.admin-sidebar .sidebar-link.active:hover i {
    color: white !important;
}

.sidebar-footer {
    border-top: 1px solid var(--admin-border);
    padding: .75rem;
}
.sidebar-footer a {
    display: flex; align-items: center; gap: .5rem;
    padding: .5rem .75rem;
    border-radius: 6px;
    color: var(--admin-text-muted);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
}
.sidebar-footer a:hover { background: #fee2e2; color: #dc2626; }

/* Overlay mobile */
#sidebarOverlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1035;
}
#sidebarOverlay.show { display: block; }

/* ==========================================
   HEADER
   ========================================== */
.admin-header {
    position: fixed;
    top: 0;
    left: var(--admin-sidebar-width);
    right: 0;
    height: var(--admin-header-height);
    background: var(--admin-surface);
    border-bottom: 1px solid var(--admin-border);
    z-index: 1039;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    transition: left .2s ease;
}
.admin-header.expanded { left: var(--admin-sidebar-collapsed); }

#sidebarToggle {
    background: none; border: none;
    font-size: 22px; color: var(--admin-text-muted);
    cursor: pointer; padding: 4px;
}
#sidebarToggle:hover { color: var(--admin-text); }

#headerTitle {
    font-size: 16px;
    font-weight: 600;
    color: var(--admin-text);
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.admin-main {
    margin-left: var(--admin-sidebar-width);
    padding-top: var(--admin-header-height);
    min-height: 100vh;
    background: var(--admin-bg);
    transition: margin-left .2s ease;
}
.admin-main.expanded { margin-left: var(--admin-sidebar-collapsed); }
.admin-content { padding: 1.5rem; }

/* Frames & Sections */
.frame { display: none; }
.frame.show { display: block; }
.frame-starting.show { display: flex; align-items: center; justify-content: center; height: 100vh; }
.section { display: none; }
.section.show { display: block; }

/* ==========================================
   KPI CARDS
   ========================================== */
.kpi-card {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.kpi-icon.blue { background: #dbeafe; color: #2563eb; }
.kpi-icon.green { background: #dcfce7; color: #16a34a; }
.kpi-icon.purple { background: #ede9fe; color: #7c3aed; }
.kpi-icon.amber { background: #fef3c7; color: #d97706; }
.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--admin-text);
    line-height: 1;
}
.kpi-label {
    font-size: 13px;
    color: var(--admin-text-muted);
    margin-top: 2px;
}
.kpi-note {
    font-size: 11px;
    color: var(--admin-text-muted);
    margin-top: 4px;
}

/* ==========================================
   PANEL CARDS
   ========================================== */
.panel {
    background: var(--admin-surface);
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    overflow: hidden;
}
.panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--admin-text);
    margin: 0;
}
.panel-body { padding: 1.25rem; }
.panel-body-flush { padding: 0; }
.panel-body-flush > .dt-container { padding: .75rem 1.25rem; padding-top: 0; }
.panel-body-flush > .dt-container .dt-search,
.panel-body-flush > .dt-container .dt-info,
.panel-body-flush > .dt-container .dt-paging { padding-top: .5rem; }

/* ==========================================
   TABLES
   ========================================== */
.admin-table {
    width: 100%;
    font-size: 14px;
}
.admin-table thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--admin-text-muted);
    font-weight: 600;
    padding: .75rem 1rem;
    border-bottom: 2px solid var(--admin-border);
    white-space: nowrap;
}
.admin-table tbody td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--admin-border);
    vertical-align: middle;
}
.admin-table tbody tr:hover { background: #f7fafc; }
.admin-table tbody tr.selected { background: #ebf5fb; }

/* ==========================================
   BAR CHART (simple CSS)
   ========================================== */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 200px;
}
.bar-chart-item {
    flex: 1;
    text-align: center;
    max-width: 80px;
}
.bar-chart-bar {
    background: var(--admin-accent);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height .3s;
}
.bar-chart-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--admin-text);
    margin-top: 4px;
}
.bar-chart-label {
    font-size: 11px;
    color: var(--admin-text-muted);
}

/* ==========================================
   CHAT VIEWER (conversas)
   ========================================== */
.chat-viewer {
    display: flex;
    height: calc(100vh - 180px);
    gap: 0;
    background: white;
    border-radius: 10px;
    border: 1px solid var(--admin-border);
    overflow: hidden;
}
.chat-list-panel {
    width: 340px;
    flex-shrink: 0;
    border-right: 1px solid var(--admin-border);
    display: flex;
    flex-direction: column;
}

/* Conversation items */
.conversation-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--admin-border);
    transition: background .1s;
}
.conversation-item:hover { background: #f7fafc; }
.conversation-item.active { background: #ebf5fb; border-left: 3px solid var(--admin-accent); }
.conversation-avatar, .user-avatar-sm {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--admin-primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    flex-shrink: 0;
}
.conversation-info { flex: 1; min-width: 0; }
.conversation-name { font-size: 13px; font-weight: 600; color: var(--admin-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-email { font-size: 11px; color: var(--admin-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-meta { text-align: right; flex-shrink: 0; }
.conversation-badge {
    display: inline-block;
    background: var(--admin-accent);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
}
.conversation-time { display: block; font-size: 11px; color: var(--admin-text-muted); margin-top: 2px; }
.chat-messages-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.chat-messages-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--admin-border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-messages-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}
.chat-msg {
    max-width: 80%;
    margin-bottom: .75rem;
    padding: .75rem 1rem;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}
.chat-msg.usuario {
    background: #dbeafe;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.chat-msg.bot {
    background: #f1f5f9;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}
.chat-msg-meta {
    font-size: 11px;
    color: var(--admin-text-muted);
    margin-top: 4px;
}

/* ==========================================
   BADGES
   ========================================== */
.badge-ativo { background: #dcfce7; color: #166534; font-weight: 500; }
.badge-inativo { background: #f1f5f9; color: #64748b; font-weight: 500; }

/* ==========================================
   TABS (anamnese)
   ========================================== */
.admin-tabs .nav-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--admin-text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: .75rem 1rem;
}
.admin-tabs .nav-link.active {
    color: var(--admin-accent);
    border-bottom-color: var(--admin-accent);
    background: none;
}

/* ==========================================
   WIZARD (notificacoes)
   ========================================== */
.wizard-steps {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.wizard-step {
    flex: 1;
    text-align: center;
    padding: .5rem;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    background: #f1f5f9;
    color: var(--admin-text-muted);
}
.wizard-step.active {
    background: var(--admin-primary);
    color: white;
}
.wizard-step.done {
    background: #dcfce7;
    color: #166534;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 991px) {
    .admin-sidebar {
        left: calc(-1 * var(--admin-sidebar-width));
        transition: left .25s ease;
    }
    .admin-sidebar.mobile-open {
        left: 0;
    }
    .admin-header { left: 0 !important; }
    .admin-main { margin-left: 0 !important; }

    .chat-viewer { flex-direction: column; height: auto; }
    .chat-list-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--admin-border); max-height: 300px; }
    .chat-messages-panel { min-height: 400px; }
}

/* ==========================================
   USER PROFILE
   ========================================== */
.user-avatar-lg {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--admin-primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700;
    flex-shrink: 0;
}
.profile-badges .badge {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
}

/* ==========================================
   UTILITIES
   ========================================== */
.section-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 4rem; color: var(--admin-text-muted);
}
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
