/*
Theme Name: WISWITS APEX School Academic System
Theme URI: https://wiswits.com/apex
Author: WISWITS Development Team
Author URI: https://wiswits.com
Description: A complete school academic management system with role-based dashboards for Admin, Teacher, and Student. Includes analytics, quiz system, worksheets, and performance tracking.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 8.0
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wiswits-apex
Tags: education, school, dashboard, academic, management
*/

/* ============================================================
   APEX THEME - GLOBAL RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f4f8;
    color: #1e293b;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: #1e3a8a; text-decoration: none; transition: color .2s; }
a:hover { color: #3b82f6; }
img { max-width: 100%; height: auto; }
ul { list-style: none; }
button, input, select, textarea { font-family: inherit; }

/* ============================================================
   LAYOUT
   ============================================================ */
.apex-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.apex-sidebar {
    width: 260px;
    min-height: 100vh;
    background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 60%, #1d4ed8 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    transition: width .3s ease;
    overflow-x: hidden;
}
.apex-sidebar.collapsed { width: 70px; }

.apex-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    min-height: 72px;
}
.apex-sidebar-brand img {
    width: 38px; height: 38px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255,255,255,.2);
}
.apex-brand-text h2 {
    font-size: 14px; font-weight: 700;
    line-height: 1.2; white-space: nowrap;
}
.apex-brand-text span {
    font-size: 11px; opacity: .7;
    white-space: nowrap;
}
.apex-sidebar.collapsed .apex-brand-text { display: none; }

.apex-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.apex-nav-section { padding: 8px 18px 4px; }
.apex-nav-section-label {
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1px;
    opacity: .5; white-space: nowrap;
}
.apex-sidebar.collapsed .apex-nav-section-label { display: none; }

.apex-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: rgba(255,255,255,.8);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    border-radius: 0;
    white-space: nowrap;
    position: relative;
    text-decoration: none;
}
.apex-nav-item:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.apex-nav-item.active {
    background: rgba(255,255,255,.18);
    color: #fff;
    border-left: 3px solid #60a5fa;
}
.apex-nav-item .nav-icon {
    font-size: 18px; flex-shrink: 0;
    width: 22px; text-align: center;
}
.apex-sidebar.collapsed .nav-label { display: none; }

