/* ============================================================
   WAQILY — Design System
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
    --primary:        #4361ee;
    --primary-dark:   #3451d1;
    --primary-light:  #eef1fd;
    --success:        #10b981;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #3b82f6;
    --surface:        #ffffff;
    --bg:             #f1f5f9;
    --border:         #e2e8f0;
    --text:           #0f172a;
    --text-muted:     #64748b;
    --radius:         10px;
    --radius-lg:      14px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow:         0 4px 16px rgba(0,0,0,.08);
    --sidebar-w:      240px;
    --topbar-h:       60px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: .9rem;
    color: #0f172a;
    background-color: #f1f5f9;
    -webkit-font-smoothing: antialiased;
}

a { color: #4361ee; text-decoration: none; }
a:hover { color: #3451d1; }

/* ── Layout shell ────────────────────────────────────────── */
#wrapper {
    display: flex;
    min-height: 100vh;
}

/* ╔══════════════════════════════════════════════════════════╗
   ║  SIDEBAR                                                 ║
   ╚══════════════════════════════════════════════════════════╝ */
#sidebar {
    width: 240px;
    min-width: 240px;
    background-color: #0f172a;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
    scrollbar-width: none;
}
#sidebar::-webkit-scrollbar { display: none; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    height: 60px;
    min-height: 60px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background-color: #4361ee;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-size: .93rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: .15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nav list */
.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding-left: 0;
}

.sidebar-nav li {
    list-style: none !important;
    list-style-type: none !important;
    padding: 0;
    margin: 0;
}

.sidebar-section-label {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .9px;
    color: #475569;
    padding: 14px 20px 4px;
    display: block;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    margin: 1px 8px;
    border-radius: 7px;
    color: #94a3b8;
    font-size: .84rem;
    font-weight: 500;
    transition: background-color .14s, color .14s;
    white-space: nowrap;
    text-decoration: none;
}

.sidebar-nav .nav-link i {
    font-size: .95rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: #64748b;
    transition: color .14s;
}

.sidebar-nav .nav-link:hover {
    background-color: rgba(255,255,255,.07);
    color: #f1f5f9;
}
.sidebar-nav .nav-link:hover i { color: #94a3b8; }

.sidebar-nav .nav-link.active {
    background-color: rgba(67,97,238,.2);
    color: #818cf8;
    font-weight: 600;
}
.sidebar-nav .nav-link.active i { color: #818cf8; }

/* Footer / user tile */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background-color .14s;
    text-decoration: none !important;
}
.sidebar-user:hover { background-color: rgba(255,255,255,.07); }

.sidebar-avatar {
    width: 32px;
    height: 32px;
    background-color: #4361ee;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: .81rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: .71rem;
    color: #64748b;
}

/* ╔══════════════════════════════════════════════════════════╗
   ║  MAIN CONTENT AREA                                       ║
   ╚══════════════════════════════════════════════════════════╝ */
#page-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
    height: 60px;
    min-height: 60px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    flex-shrink: 0;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Page body ────────────────────────────────────────────── */
.page-body {
    padding: 24px;
    flex: 1;
}

/* ╔══════════════════════════════════════════════════════════╗
   ║  COMPONENTS                                              ║
   ╚══════════════════════════════════════════════════════════╝ */

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.06) !important;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 13px 18px !important;
    font-size: .86rem;
    background-color: #f8fafc !important;
    color: #0f172a;
}

.card-body { padding: 18px !important; }

.card-footer {
    border-top: 1px solid #e2e8f0 !important;
    border-radius: 0 0 12px 12px !important;
    padding: 10px 18px !important;
    background-color: #ffffff !important;
}

/* ── KPI / Stat cards ─────────────────────────────────────── */
.stat-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 12px 12px 0 0;
}

.stat-card.stat-blue::before   { background-color: #4361ee; }
.stat-card.stat-green::before  { background-color: #10b981; }
.stat-card.stat-amber::before  { background-color: #f59e0b; }
.stat-card.stat-red::before    { background-color: #ef4444; }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
    margin-bottom: 14px;
}

.stat-icon.blue  { background-color: #eef1fd; color: #4361ee; }
.stat-icon.green { background-color: #d1fae5; color: #059669; }
.stat-icon.amber { background-color: #fef3c7; color: #d97706; }
.stat-icon.red   { background-color: #fee2e2; color: #dc2626; }

.stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: .75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ── Tables ──────────────────────────────────────────────── */
.table {
    margin-bottom: 0;
    font-size: .865rem;
}

.table thead th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .7px;
    font-weight: 700;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0 !important;
    border-top: none;
    padding: 10px 14px;
    background-color: #f8fafc;
    white-space: nowrap;
}

.table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #0f172a;
}

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

.table-hover tbody tr:hover td { background-color: #f8faff; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    font-weight: 600;
    font-size: .71rem;
    letter-spacing: .2px;
    padding: 4px 10px;
    border-radius: 20px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    font-size: .84rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 7px 16px;
    transition: all .15s;
}

.btn-sm {
    font-size: .78rem;
    padding: 5px 12px;
    border-radius: 6px;
}

.btn-primary {
    background-color: #4361ee;
    border-color: #4361ee;
    color: #fff;
}
.btn-primary:hover,
.btn-primary:focus {
    background-color: #3451d1;
    border-color: #3451d1;
    color: #fff;
}

.btn-outline-primary {
    color: #4361ee;
    border-color: #4361ee;
}
.btn-outline-primary:hover {
    background-color: #4361ee;
    border-color: #4361ee;
    color: #fff;
}

.btn-outline-secondary {
    color: #64748b;
    border-color: #e2e8f0;
}
.btn-outline-secondary:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: .875rem;
    padding: 8px 12px;
    transition: border-color .15s, box-shadow .15s;
    color: #0f172a;
    background-color: #ffffff;
}

.form-control:focus, .form-select:focus {
    border-color: #4361ee;
    box-shadow: 0 0 0 3px rgba(67,97,238,.1);
    outline: none;
}

.form-label {
    font-size: .81rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 5px;
}

.form-control-sm, .form-select-sm {
    font-size: .81rem;
    padding: 5px 10px;
    border-radius: 6px;
}

.form-text { font-size: .77rem; color: #94a3b8; }

/* ── List groups ─────────────────────────────────────────── */
.list-group-item {
    border-color: #e2e8f0;
    font-size: .865rem;
    padding: 11px 16px;
}

.list-group-item-action:hover {
    background-color: #f8faff;
    color: #0f172a;
}

/* ── Pagination ──────────────────────────────────────────── */
.page-link {
    border-color: #e2e8f0;
    color: #4361ee;
    font-size: .81rem;
    border-radius: 6px !important;
    margin: 0 2px;
}
.page-item.active .page-link {
    background-color: #4361ee;
    border-color: #4361ee;
}

/* ── Code ────────────────────────────────────────────────── */
code {
    font-size: .8rem;
    color: #4361ee;
    background-color: #eef1fd;
    padding: 2px 7px;
    border-radius: 4px;
}

/* ── Detail rows (key-value pairs) ──────────────────────── */
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: .875rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: #64748b; font-weight: 500; }
.detail-row .value { font-weight: 500; color: #0f172a; text-align: right; }

/* ── Auth ────────────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.auth-card {
    background-color: #ffffff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.auth-logo-icon {
    width: 40px; height: 40px;
    background-color: #4361ee;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: #fff;
}

/* ── Section heading inside page ─────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-header h6 {
    font-size: .88rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        transition: transform .25s;
    }
    #sidebar.open { transform: translateX(0); }
    #page-content { margin-left: 0; }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
