/* =====================================================================
   drAdmin — Global Theme Override (mobile-first)
   Loaded LAST in styles/css.php so it restyles every page at once.
   Overrides visual properties only (color, surface, radius, typography);
   layout/positioning is left to the template + responsive.css + sidebar JS.
   ===================================================================== */

:root {
    --body-font: "Jost", sans-serif;
    --body-color: #070044;
    --bg-color: #edb606;
    --para-color: #f7f4ff;
    --para-alt-color: #b2b4e1;
    --hover-color: #edb606;
    --hover-alt-color: #5ac4ff;
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bg-nav: #2d0572;
    --alt-blue: #273579;
    --body-rgb: 7, 0, 68;
    --bg-nav-rgb: 45, 5, 114;
    --gold: #edb606;
    --gold-dim: rgba(237, 182, 6, 0.1);
    --gold-border: rgba(237, 182, 6, 0.22);
    --card-border: rgba(237, 182, 6, 0.18);
    --text-primary: #f0eaff;
    --text-muted: #8a7faa;

    --dark-bg: #0a001f;
    --dark-card: #1a0a3d;
    --dark-text: #f7f4ff;
    --dark-text-alt: #b2b4e1;
    --dark-border: #2d1a5c;
    --dark-shadow: rgba(0, 0, 0, 0.3);

    --primary-color: #0a043c;
    --secondary-color: #fea500;
    --card-bg: rgba(26, 10, 61, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);

    /* Derived tokens used across the theme */
    --surface: #150637;
    --surface-2: #1f0a4d;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-gold: 0 6px 18px rgba(237, 182, 6, 0.18);
}

/* ------------------------------ Base ------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Jost:wght@300;400;500;600;700&display=swap');

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--body-font);
    background: radial-gradient(1200px 800px at 15% -10%, #1a0a3d 0%, var(--dark-bg) 55%) fixed, var(--dark-bg);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; }
p { color: var(--para-alt-color); }
a { color: var(--gold); }
a:hover { color: var(--hover-alt-color); }

.text-white { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-muted) !important; }
.text-dark { color: var(--dark-text) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Custom scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--gold-border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--gold-border); border-radius: 8px; }

/* ------------------------------ Cards ------------------------------ */
.iq-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(6px);
}
.iq-card .iq-card-header { border-bottom: 1px solid var(--border-color); }
.iq-card-body { color: var(--para-alt-color); }
.iq-card-icon,
.iq-bg-primary { background: var(--gold-dim) !important; color: var(--gold) !important; }

/* Stat numbers pop in gold */
.iq-card-body h4 b, .iq-card-body h2, .iq-card-body .counter { color: var(--gold); }

