/* ============================================================================
   QueryGate — admin theme (Bootstrap 5 overlay).
   Class names are kept stable with the layout; this file restyles them.
   ============================================================================ */
:root {
    --accent: #1E5BA8;
    --accent-600: #1A4F93;
    --accent-700: #17488A;
    --accent-soft: #EAF1FA;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e8edf2;
    --bg: #f6f8fb;
    --card: #ffffff;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
    --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .25);

    --bs-primary: #1E5BA8;
    --bs-primary-rgb: 30, 91, 168;
    --bs-body-bg: #f6f8fb;
    --bs-body-color: #0f172a;
    --bs-border-color: #e8edf2;
    --bs-link-color: #17488A;
    --bs-link-hover-color: #0F3566;
    --bs-border-radius: 10px;
}

* { -webkit-font-smoothing: antialiased; }
body {
    font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    letter-spacing: -0.005em;
}
html[dir="rtl"] body { font-family: 'IBM Plex Sans Arabic', 'Tajawal', system-ui, sans-serif; }
h1, h2, h3, .h3, .h4, .h5 { letter-spacing: -0.02em; }
code { color: var(--accent-700); background: var(--accent-soft); padding: .1rem .35rem; border-radius: 6px; font-size: .85em; }

/* ---------------- App shell ---------------- */
.qg-shell { min-height: 100vh; display: flex; }