.apex-sidebar-footer {
    padding: 16px 18px;
    border-top: 1px solid rgba(255,255,255,.15);
}
.apex-user-info {
    display: flex; align-items: center; gap: 10px;
}
.apex-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    flex-shrink: 0;
}
.apex-user-meta { overflow: hidden; }
.apex-user-meta strong {
    display: block; font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.apex-user-meta span { font-size: 11px; opacity: .6; }
.apex-sidebar.collapsed .apex-user-meta { display: none; }
.apex-logout-btn {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 10px; font-size: 12px;
    color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.1);
    border: none; border-radius: 6px;
    padding: 6px 12px; cursor: pointer;
    transition: all .2s; width: 100%;
    justify-content: center; text-decoration: none;
}
.apex-logout-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.apex-sidebar.collapsed .apex-logout-btn span { display: none; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.apex-main {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .3s ease;
}
.apex-main.expanded { margin-left: 70px; }

/* ============================================================
   TOP HEADER
   ============================================================ */
.apex-topbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 900;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.apex-topbar-left { display: flex; align-items: center; gap: 16px; }
.apex-toggle-btn {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: #64748b; padding: 6px;
    border-radius: 6px; transition: all .2s;
}
.apex-toggle-btn:hover { background: #f1f5f9; color: #1e3a8a; }
.apex-page-title { font-size: 18px; font-weight: 600; color: #1e293b; }
.apex-topbar-right { display: flex; align-items: center; gap: 12px; }
.apex-school-name { font-size: 13px; color: #64748b; font-weight: 500; }
.apex-date-display { font-size: 12px; color: #94a3b8; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.apex-content { padding: 28px 24px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.apex-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    overflow: hidden;
}
.apex-card-header {
    padding: 18px 22px;
    border-bottom: 1px solid #f1f5f9;
    display: flex; align-items: center; justify-content: space-between;
}
.apex-card-title {
    font-size: 15px; font-weight: 600; color: #1e293b;
    display: flex; align-items: center; gap: 8px;
}
.apex-card-body { padding: 22px; }

/* ============================================================
   STAT CARDS (KPI)
   ============================================================ */
.apex-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.apex-stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px 22px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    display: flex; align-items: flex-start; gap: 14px;
}
.apex-stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.apex-stat-icon.blue { background: #dbeafe; }
.apex-stat-icon.green { background: #dcfce7; }
.apex-stat-icon.amber { background: #fef3c7; }
.apex-stat-icon.red { background: #fee2e2; }
.apex-stat-icon.purple { background: #f3e8ff; }
.apex-stat-value { font-size: 26px; font-weight: 700; color: #1e293b; }
.apex-stat-label { font-size: 12px; color: #64748b; margin-top: 2px; }
.apex-stat-change { font-size: 12px; margin-top: 4px; }
.apex-stat-change.up { color: #16a34a; }
.apex-stat-change.down { color: #dc2626; }

/* ============================================================
   TABLES
   ============================================================ */
.apex-table-wrap { overflow-x: auto; }
.apex-table {
    width: 100%; border-collapse: collapse;
    font-size: 13.5px;
}
.apex-table th {
    background: #f8fafc;
    padding: 11px 16px;
    text-align: left; font-weight: 600;
    color: #475569; font-size: 12px;
    text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.apex-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #374151; vertical-align: middle;
}
.apex-table tbody tr:hover { background: #f8fafc; }
.apex-table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   FORMS
   ============================================================ */
.apex-form-group { margin-bottom: 18px; }
.apex-form-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: #374151; margin-bottom: 6px;
}
.apex-form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px; color: #1e293b;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}
.apex-form-control:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.apex-form-control:invalid { border-color: #ef4444; }
textarea.apex-form-control { resize: vertical; min-height: 100px; }
select.apex-form-control { cursor: pointer; }

/* ============================================================
   BUTTONS
   ============================================================ */
.apex-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 18px; border-radius: 8px;
    font-size: 13.5px; font-weight: 600;
    cursor: pointer; border: none; transition: all .2s;
    white-space: nowrap;
    text-decoration: none;
}
.apex-btn-primary { background: #1e3a8a; color: #fff; }
.apex-btn-primary:hover { background: #1e40af; color: #fff; }
.apex-btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.apex-btn-secondary:hover { background: #e2e8f0; }
.apex-btn-success { background: #16a34a; color: #fff; }
.apex-btn-success:hover { background: #15803d; color: #fff; }
.apex-btn-danger { background: #dc2626; color: #fff; }
.apex-btn-danger:hover { background: #b91c1c; color: #fff; }
.apex-btn-sm { padding: 5px 12px; font-size: 12px; }
.apex-btn-lg { padding: 12px 24px; font-size: 15px; }
.apex-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   BADGES
   ============================================================ */
.apex-badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.apex-badge-blue { background: #dbeafe; color: #1e3a8a; }
.apex-badge-green { background: #dcfce7; color: #15803d; }
.apex-badge-amber { background: #fef3c7; color: #92400e; }
.apex-badge-red { background: #fee2e2; color: #b91c1c; }
.apex-badge-purple { background: #f3e8ff; color: #7e22ce; }
.apex-badge-gray { background: #f1f5f9; color: #475569; }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.apex-progress-bar {
    background: #e2e8f0; border-radius: 99px;
    height: 8px; overflow: hidden;
}
.apex-progress-fill {
    height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, #1e3a8a, #3b82f6);
    transition: width .6s ease;
}
.apex-progress-fill.green { background: linear-gradient(90deg, #16a34a, #22c55e); }
.apex-progress-fill.amber { background: linear-gradient(90deg, #d97706, #f59e0b); }
.apex-progress-fill.red { background: linear-gradient(90deg, #dc2626, #ef4444); }

/* ============================================================
   ALERTS & NOTICES
   ============================================================ */
.apex-alert {
    padding: 12px 16px; border-radius: 8px;
    font-size: 13.5px; margin-bottom: 16px;
    display: flex; align-items: flex-start; gap: 10px;
}
.apex-alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.apex-alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.apex-alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.apex-alert-info { background: #dbeafe; color: #1e3a8a; border: 1px solid #bfdbfe; }

/* ============================================================
   TABS
   ============================================================ */
.apex-tabs { border-bottom: 2px solid #e2e8f0; display: flex; gap: 0; margin-bottom: 24px; }
.apex-tab-btn {
    padding: 10px 20px; font-size: 14px; font-weight: 500;
    color: #64748b; background: none; border: none;
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all .2s;
}
.apex-tab-btn:hover { color: #1e3a8a; }
.apex-tab-btn.active { color: #1e3a8a; border-bottom-color: #1e3a8a; font-weight: 600; }
.apex-tab-content { display: none; }
.apex-tab-content.active { display: block; }

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.apex-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.apex-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.apex-grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-8  { margin-bottom: 8px; }

/* ============================================================
   CHART CONTAINERS
   ============================================================ */
.apex-chart-container {
    position: relative;
    padding: 16px;
}
.apex-chart-container canvas { max-width: 100% !important; }

/* ============================================================
   QUIZ STYLES
   ============================================================ */
.apex-quiz-question {
    background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 10px; padding: 18px; margin-bottom: 16px;
}
.apex-quiz-question h4 { font-size: 15px; color: #1e293b; margin-bottom: 12px; }
.apex-quiz-option {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 8px;
    border: 2px solid #e2e8f0; margin-bottom: 8px;
    cursor: pointer; transition: all .2s; font-size: 14px;
}
.apex-quiz-option:hover { border-color: #3b82f6; background: #eff6ff; }
.apex-quiz-option.selected { border-color: #1e3a8a; background: #eff6ff; }
.apex-quiz-option.correct { border-color: #16a34a; background: #dcfce7; }
.apex-quiz-option.incorrect { border-color: #dc2626; background: #fee2e2; }

/* ============================================================
   TODO LIST
   ============================================================ */
.apex-todo-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid #f1f5f9;
}
.apex-todo-item:last-child { border-bottom: none; }
.apex-todo-check {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid #94a3b8; flex-shrink: 0;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all .2s;
}
.apex-todo-check.done { background: #16a34a; border-color: #16a34a; }
.apex-todo-text { flex: 1; font-size: 14px; }
.apex-todo-text.done { text-decoration: line-through; color: #94a3b8; }
.apex-todo-priority {
    font-size: 11px; padding: 2px 8px; border-radius: 4px;
}

/* ============================================================
   MODAL
   ============================================================ */
.apex-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 9000;
    display: none; align-items: center; justify-content: center;
    padding: 20px;
}
.apex-modal-overlay.open { display: flex; }
.apex-modal {
    background: #fff; border-radius: 14px;
    width: 100%; max-width: 600px; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.apex-modal-header {
    padding: 20px 24px; border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; background: #fff; z-index: 1;
}
.apex-modal-header h3 { font-size: 16px; font-weight: 700; }
.apex-modal-close {
    background: none; border: none; font-size: 22px;
    cursor: pointer; color: #64748b; line-height: 1;
    padding: 4px;
}
.apex-modal-close:hover { color: #dc2626; }
.apex-modal-body { padding: 24px; }
.apex-modal-footer {
    padding: 16px 24px; border-top: 1px solid #e2e8f0;
    display: flex; justify-content: flex-end; gap: 10px;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.apex-spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid #e2e8f0;
    border-top-color: #1e3a8a;
    border-radius: 50%;
    animation: apex-spin .7s linear infinite;
}
@keyframes apex-spin { to { transform: rotate(360deg); } }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.apex-login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #2563eb 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.apex-login-box {
    background: #fff; border-radius: 16px;
    padding: 40px; width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.apex-login-logo {
    text-align: center; margin-bottom: 32px;
}
.apex-login-logo img { width: 64px; height: 64px; border-radius: 12px; margin-bottom: 12px; }
.apex-login-logo h1 { font-size: 20px; font-weight: 700; color: #1e3a8a; }
.apex-login-logo p { font-size: 13px; color: #64748b; margin-top: 4px; }

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .apex-sidebar, .apex-topbar, .apex-btn, .no-print { display: none !important; }
    .apex-main { margin-left: 0 !important; }
    .apex-content { padding: 0 !important; }
    .apex-card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
    body { background: #fff !important; font-size: 12px; }
    .apex-stat-card { break-inside: avoid; }
    canvas { max-width: 400px !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .apex-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .apex-sidebar { width: 70px; }
    .apex-sidebar .apex-brand-text,
    .apex-sidebar .nav-label,
    .apex-sidebar .apex-nav-section-label,
    .apex-sidebar .apex-user-meta,
    .apex-sidebar .apex-logout-btn span { display: none; }
    .apex-main { margin-left: 70px; }
    .apex-grid-2 { grid-template-columns: 1fr; }
    .apex-grid-3 { grid-template-columns: 1fr; }
    .apex-stats-grid { grid-template-columns: 1fr 1fr; }
    .apex-content { padding: 16px; }
}
@media (max-width: 480px) {
    .apex-stats-grid { grid-template-columns: 1fr; }
    .apex-login-box { padding: 28px 20px; }
}