/* ------------------------------ Sidebar ------------------------------ */
.iq-sidebar {
    background: linear-gradient(180deg, var(--bg-nav) 0%, var(--primary-color) 100%);
    border-right: 1px solid var(--dark-border);
}
.iq-sidebar-menu .iq-menu li a { color: var(--para-alt-color); border-radius: var(--radius-sm); }
.iq-sidebar-menu .iq-menu li a:hover,
.iq-sidebar-menu .iq-menu li.active > a {
    color: #1a0a3d;
    background: var(--gold);
    box-shadow: var(--shadow-gold);
}
.iq-sidebar-menu .iq-menu li.active > a i,
.iq-sidebar-menu .iq-menu li a:hover i { color: #1a0a3d; }
.iq-navbar-logo { padding: 10px; }

/* ------------------------------ Top navbar ------------------------------ */
.iq-top-navbar {
    background: rgba(45, 5, 114, 0.85);
    border-bottom: 1px solid var(--dark-border);
    backdrop-filter: blur(8px);
}
.iq-top-navbar .navbar-list li > a { color: var(--para-alt-color); }
.iq-sub-dropdown, .iq-user-dropdown .iq-card { background: var(--surface-2); }
.wrapper-menu .main-circle i, .wrapper-menu .hover-circle i { color: var(--gold); }

/* ------------------------------ Buttons ------------------------------ */
.btn { border-radius: 999px; font-weight: 500; letter-spacing: .2px; }
.btn-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: #1a0a3d;
}
.btn-primary:hover, .btn-primary:focus {
    background: #ffcb1f;
    border-color: #ffcb1f;
    color: #1a0a3d;
    box-shadow: var(--shadow-gold);
}
.btn-warning { background: var(--secondary-color); border-color: var(--secondary-color); color: #1a0a3d; }
.btn-secondary { background: var(--alt-blue); border-color: var(--alt-blue); color: #fff; }
.btn-outline-primary { color: var(--gold); border-color: var(--gold); }
.btn-outline-primary:hover { background: var(--gold); color: #1a0a3d; }
.bg-primary { background: var(--bg-nav) !important; }

/* ------------------------------ Forms ------------------------------ */
.form-control, .form-select, .custom-select {
    background: rgba(10, 4, 60, 0.55);
    border: 1px solid var(--dark-border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
    background: rgba(10, 4, 60, 0.75);
    border-color: var(--gold);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.15rem var(--gold-dim);
}
.form-control::placeholder { color: var(--text-muted); }
label, .control-label { color: var(--para-alt-color); }

/* Select2 legibility (template sets odd colors) */
.select2-container--default .select2-selection--single,
.select2-dropdown { background: var(--surface-2); border-color: var(--dark-border); color: var(--text-primary); }
.select2-results { color: var(--text-primary) !important; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--gold); color: #1a0a3d; }

/* ------------------------------ Tables / DataTables ------------------------------ */
.table { color: var(--para-alt-color); }
.table thead th { color: var(--gold); border-bottom: 1px solid var(--gold-border); }
.table td, .table th { border-color: var(--border-color); }
.table-hover tbody tr:hover { background: var(--gold-dim); }
table.dataTable tbody tr { background: transparent; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: rgba(10, 4, 60, 0.55); border: 1px solid var(--dark-border); color: var(--text-primary); border-radius: var(--radius-sm);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--para-alt-color) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--gold) !important; color: #1a0a3d !important; border: none; border-radius: 8px; }
.dt-button { background: var(--gold) !important; border: none !important; color: #1a0a3d !important; border-radius: 999px !important; }

/* ------------------------------ Modals ------------------------------ */
.modal-content { background: var(--surface-2); border: 1px solid var(--card-border); border-radius: var(--radius); color: var(--text-primary); }
.modal-header, .modal-footer { border-color: var(--border-color); }
.modal-title { color: var(--gold); }
.close, .modal-header .close { color: var(--para-alt-color); text-shadow: none; opacity: .9; }

/* ------------------------------ Badges / misc ------------------------------ */
.badge-primary { background: var(--gold); color: #1a0a3d; }
.badge-success { background: #1faa59; }
.badge-danger { background: #e0454e; }
hr { border-color: var(--border-color); }
.iq-bg-primary-hover:hover { background: var(--gold-dim) !important; }

/* ------------------------------ Auth pages ------------------------------ */
#loginpage, body.sign-in-page, .sign-in-page {
    background: radial-gradient(900px 600px at 50% -10%, #2d0572 0%, var(--dark-bg) 60%) fixed, var(--dark-bg);
}
.sign-in-from, .sign-in-page-data { background: var(--surface-2) !important; border-radius: var(--radius); }
.sign-in-from .form-control { background: rgba(10, 4, 60, 0.5); }
.sign-in-page .sign-in-from h1,
.sign-in-page .sign-in-from p { color: var(--text-primary); }

/* ================================================================
   Mobile-first responsive polish
   Base rules above already assume small screens; scale up below.
   ================================================================ */
@media (max-width: 575.98px) {
    body { font-size: 14px; }
    .iq-card { border-radius: var(--radius-sm); }
    .container-fluid { padding-left: 12px; padding-right: 12px; }
    .iq-card-body { padding: 14px; }
    h1 { font-size: 1.5rem; }
    /* Let wide DataTables scroll instead of breaking layout on phones */
    .table-responsive, .dataTables_wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .btn { padding: .5rem .9rem; }
    .modal-dialog { margin: .5rem; }
}

@media (min-width: 992px) {
    body { font-size: 15px; }
    .iq-card-body { padding: 20px; }
}

/* ================================================================
   Responsive tables → cards (mobile)
   DataTables Responsive collapses overflow columns into an
   expandable child "card"; below we theme that card and also
   transform plain server-rendered tables into cards on phones.
   ================================================================ */

/* --- DataTables Responsive: expand/collapse control (the +/-) --- */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    background-color: var(--gold);
    border: none;
    color: #1a0a3d;
    box-shadow: var(--shadow-gold);
}
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before {
    background-color: var(--secondary-color);
    color: #1a0a3d;
}
/* The expanded child row rendered as a labelled card */
table.dataTable > tbody > tr.child ul.dtr-details {
    display: block;
    width: 100%;
}
table.dataTable > tbody > tr.child {
    background: var(--surface-2);
}
table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom: 1px solid var(--border-color);
    padding: 8px 0;
}
table.dataTable > tbody > tr.child span.dtr-title {
    color: var(--gold);
    min-width: 40%;
    font-weight: 600;
}
table.dataTable > tbody > tr.child span.dtr-data {
    color: var(--text-primary);
}

/* --- Plain (non-DataTable) tables → stacked cards on phones --- */
@media (max-width: 767.98px) {
    /* Applies to custom tables opted-in via .articles-table */
    .articles-table thead {
        position: absolute;
        left: -9999px;
        top: -9999px;
    }
    .articles-table,
    .articles-table tbody,
    .articles-table tr,
    .articles-table td {
        display: block;
        width: 100%;
    }
    .articles-table tr {
        background: var(--card-bg);
        border: 1px solid var(--card-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-soft);
        margin-bottom: 16px;
        padding: 8px 14px;
    }
    .articles-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: right;
        border: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px 0;
    }
    .articles-table td:last-child { border-bottom: none; }
    /* Field label pulled from data-label on each cell */
    .articles-table td::before {
        content: attr(data-label);
        color: var(--gold);
        font-weight: 600;
        text-align: left;
        flex: 0 0 40%;
    }
    /* Let the Actions row wrap its buttons full width */
    .articles-table td[data-label="Actions"] {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }
    .articles-table td[data-label="Actions"] .action-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }
}