.qg-sidebar {
    width: 16rem;
    flex-shrink: 0;
    min-height: 100vh;
    color: #E6EEF8;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0B1F3A 0%, #102B50 55%, #17488A 100%);
    position: sticky; top: 0; height: 100vh;
    box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
}
.qg-brand {
    padding: 1.25rem 1.1rem;
    display: flex; align-items: center; gap: .7rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.qg-brand img { height: 2.1rem; width: auto; }
.qg-brand .title { font-size: .9rem; font-weight: 700; line-height: 1.1; color: #fff; }
.qg-brand .subtitle { font-size: .62rem; color: #9DBBE3; text-transform: uppercase; letter-spacing: .13em; margin-top: 2px; }

.qg-nav { margin-top: .85rem; flex: 1; padding: 0 .7rem; display: flex; flex-direction: column; gap: .18rem; }
.qg-nav a {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem;
    border-radius: 10px;
    font-size: .875rem; font-weight: 500;
    color: #B4C6DD;
    text-decoration: none;
    position: relative;
    transition: background-color .18s, color .18s, transform .18s;
}
.qg-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.qg-nav a.active {
    background: linear-gradient(90deg, rgba(30,91,168,.28), rgba(30,91,168,.10));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(30,91,168,.35);
}
.qg-nav a.active::before {
    content: ""; position: absolute; inset-inline-start: -.7rem; top: 50%; transform: translateY(-50%);
    width: 3px; height: 1.35rem; border-radius: 0 4px 4px 0; background: var(--accent);
}
html[dir="rtl"] .qg-nav a.active::before { border-radius: 4px 0 0 4px; }
.qg-nav a svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; opacity: .9; }

.qg-userbox {
    margin: .5rem .7rem 1rem;
    padding: .7rem .75rem;
    border-radius: 12px;
    background: rgba(255,255,255,.05);
    display: flex; align-items: center; gap: .7rem;
}
.qg-avatar {
    width: 2.1rem; height: 2.1rem; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #5B8FD6);
    color: #0B1F3A; font-weight: 800; font-size: .85rem;
    display: flex; align-items: center; justify-content: center; text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(30,91,168,.4);
}
.qg-userbox .name { font-size: .82rem; font-weight: 600; color: #fff; }
.qg-userbox .role { font-size: .7rem; color: #9DBBE3; }

.qg-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.qg-header {
    position: sticky; top: 0; z-index: 20;
    background: rgba(255,255,255,.82);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    padding: .85rem 1.75rem;
    display: flex; align-items: center; justify-content: space-between;
}
.qg-header h2 { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin: 0; }
.qg-header .actions { display: flex; align-items: center; gap: 1rem; }
.qg-header .actions a, .qg-header .actions button { color: var(--muted); font-size: .85rem; text-decoration: none; font-weight: 500; }
.qg-header .actions a:hover, .qg-header .actions button:hover { color: var(--ink); }
.qg-content { flex: 1; padding: 1.75rem; max-width: 1400px; width: 100%; }

/* page title row spacing */
.qg-content > .d-flex.justify-content-between:first-child,
.qg-content > h1 { margin-bottom: 1.25rem !important; }
.qg-content h1.h3 { font-size: 1.5rem; font-weight: 700; }

/* ---------------- Buttons ---------------- */
.btn { border-radius: 10px; font-weight: 600; font-size: .875rem; padding: .5rem .95rem; transition: all .16s; }
.btn-sm { border-radius: 8px; padding: .3rem .6rem; font-size: .8rem; }
.btn-primary {
    --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-600); --bs-btn-hover-border-color: var(--accent-600);
    --bs-btn-active-bg: var(--accent-700); --bs-btn-active-border-color: var(--accent-700);
    --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent);
    color: #fff; box-shadow: 0 1px 2px rgba(30,91,168,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(30,91,168,.32); }
.btn-outline-primary { --bs-btn-color: var(--accent-700); --bs-btn-border-color: #C3D5EE; --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent-600); }
.btn-outline-secondary { --bs-btn-color: #475569; --bs-btn-border-color: #dbe2ea; --bs-btn-hover-bg: #f1f5f9; --bs-btn-hover-border-color: #cbd5e1; --bs-btn-hover-color: #0f172a; }
.btn-outline-danger { --bs-btn-border-color: #f3c9c9; }
.btn-outline-warning { --bs-btn-border-color: #f3e0b3; }
.btn-link { text-decoration: none; }

/* ---------------- Cards ---------------- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--card);
}
.card-body { padding: 1.35rem; }
.card-header {
    background: transparent; border-bottom: 1px solid var(--line);
    font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #475569;
    padding: .9rem 1.35rem;
}
.shadow-sm { box-shadow: var(--shadow-sm) !important; }

/* ---------------- Tables ---------------- */
.table { --bs-table-hover-bg: #f7fafc; margin: 0; color: var(--ink); }
.table thead th {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    color: #94a3b8; font-weight: 700; border-bottom: 1px solid var(--line);
    padding: .8rem 1rem; background: #fcfdfe;
}
.table tbody td { padding: .8rem 1rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table-responsive { border-radius: var(--radius); }

/* ---------------- Badges (soft/pill) ---------------- */
.badge { font-weight: 600; padding: .35em .7em; border-radius: 999px; font-size: .72rem; letter-spacing: .01em; }
.badge.bg-success { background: #e7f8ef !important; color: #08875d !important; }
.badge.bg-danger  { background: #fdecec !important; color: #d63b3b !important; }
.badge.bg-secondary { background: #eef2f7 !important; color: #55637a !important; }
.badge.bg-primary { background: #EAF1FA !important; color: var(--accent-700) !important; }
.badge.bg-info { background: #e8f4fb !important; color: #1f7fb8 !important; }
.badge.bg-warning { background: #fdf3e0 !important; color: #b8791f !important; }

/* ---------------- Forms ---------------- */
.form-label { font-weight: 600; font-size: .8rem; color: #475569; margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: 10px; border: 1px solid #dde5ee; padding: .55rem .8rem; font-size: .9rem;
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,91,168,.15); }
.form-control::placeholder { color: #aab6c6; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(30,91,168,.15); }
textarea.font-monospace { font-size: .82rem; }

/* Tabs */
.nav-tabs { border-bottom: 1px solid var(--line); gap: .25rem; }
.nav-tabs .nav-link { border: 0; color: var(--muted); font-weight: 600; font-size: .875rem; border-radius: 8px 8px 0 0; padding: .6rem 1rem; }
.nav-tabs .nav-link:hover { color: var(--ink); background: #f1f5f9; }
.nav-tabs .nav-link.active { color: var(--accent-700); background: transparent; border-bottom: 2px solid var(--accent); }

/* ---------------- Alerts ---------------- */
.alert { border-radius: 12px; border: 1px solid transparent; font-size: .875rem; padding: .8rem 1rem; box-shadow: var(--shadow-sm); }
.alert-success { background: #ecfdf5; border-color: #b7ebd2; color: #067a54; }
.alert-danger { background: #fef2f2; border-color: #f6d0d0; color: #c23b3b; }
.alert-warning { background: #fffbeb; border-color: #fde9bf; color: #a86a12; }
.alert-info { background: #eff6ff; border-color: #cfe2fb; color: #1f6fb2; }

/* ---------------- Dashboard KPI cards ---------------- */
.kpi { display: flex; align-items: center; gap: 1rem; }
.kpi-icon {
    width: 3rem; height: 3rem; border-radius: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg { width: 1.4rem; height: 1.4rem; }
.kpi-teal { background: #EAF1FA; color: var(--accent-700); }
.kpi-green { background: #e7f8ef; color: #08875d; }
.kpi-blue { background: #e8f4fb; color: #1f7fb8; }
.kpi-slate { background: #eef2f7; color: #55637a; }
.kpi-red { background: #fdecec; color: #d63b3b; }
.kpi .val { font-size: 1.7rem; font-weight: 800; line-height: 1; color: var(--ink); }
.kpi .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; font-weight: 600; margin-top: .25rem; }
.card.stat-card { transition: transform .18s, box-shadow .18s; }
.card.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* Empty states */
.table tbody td.text-center.text-muted { color: #9aa7b8 !important; font-size: .9rem; }

/* Pagination */
.pagination { --bs-pagination-color: #475569; --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent); --bs-pagination-border-radius: 9px; gap: .25rem; }
.page-link { border-radius: 9px !important; border: 1px solid var(--line); font-size: .85rem; }

/* Language dropdown */
.qg-lang .dropdown-toggle { border: 1px solid var(--line); padding: .4rem .7rem; border-radius: 9px; background: #fff; }
.dropdown-menu { border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); padding: .35rem; }
.dropdown-item { border-radius: 8px; font-size: .85rem; padding: .45rem .7rem; }
.dropdown-item.active, .dropdown-item:active { background: var(--accent-soft); color: var(--accent-700); }

/* ---------------- Auth / login ---------------- */
.qg-auth {
    min-height: 100vh; display: flex;
    background:
        linear-gradient(135deg, rgba(11,31,58,.92) 0%, rgba(16,43,80,.82) 48%, rgba(30,91,168,.55) 100%),
        url('/images/login_bg.jpg');
    background-size: cover; background-position: center; background-attachment: fixed;
}
.qg-auth-brand { width: 52%; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 3rem; color: #fff; text-align: center; }
.qg-auth-brand img { height: 4.2rem; margin-bottom: 1.5rem; }
.qg-auth-brand h1 { font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; }
.qg-auth-brand .portal { color: #9DBBE3; font-size: .72rem; text-transform: uppercase; letter-spacing: .28em; margin: .35rem 0 1.75rem; }
.qg-auth-brand .lead { color: #DCE7F5; font-size: 1.05rem; line-height: 1.75; max-width: 30rem; opacity: .95; }
.qg-auth-stats { margin-top: 2.5rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; max-width: 30rem; }
.qg-auth-stats > div { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 1rem .5rem; backdrop-filter: blur(4px); }
.qg-auth-stats .v { font-size: 1.25rem; font-weight: 800; }
.qg-auth-stats .l { color: #B4CBEA; font-size: .66rem; margin-top: .3rem; line-height: 1.3; }
.qg-auth-form { width: 48%; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 3rem 1.5rem; }
.qg-auth-card { width: 100%; max-width: 27rem; background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); padding: 2.25rem; }
.qg-auth-foot { color: #C3D5EE; font-size: .72rem; text-align: center; margin-top: 1.5rem; }
@media (max-width: 991px) { .qg-auth-brand { display: none; } .qg-auth-form { width: 100%; } }

/* Misc utility */
.text-muted { color: #94a3b8 !important; }
dl.row dt { color: #64748b; font-weight: 600; }
hr { border-color: var(--line); opacity: 1; }
