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

:root {
    --primary: #D4A373;
    --primary-hover: #b5835a;
    --secondary: #457B9D;
    --accent-orange: #E76F51;
    --success: #2ec4b6;
    --warning: #ff9f1c;
    --danger: #e71d36;
    --info: #457B9D;
    
    /* Light Theme (Default) */
    --bg-main: #f4f5f7;
    --bg-card: #ffffff;
    --bg-cream: #f4f5f7;
    --bg-sidebar: #1E1A18; /* Luxury Academic Dark Sidebar */
    --text-main: #2b221e;
    --text-dark: #2b221e;
    --text-muted: #7d6e68;
    --text-sidebar: #e5dfd9;
    --border-color: #e6dfd5;
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 20px rgba(0,0,0,0.08);
    --shadow-3d: 0 18px 34px rgba(43, 34, 30, 0.10), 0 2px 0 rgba(255,255,255,0.85) inset;
}

/* Dark Theme Overrides */
[data-theme="dark"] {
    --bg-main: #121214;
    --bg-card: #1d1d21;
    --bg-sidebar: #0d0d0e;
    --text-main: #f1ede9;
    --text-muted: #a3958f;
    --text-sidebar: #d4cdc5;
    --border-color: #2e2c35;
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-md: 0 10px 20px rgba(0,0,0,0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Layout Structure --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--border-color);
}
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 16, 14, 0.48);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}
.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-logo {
    font-size: 1.8rem;
}
.sidebar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}
.sidebar-menu {
    list-style: none;
    padding: 14px 12px 20px;
    overflow-y: auto;
    flex-grow: 1;
}
.grouped-sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.menu-group {
    list-style: none;
}
.menu-group details {
    border-radius: 10px;
    overflow: hidden;
}
.menu-group details[open] {
    background: rgba(255, 255, 255, 0.035);
}
.menu-group summary {
    min-height: 44px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 20px 1fr 14px;
    align-items: center;
    gap: 12px;
    color: var(--text-sidebar);
    cursor: pointer;
    opacity: 0.82;
    font-weight: 700;
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    user-select: none;
}
.menu-group summary::-webkit-details-marker {
    display: none;
}
.menu-group summary:hover {
    background: rgba(212, 163, 115, 0.10);
    color: var(--primary);
    opacity: 1;
}
.group-chevron {
    font-size: 0.72rem;
    transition: transform 0.2s ease;
}
.menu-group details[open] .group-chevron {
    transform: rotate(180deg);
}
.menu-group ul {
    list-style: none;
    padding: 4px 0 8px;
}
.menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 38px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    color: var(--text-sidebar);
    opacity: 0.75;
    border-radius: 8px;
}
.menu-item a:hover, .menu-item.active a {
    background-color: rgba(212, 163, 115, 0.12);
    color: var(--primary);
    opacity: 1;
    border-left: 3px solid var(--primary);
    padding-left: 35px;
}
.grouped-sidebar-menu > .menu-item > a {
    padding-left: 12px;
    font-weight: 700;
}
.grouped-sidebar-menu > .menu-item.active > a,
.grouped-sidebar-menu > .menu-item > a:hover {
    padding-left: 9px;
}

.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s;
}

/* --- Top Header Bar --- */
.topbar {
    height: 70px;
    background-color: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 99;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}
.toggle-sidebar-btn {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: none;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}
.profile-dropdown {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.profile-dropdown img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
}
.theme-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-main);
}

/* --- Content Wrapper --- */
.content-body {
    padding: 30px;
    flex-grow: 1;
    background:
        radial-gradient(circle at 12% 8%, rgba(212, 163, 115, 0.12), transparent 28%),
        radial-gradient(circle at 95% 18%, rgba(69, 123, 157, 0.10), transparent 24%),
        linear-gradient(180deg, rgba(255,255,255,0.28), transparent 260px);
}
.page-title-box {
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}
.page-title {
    font-size: 1.8rem;
    font-weight: 700;
}

/* --- Dashboard Stat Widgets --- */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 24px;
    margin-bottom: 35px;
}
.widget-card {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.widget-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}
.widget-value {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.2;
}
.widget-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 5px;
    letter-spacing: 0.05em;
}
.widget-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    background-color: rgba(212, 163, 115, 0.15);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* --- Analytics Charts Grid --- */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 35px;
}
@media (max-width: 992px) {
    .charts-grid { grid-template-columns: 1fr; }
}
.chart-card {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.chart-header {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

/* --- Form Fields & Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.btn-primary { background-color: var(--primary); color: #fff; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: transparent; border-color: var(--border-color); color: var(--text-main); }
.btn-secondary:hover { background-color: var(--bg-main); }
.btn-danger { background-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
.form-control:focus {
    border-color: var(--primary);
    background-color: var(--bg-card);
}

/* --- Table Styles --- */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}
.admin-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.admin-table th, .admin-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    font-size: 0.9rem;
}
.admin-table th {
    background-color: var(--bg-main);
    font-weight: 600;
    color: var(--text-muted);
}
.admin-table tbody tr:hover {
    background-color: rgba(212, 163, 115, 0.03);
}
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-success { background-color: rgba(46, 196, 182, 0.15); color: var(--success); }
.badge-warning { background-color: rgba(255, 159, 28, 0.15); color: var(--warning); }
.badge-danger { background-color: rgba(231, 29, 54, 0.15); color: var(--danger); }
.badge-info { background-color: rgba(69, 123, 157, 0.15); color: var(--info); }

