/* ============================================
   Dashboard — Modern Admin Panel
   ============================================ */
:root {
    --sidebar-w: 280px;
    --header-h: 64px;
    --gold: #FFD700;
    --gold-dark: #d97706;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg: #f3f4f6;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-light: #6b7280;
}

.admin-layout { min-height: 100vh; background: var(--bg); display: flex; position: relative; }

/* SIDEBAR */
.admin-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    position: fixed;
    top: 0; bottom: 0; right: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
    box-shadow: -2px 0 15px rgba(0,0,0,0.1);
}
[dir="ltr"] .admin-sidebar { right: auto; left: 0; box-shadow: 2px 0 15px rgba(0,0,0,0.1); }

.sidebar-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    flex-shrink: 0;
}
.sidebar-logo {
    width: 42px; height: 42px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-logo i { font-size: 1.15rem; color: white; }
.sidebar-brand { flex: 1; min-width: 0; }
.brand-title { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; opacity: 0.9; }
.sidebar-close {
    background: rgba(255,255,255,0.1);
    border: none; color: white;
    width: 32px; height: 32px;
    border-radius: 8px; cursor: pointer;
    display: none; font-family: inherit;
    align-items: center; justify-content: center;
}

.sidebar-user {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.user-avatar {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 16px; color: white;
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: #a5b4fc; font-weight: 700; }

/* SEARCH BOX */
.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.search-wrapper { position: relative; }
.search-icon {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 13px;
    pointer-events: none;
}
[dir="ltr"] .search-icon { right: auto; left: 12px; }
.search-input {
    width: 100%;
    padding: 9px 36px 9px 36px;
    background: rgba(255,255,255,0.06);
    border: 1.5px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-family: inherit;
    transition: all .2s;
    outline: none;
}
.search-input::placeholder { color: #64748b; }
.search-input:focus {
    background: rgba(255,255,255,0.1);
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}
.search-clear {
    position: absolute;
    left: 8px; top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: none; color: white;
    width: 22px; height: 22px;
    border-radius: 6px; cursor: pointer;
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: inherit;
}
[dir="ltr"] .search-clear { left: auto; right: 8px; }
.search-clear:hover { background: rgba(239,68,68,0.5); }
.search-hint {
    margin-top: 6px;
    font-size: 11px;
    color: #a5b4fc;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 4px;
}
.search-empty { color: #94a3b8; }

/* NAV */
.sidebar-nav {
    padding: 12px 10px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.menu-item-wrap { margin-bottom: 2px; }
.menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    color: #cbd5e1; text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    transition: all .15s; cursor: pointer;
    border: none; background: transparent;
    width: 100%; text-align: inherit;
    font-family: inherit;
}
.menu-item:hover { background: rgba(255,255,255,0.06); color: white; }
.menu-item.active {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.menu-item.menu-open { background: rgba(255,255,255,0.05); color: white; }
.menu-item i:first-child { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.menu-item .arrow { margin-right: auto; font-size: 10px; transition: transform .2s; }
[dir="ltr"] .menu-item .arrow { margin-right: 0; margin-left: auto; }
.menu-item .arrow.rotate { transform: rotate(180deg); }

.submenu {
    margin-right: 12px; margin-top: 4px;
    padding-right: 12px;
    border-right: 2px solid rgba(99,102,241,0.25);
}
[dir="ltr"] .submenu {
    margin-right: 0; margin-left: 12px;
    padding-right: 0; padding-left: 12px;
    border-right: none; border-left: 2px solid rgba(99,102,241,0.25);
}
.submenu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 8px;
    color: #94a3b8; text-decoration: none;
    font-size: 12.5px; transition: all .15s;
    margin-bottom: 2px;
}
.submenu-item:hover { background: rgba(51,65,85,0.5); color: #e2e8f0; }
.submenu-item.active { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.submenu-item i { font-size: 9px; width: 14px; text-align: center; }

.menu-empty {
    text-align: center;
    padding: 30px 10px;
    color: #64748b;
    font-size: 12px;
}
.menu-empty i { display: block; font-size: 24px; margin-bottom: 8px; opacity: .5; }

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.menu-item-danger { color: #fca5a5; }
.menu-item-danger:hover { background: rgba(239,68,68,0.15); color: #f87171; }

/* MAIN */
.admin-main {
    flex: 1;
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex; flex-direction: column;
}
[dir="ltr"] .admin-main { margin-right: 0; margin-left: var(--sidebar-w); }

.admin-topbar {
    background: white; height: var(--header-h);
    padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.btn-menu {
    background: transparent; border: none;
    color: var(--text); padding: 8px 12px;
    border-radius: 8px; cursor: pointer;
    font-size: 18px; display: none; font-family: inherit;
}
.btn-menu:hover { background: var(--bg); }
.page-title { font-size: 20px; font-weight: 900; color: var(--text); margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.lang-selector-top {
    display: flex; gap: 2px;
    background: var(--bg); border-radius: 8px; padding: 3px;
}
.lang-selector-top a {
    padding: 5px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 700;
    color: var(--text-light); text-decoration: none;
    transition: all .2s;
}
.lang-selector-top a:hover { background: white; color: var(--gold-dark); }
.lang-selector-top a.active { background: var(--gold); color: white; }

.role-badge { padding: 5px 12px; border-radius: 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.role-super_admin { background: rgba(251,191,36,0.15); color: #d97706; }
.role-institute_admin { background: rgba(239,68,68,0.1); color: #ef4444; }
.role-institute_manager { background: rgba(249,115,22,0.1); color: #f97316; }
.role-teacher { background: rgba(16,185,129,0.1); color: #10b981; }
.role-student { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.role-parent { background: rgba(236,72,153,0.1); color: #ec4899; }
.role-accountant { background: rgba(14,165,233,0.1); color: #0ea5e9; }

.admin-content { padding: 24px; flex: 1; }

.welcome-card {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 20px; padding: 28px;
    color: white;
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
    box-shadow: 0 10px 25px rgba(99,102,241,0.25);
}
.welcome-content h2 { font-size: 24px; font-weight: 900; margin-bottom: 6px; }
.welcome-content p { font-size: 14px; opacity: 0.9; }
.welcome-icon {
    width: 64px; height: 64px;
    background: rgba(255,255,255,0.2);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.welcome-icon i { font-size: 28px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: white; border-radius: 16px; padding: 20px;
    display: flex; align-items: center; gap: 16px;
    border: 1px solid var(--border);
    transition: all .2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); border-color: #a5b4fc; }
.stat-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 20px;
}
.stat-icon.blue { background: rgba(99,102,241,0.1); color: #6366f1; }
.stat-icon.green { background: rgba(16,185,129,0.1); color: #10b981; }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.stat-icon.orange { background: rgba(245,158,11,0.1); color: #f59e0b; }
.stat-value { font-size: 26px; font-weight: 900; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.info-card { background: white; border-radius: 16px; padding: 24px; border: 1px solid var(--border); }
.info-card h3 { font-size: 16px; font-weight: 900; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.info-card h3 i { color: var(--primary); }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.info-line { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--bg); border-radius: 10px; font-size: 13px; }
.info-line span:first-child { color: var(--text-light); }
.info-line b { color: var(--text); font-weight: 700; }

.placeholder-page {
    text-align: center; padding: 80px 20px;
    color: var(--text-light); background: white;
    border-radius: 16px; border: 2px dashed var(--border);
}
.placeholder-page i { font-size: 48px; color: var(--primary); opacity: 0.3; margin-bottom: 16px; display: block; }
.placeholder-page h2 { font-size: 22px; font-weight: 900; color: var(--text); margin-bottom: 8px; }

.mobile-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; display: none; }

/* RESPONSIVE */
@media (max-width: 1024px) {
    .admin-sidebar { transform: translateX(100%); }
    [dir="ltr"] .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-right: 0 !important; margin-left: 0 !important; }
    .btn-menu { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
    .admin-content { padding: 16px; }
    .welcome-card { padding: 20px; flex-direction: column; text-align: center; gap: 16px; }
    .welcome-content h2 { font-size: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .info-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 16px; }
    .lang-selector-top { display: none; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Page Builder / Section Editor
   ============================================ */
.tenant-builder {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.builder-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.builder-toolbar h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    color: var(--text);
}
.builder-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.builder-btn {
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    padding: 9px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    transition: .2s;
}
.builder-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.builder-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.builder-btn.primary:hover {
    background: var(--primary-dark);
}
.builder-sections {
    display: grid;
    gap: 12px;
}
.builder-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow .2s, border-color .2s;
}
.builder-section:hover {
    border-color: #c7d2fe;
    box-shadow: 0 5px 16px rgba(0,0,0,.05);
}
.builder-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.builder-drag {
    color: #94a3b8;
    cursor: grab;
    font-size: 16px;
}
.builder-section-info {
    flex: 1;
    min-width: 0;
}
.builder-section-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
}
.builder-section-meta {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 3px;
}
.builder-section-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}
.builder-icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-light);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: .2s;
}
.builder-icon-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}
.builder-icon-btn.danger:hover {
    color: #ef4444;
    border-color: #ef4444;
}
.builder-section-body {
    padding: 18px;
}
.builder-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.builder-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.builder-field.full {
    grid-column: 1 / -1;
}
.builder-field label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text);
}
.builder-field input,
.builder-field textarea,
.builder-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: .2s;
}
.builder-field input:focus,
.builder-field textarea:focus,
.builder-field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.builder-field textarea {
    resize: vertical;
    min-height: 100px;
}
.builder-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
}
.builder-status.active {
    background: #dcfce7;
    color: #15803d;
}
.builder-status.inactive {
    background: #fee2e2;
    color: #b91c1c;
}
.builder-empty {
    padding: 45px 20px;
    text-align: center;
    color: var(--text-light);
    border: 2px dashed var(--border);
    border-radius: 14px;
}
.builder-empty i {
    display: block;
    font-size: 34px;
    margin-bottom: 12px;
    opacity: .4;
}
.builder-notice {
    padding: 12px 14px;
    border-radius: 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 12px;
    line-height: 1.9;
}
@media (max-width: 640px) {
    .builder-fields {
        grid-template-columns: 1fr;
    }
    .builder-field.full {
        grid-column: auto;
    }
    .builder-section-header {
        align-items: flex-start;
    }
    .builder-section-actions {
        flex-wrap: wrap;
    }
    .builder-toolbar {
        align-items: stretch;
        flex-direction: column;
    }
}

.menu-error{margin:10px 14px;padding:10px 12px;border-radius:10px;background:#3b1010;color:#fecaca;font-size:12px;line-height:1.7}
