/* =========================================================================
   AIDA Dashboard — Main Stylesheet
   Dark sidebar, light content, responsive layout
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Reset & Base
   --------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sidebar-bg: #1a1a2e;
    --sidebar-hover: #16213e;
    --sidebar-active: #0f3460;
    --sidebar-text: #a8b2c1;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 240px;

    --topbar-bg: #ffffff;
    --topbar-shadow: 0 1px 3px rgba(0,0,0,0.08);

    --content-bg: #f0f2f5;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06);
    --card-radius: 8px;

    --text-primary: #1a1a2e;
    --text-secondary: #5a6474;
    --text-muted: #8c95a4;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #6366f1;

    --border: #e2e5ea;
    --input-bg: #ffffff;
    --input-border: #d1d5db;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
}

html { font-size: 14px; }

body {
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--content-bg);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Layout: sidebar + main
   --------------------------------------------------------------------------- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 20px 18px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span.icon { font-size: 1.5rem; }

.sidebar-nav { flex: 1; padding: 8px 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.93rem;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #dde1e8;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--accent);
}

.sidebar-nav a .nav-icon {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 18px;
    font-size: 0.78rem;
    color: rgba(168,178,193,0.5);
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* Main content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top bar */
.topbar {
    background: var(--topbar-bg);
    box-shadow: var(--topbar-shadow);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.topbar-right a { color: var(--text-secondary); }
.topbar-right a:hover { color: var(--danger); }

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 4px 8px;
}

/* Content area */
.content {
    flex: 1;
    padding: 24px;
}

/* ---------------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------------- */
.card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Stat cards grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-value.accent { color: var(--accent); }
.stat-card .stat-value.success { color: var(--success); }
.stat-card .stat-value.warning { color: var(--warning); }
.stat-card .stat-value.danger { color: var(--danger); }

/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    background: #f7f8fa;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover { background: #f7f9fc; }

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

/* Clickable rows */
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #eef2ff; }

/* ---------------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0e7ff; color: #3730a3; }
.badge-muted   { background: #f3f4f6; color: #6b7280; }

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

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

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-secondary);
}
.btn-outline:hover { background: #f3f4f6; color: var(--text-primary); }

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.9rem;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

textarea { resize: vertical; min-height: 80px; }

select { cursor: pointer; }

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.form-inline .form-group { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   Flash messages
   --------------------------------------------------------------------------- */
.flash {
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: flashIn 0.3s ease;
}

.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info    { background: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.flash .close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0 4px;
}
.flash .close-btn:hover { opacity: 1; }

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

/* ---------------------------------------------------------------------------
   Pagination
   --------------------------------------------------------------------------- */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 16px;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    text-decoration: none;
}

.pagination a {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.pagination a:hover { background: #f3f4f6; text-decoration: none; }

.pagination .active {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}

.pagination .disabled {
    color: var(--text-muted);
    pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Tabs
   --------------------------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.tabs a {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tabs a:hover { color: var(--text-primary); text-decoration: none; }

.tabs a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Detail / Expand panels
   --------------------------------------------------------------------------- */
.detail-panel {
    background: #f7f9fc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    margin: 8px 0 16px;
    display: none;
}

.detail-panel.open { display: block; }

.detail-panel pre {
    background: #1a1a2e;
    color: #e0e0e0;
    padding: 14px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Login page
   --------------------------------------------------------------------------- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
}

.login-box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.login-box h1 {
    font-size: 1.6rem;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-box .error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.88rem;
}

.login-box .btn { width: 100%; justify-content: center; padding: 10px; }

/* ---------------------------------------------------------------------------
   Utility
   --------------------------------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.82rem; }
.text-mono { font-family: var(--mono); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

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

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .main {
        margin-left: 0;
    }

    .hamburger { display: block; }

    .content { padding: 16px; }

    .stat-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .form-inline { flex-direction: column; align-items: stretch; }

    .topbar { padding: 0 14px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .login-box { margin: 16px; padding: 28px; }
}
