/* ===================================================================
   Claude Code Web - Core Application Styles
   =================================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1a1a2e;
    --sidebar-hover: #16213e;
    --sidebar-active: #0f3460;
    --sidebar-text: #a0a0b8;
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --top-navbar-height: 56px;
}

/* ===================================================================
   Sidebar
   =================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 1040;
    overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--sidebar-text-active);
    font-size: 1.15rem;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-brand i {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    transition: opacity 0.2s ease;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
}

.sidebar-nav .nav {
    gap: 2px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    white-space: nowrap;
    border-radius: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
    font-size: 0.9rem;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 500;
}

.sidebar-nav .nav-link .badge {
    font-size: 0.7rem;
    padding: 0.25em 0.5em;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--sidebar-text);
    padding: 0.4rem 0;
    white-space: nowrap;
    font-size: 0.9rem;
}

.sidebar-user:hover {
    color: var(--sidebar-text-active);
}

.user-avatar i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.sidebar-footer .dropdown-menu {
    background: #16213e;
    border: 1px solid var(--sidebar-border);
    min-width: 180px;
}

.sidebar-footer .dropdown-item {
    color: var(--sidebar-text);
    font-size: 0.875rem;
}

.sidebar-footer .dropdown-item:hover {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.sidebar-footer .dropdown-divider {
    border-color: var(--sidebar-border);
}

/* Sidebar Conversation Tree */
.sidebar-tree-item .nav-link {
    cursor: default;
}

.sidebar-tree-label {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.sidebar-tree-label:hover {
    color: var(--sidebar-text-active);
}

.sidebar-tree-chevron {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    cursor: pointer;
    padding: 0.25rem;
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-tree-chevron:hover {
    opacity: 1;
}

.sidebar-tree-chevron[aria-expanded="true"] {
    transform: rotate(90deg);
}

.sidebar-tree-list {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0;
}

.sidebar-tree-list::-webkit-scrollbar {
    width: 3px;
}

.sidebar-tree-list::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-tree-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar-conv-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1.25rem 0.35rem 2.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-conv-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.sidebar-conv-model {
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--sidebar-text);
    flex-shrink: 0;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.sidebar-conv-time {
    font-size: 0.65rem;
    color: rgba(160, 160, 184, 0.6);
    flex-shrink: 0;
}

.sidebar-conv-loading {
    padding: 0.5rem 2.75rem;
    font-size: 0.75rem;
    color: rgba(160, 160, 184, 0.5);
}

.sidebar-conv-empty {
    padding: 0.5rem 2.75rem;
    font-size: 0.75rem;
    color: rgba(160, 160, 184, 0.5);
    font-style: italic;
}

/* Sidebar Collapsed Mode (Desktop) */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-user .nav-text,
.sidebar.collapsed .badge,
.sidebar.collapsed .sidebar-tree-chevron {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-tree-collapse {
    display: none !important;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
}

.sidebar.collapsed .sidebar-header {
    padding: 1rem 0;
    text-align: center;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.65rem 0;
}

.sidebar.collapsed .sidebar-footer {
    padding: 0.75rem 0;
    text-align: center;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
}

.sidebar.collapsed + .sidebar-overlay + .main-content,
.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}

.sidebar-overlay.show {
    display: block;
}

/* ===================================================================
   Main Content
   =================================================================== */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: #f8f9fa;
    transition: margin-left 0.3s ease;
}

/* Top Navbar */
.top-navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--top-navbar-height);
    padding: 0 1.25rem;
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.sidebar-toggle {
    font-size: 1.35rem;
    color: #495057;
    padding: 0.25rem;
    text-decoration: none;
    border: none;
    background: none;
}

.sidebar-toggle:hover {
    color: #212529;
}

.top-navbar-brand {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 500;
}

/* ===================================================================
   Auth Layout (Login / 2FA Pages)
   =================================================================== */

.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #1a1a2e 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.2);
}

/* ===================================================================
   Dashboard Stat Cards
   =================================================================== */

.stat-card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: #ffffff;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: #212529;
}

.stat-total {
    font-size: 0.9rem;
    font-weight: 400;
    color: #6c757d;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Purple color helper (not in Bootstrap) */
.bg-purple {
    background-color: rgba(111, 66, 193, 0.1) !important;
}

.text-purple {
    color: #6f42c1 !important;
}

/* ===================================================================
   Agent Slot Cards
   =================================================================== */

.agent-slot-card {
    border-radius: 0.5rem;
    border: 1px solid #e9ecef;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.agent-slot-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Status Dots */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.idle {
    background: #28a745;
}

.status-dot.running {
    background: #007bff;
    animation: pulse 1.5s infinite;
}

.status-dot.error {
    background: #dc3545;
}

.status-dot.stopping {
    background: #ffc107;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===================================================================
   Flash Alerts
   =================================================================== */

.flash-alert {
    transition: opacity 0.3s ease;
}

/* ===================================================================
   Tables
   =================================================================== */

.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    font-size: 0.9rem;
}

/* ===================================================================
   Scrollbar (Sidebar)
   =================================================================== */

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===================================================================
   Responsive (Mobile / Tablet)
   =================================================================== */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* On mobile, collapsed is not used -- only show/hide */
    .sidebar.collapsed {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }

    .sidebar.collapsed.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }
}

@media (max-width: 576px) {
    .auth-card {
        padding: 1.5rem;
        border-radius: 0.75rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
}
