/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg) var(--spacing-md);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sidebar);
    overflow-y: auto;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--spacing-xl);
    min-height: 100vh;
}

/* ── Sidebar Nav ── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-teal);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.sidebar-logo .logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--foreground-primary);
}

.nav-section {
    margin-bottom: var(--spacing-sm);
}

.nav-section-label {
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--foreground-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--spacing-sm) var(--spacing-md);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px var(--spacing-md);
    border-radius: var(--radius-md);
    color: var(--foreground-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--surface-hover);
    color: var(--foreground-primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--surface-elevated);
    color: var(--foreground-primary);
    font-weight: 600;
}

.nav-item.active i[data-lucide] { color: var(--accent-teal); }

.nav-item i[data-lucide] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-spacer { flex: 1; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    margin-top: var(--spacing-sm);
}

.sidebar-user .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 0.875rem; font-weight: 500; color: var(--foreground-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 0.75rem; color: var(--foreground-muted); }

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
}

.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
}

.stat-card .stat-label { font-size: 0.75rem; font-weight: 500; color: var(--foreground-secondary); margin-bottom: var(--spacing-sm); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--foreground-primary); }
.stat-card .stat-sub { font-size: 0.75rem; color: var(--foreground-muted); margin-top: var(--spacing-xs); }

/* ── Cards ── */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 { font-size: 0.875rem; font-weight: 600; }
.card-body { padding: var(--spacing-lg); }

/* ── Data Table ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--foreground-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px var(--spacing-md);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
}

.data-table td {
    padding: 12px var(--spacing-md);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--foreground-primary);
}

.data-table tr:hover td { background: var(--surface-hover); }
.data-table tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge--success { background: rgba(34, 197, 94, 0.13); color: #22C55E; }
.badge--warning { background: rgba(245, 158, 11, 0.13); color: #F59E0B; }
.badge--error { background: rgba(255, 102, 102, 0.13); color: #FF6666; }
.badge--info { background: rgba(75, 123, 245, 0.13); color: #4B7BF5; }
.badge--idle { background: rgba(102, 102, 102, 0.13); color: #666666; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--accent-teal);
    color: var(--foreground-primary);
}

.btn-primary:hover { background: #178a64; }

.btn-secondary {
    background: transparent;
    color: var(--foreground-secondary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--foreground-primary);
}

.btn-sm { padding: 6px 12px; font-size: 0.75rem; }

.btn-danger { background: rgba(255, 102, 102, 0.15); color: #FF6666; }
.btn-danger:hover { background: rgba(255, 102, 102, 0.25); }

.btn i[data-lucide] { width: 16px; height: 16px; }

/* ── Forms ── */
.form-group { margin-bottom: var(--spacing-md); }
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground-secondary);
    margin-bottom: var(--spacing-xs);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--foreground-primary);
    font-size: 0.875rem;
    transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-teal);
}

.form-textarea { resize: vertical; min-height: 100px; }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 12px var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
}

.alert-success { background: rgba(34, 197, 94, 0.1); color: #22C55E; border: 1px solid rgba(34, 197, 94, 0.2); }
.alert-error { background: rgba(255, 102, 102, 0.1); color: #FF6666; border: 1px solid rgba(255, 102, 102, 0.2); }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: #F59E0B; border: 1px solid rgba(245, 158, 11, 0.2); }
.alert-info { background: rgba(75, 123, 245, 0.1); color: #4B7BF5; border: 1px solid rgba(75, 123, 245, 0.2); }

.alert .alert-dismiss {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.7;
}

.alert .alert-dismiss:hover { opacity: 1; }

/* ── Agent Card ── */
.agent-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.agent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 0.875rem; font-weight: 600; }
.agent-role { font-size: 0.75rem; color: var(--foreground-muted); }

/* ── Activity Row ── */
.activity-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px var(--spacing-md);
    border-bottom: 1px solid var(--border-subtle);
}

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

.activity-time { font-size: 0.75rem; color: var(--foreground-muted); width: 40px; flex-shrink: 0; font-weight: 500; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px; }
.activity-dot--teal { background: var(--accent-teal); }
.activity-dot--purple { background: var(--accent-purple); }
.activity-dot--blue { background: var(--accent-blue); }
.activity-dot--orange { background: var(--accent-orange); }
.activity-text { font-size: 0.875rem; color: var(--foreground-primary); }
.activity-detail { font-size: 0.75rem; color: var(--foreground-muted); }

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--spacing-lg);
}

.tab {
    padding: 12px var(--spacing-lg);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.tab:hover { color: var(--foreground-primary); text-decoration: none; }
.tab.active { color: var(--foreground-primary); border-bottom-color: var(--accent-teal); font-weight: 600; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--foreground-muted);
}

.empty-state i[data-lucide] { width: 48px; height: 48px; margin: 0 auto var(--spacing-md); opacity: 0.3; }
.empty-state p { font-size: 0.875rem; }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--surface-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 { font-size: 1rem; }

.modal-close { cursor: pointer; color: var(--foreground-muted); }
.modal-close:hover { color: var(--foreground-primary); }

.modal-body { padding: var(--spacing-lg); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-subtle);
}

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-primary);
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--border-subtle) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: 0.3;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--spacing-xl);
}

.login-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-teal);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.login-logo .logo-text {
    font-size: 1.375rem;
    font-weight: 700;
}

.login-card .form-group { margin-bottom: var(--spacing-md); }

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    margin-top: var(--spacing-sm);
}

/* ── Mobile ── */
.sidebar-toggle { display: none; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-sidebar) - 1);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; padding: var(--spacing-md); }
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: var(--radius-md);
        background: var(--surface-card);
        border: 1px solid var(--border-subtle);
        color: var(--foreground-primary);
        cursor: pointer;
    }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
