/* ============================================================
   PE Smart School - Super Admin Panel
   Premium Dark Theme with Glassmorphism
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --bg-primary: #f0fdf4;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-glass-hover: rgba(255, 255, 255, 0.8);
    --border-glass: rgba(16, 185, 129, 0.2);
    --text-primary: #064e3b;
    --text-secondary: #065f46;
    --text-muted: #34d399;
    --accent-emerald: #10b981;
    --accent-emerald-dark: #059669;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-pink: #ec4899;
    --accent-cyan: #06b6d4;
    --gradient-primary: linear-gradient(135deg, #10b981, #059669);
    --gradient-secondary: linear-gradient(135deg, #3b82f6, #10b981);
    --gradient-success: linear-gradient(135deg, #10b981, #34d399);
    --gradient-warning: linear-gradient(135deg, #f59e0b, #ef4444);
    --shadow-glow: 0 0 30px rgba(16, 185, 129, 0.15);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.05);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.9);
    --bg-glass: rgba(30, 41, 59, 0.6);
    --bg-glass-hover: rgba(51, 65, 85, 0.8);
    --border-glass: rgba(16, 185, 129, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.2);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    direction: rtl;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-glow), var(--shadow-card);
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .icon {
    width: 64px;
    height: 64px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-logo p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Cairo', sans-serif;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-success {
    background: var(--accent-green);
    color: #fff;
}

.btn-success:hover {
    background: #0d9668;
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.btn-purple {
    background: var(--accent-emerald);
    color: #fff;
}

.btn-purple:hover {
    background: var(--accent-emerald-dark);
}

.btn-orange {
    background: var(--accent-orange);
    color: #000;
}

.btn-cyan {
    background: var(--accent-cyan);
    color: #fff;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.admin-app {
    display: none;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.admin-app.active {
    display: block;
}

/* TOP NAVBAR */
.top-nav {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.nav-brand h2 {
    font-size: 16px;
    font-weight: 700;
}

.nav-brand span {
    color: var(--accent-emerald);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-user .user-name {
    font-size: 13px;
    color: var(--text-secondary);
}

.nav-user .user-name strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* SIDEBAR + CONTENT */
.admin-body {
    display: flex;
    min-height: calc(100vh - 64px);
}

.sidebar {
    width: 240px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-glass);
    padding: 24px 16px;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: right;
    font-family: 'Cairo', sans-serif;
}

.sidebar-link:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-emerald);
    font-weight: 600;
}

.sidebar-link .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.main-content {
    flex: 1;
    padding: 32px;
    min-width: 0;
}

/* ============================================================
   DASHBOARD CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
}

.stat-card.purple::after {
    background: var(--gradient-primary);
}

.stat-card.green::after {
    background: var(--gradient-success);
}

.stat-card.orange::after {
    background: var(--gradient-warning);
}

.stat-card.pink::after {
    background: var(--gradient-secondary);
}

.stat-card.cyan .stat-value {
    background: var(--gradient-success);
    -webkit-background-clip: text;
    background-clip: text;
}

.stat-card.orange .stat-value {
    background: var(--gradient-warning);
    -webkit-background-clip: text;
    background-clip: text;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-body {
    padding: 24px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: rgba(139, 92, 246, 0.08);
    padding: 14px 16px;
    text-align: right;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: var(--bg-glass-hover);
}

/* ============================================================
   BADGES / TAGS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.badge-trial {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

.badge-suspended {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.badge-expired {
    background: rgba(96, 96, 128, 0.2);
    color: var(--text-muted);
}

.badge-inactive {
    background: rgba(96, 96, 128, 0.2);
    color: var(--text-muted);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-glow), var(--shadow-card);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-start;
    gap: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group-modal {
    margin-bottom: 20px;
}

.form-group-modal label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Cairo', sans-serif;
    outline: none;
    transition: var(--transition);
    appearance: none;
}

.form-select:focus {
    border-color: var(--accent-emerald);
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow-card);
}

.toast-success {
    background: var(--accent-green);
    color: #fff;
}

.toast-error {
    background: var(--accent-red);
    color: #fff;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ============================================================
   ACTION BUTTONS IN TABLE
   ============================================================ */
.action-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Cairo', sans-serif;
    white-space: nowrap;
}

.action-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.action-btn.edit:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.action-btn.sub:hover {
    color: var(--accent-orange);
    border-color: var(--accent-orange);
}

.action-btn.enter:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.action-btn.toggle-on:hover {
    color: var(--accent-green);
    border-color: var(--accent-green);
}

.action-btn.toggle-off:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

/* ============================================================
   LOADING
   ============================================================ */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--accent-emerald);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 24px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.mobile-only {
    display: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* Sidebar Overlay Backdrop */
.sidebar-overlay {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 899;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 64px;
        right: -260px;
        width: 260px;
        height: calc(100vh - 64px);
        overflow-y: auto;
        z-index: 900;
        transition: var(--transition);
    }

    .sidebar.open {
        right: 0;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
    }

    .mobile-only {
        display: inline-flex !important;
    }

    .nav-brand h2 span,
    .nav-user .user-name {
        display: none;
    }

    .top-nav {
        padding: 0 16px;
    }

    .main-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 24px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        max-width: 100%;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Hidden utility */
.hidden {
    display: none !important;
}