/* --- Pagination & Filters --- */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}
.pagination {
    display: flex;
    gap: 5px;
    list-style: none;
}
.pagination-link {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}
.pagination-link.active, .pagination-link:hover {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* --- Drag & Drop file upload area --- */
.upload-drop-zone {
    border: 2px dashed var(--primary);
    padding: 40px;
    text-align: center;
    border-radius: 8px;
    background-color: rgba(212, 163, 115, 0.05);
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 20px;
}
.upload-drop-zone:hover {
    background-color: rgba(212, 163, 115, 0.1);
}

/* --- Action Dropdown --- */
.action-btn-group {
    display: flex;
    gap: 10px;
}

/* --- Login Form Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background-color: var(--bg-main);
}
.login-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}

.content-body > div[style*="background-color: var(--bg-card)"],
.content-body > section[style*="background-color: var(--bg-card)"] {
    box-shadow: var(--shadow-3d) !important;
}

/* --- Mobile Responsive Rules --- */
@media (max-width: 768px) {
    body.sidebar-open {
        overflow: hidden;
    }
    .toggle-sidebar-btn { display: block; }
    .sidebar {
        transform: translateX(-100%);
        width: min(86vw, 300px);
        z-index: 120;
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .topbar {
        height: auto;
        min-height: 64px;
        padding: 10px 14px;
        gap: 10px;
    }
    .topbar-left,
    .topbar-right {
        gap: 10px;
    }
    .topbar-left .btn {
        padding: 8px 10px !important;
        font-size: 0 !important;
        line-height: 0 !important;
        width: 42px !important;
        height: 42px !important;
        overflow: hidden;
        color: transparent !important;
        flex: 0 0 42px !important;
    }
    .topbar-left .btn i {
        font-size: 1.15rem !important;
        margin: 0;
        color: var(--text-main) !important;
    }
    .profile-dropdown > div {
        display: none;
    }
    .content-body { padding: 16px; }
    .page-title-box {
        align-items: stretch;
        margin-bottom: 20px;
    }
    .page-title {
        font-size: 1.35rem;
        line-height: 1.2;
    }
    .page-title-box p {
        font-size: 0.92rem !important;
        line-height: 1.45;
    }
    .page-title-box > div:last-child,
    .page-title-box > a,
    .page-title-box .btn {
        width: 100%;
    }
    .page-title-box > div:last-child {
        flex-wrap: wrap;
    }
    .page-title-box > div:last-child .btn {
        flex: 1 1 160px;
    }
    .widgets-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .widget-card,
    .chart-card {
        border-radius: 8px;
        padding: 18px;
    }
    .btn {
        min-height: 40px;
        padding: 10px 14px;
        white-space: normal;
        text-align: center;
    }
    .action-btn-group {
        flex-wrap: wrap;
    }
    .form-control {
        min-height: 42px;
        font-size: 16px;
    }
    .login-wrapper {
        align-items: flex-start;
        padding: 24px 14px;
    }
    .login-card {
        padding: 26px 18px;
        border-radius: 8px;
        max-width: none;
    }
    .login-card .btn {
        width: 100%;
    }
    form[style*="grid-template-columns"],
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    div[style*="grid-template-columns"] > * {
        min-width: 0;
    }
    div[style*="max-width: 800px"],
    div[style*="max-width: 600px"],
    div[style*="max-width: 500px"] {
        max-width: none !important;
        padding: 18px !important;
        border-radius: 10px !important;
    }
    .content-body h3 {
        font-size: 1.12rem !important;
    }
    form[style*="display: flex"] {
        flex-wrap: wrap;
    }
    form[style*="display: flex"] > * {
        flex: 1 1 100%;
    }
    .mapping-row {
        grid-template-columns: 1fr !important;
    }
    #subjects-checkbox-container {
        max-height: none !important;
    }
    .table-responsive {
        overflow: visible;
    }
    .admin-table {
        min-width: 0;
        border: none;
        background: transparent;
    }
    .admin-table,
    .admin-table thead,
    .admin-table tbody,
    .admin-table tr,
    .admin-table th,
    .admin-table td {
        display: block;
        width: 100%;
    }
    .admin-table thead {
        display: none;
    }
    .admin-table tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        box-shadow: var(--shadow-3d);
        margin-bottom: 14px;
        padding: 12px;
    }
    .admin-table td {
        border-bottom: 1px solid var(--border-color);
        padding: 10px 4px;
        display: grid;
        grid-template-columns: minmax(100px, 36%) 1fr;
        gap: 12px;
        text-align: left !important;
        align-items: center;
    }
    .admin-table td:last-child {
        border-bottom: none;
    }
    .admin-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    .admin-table td .action-btn-group {
        justify-content: flex-start !important;
    }
    .blog-editor-grid {
        grid-template-columns: 1fr !important;
    }
}
