/* ========================================
   مساعد نور الحديث - التصميم الأساسي
   ======================================== */

:root {
    --primary: #1a8a5c;
    --primary-dark: #14694a;
    --primary-light: #22b876;
    --primary-glow: rgba(26, 138, 92, 0.08);
    --accent: #f0b429;
    --accent-light: #ffd666;

    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #f1f5f9;
    --bg-hover: #e2e8f0;
    --bg-table-row: #ffffff;
    --bg-table-alt: #f8fafc;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-white: #ffffff;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --transition: all 0.25s ease;

    --sidebar-width: 260px;
}

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

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

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-sub {
    font-size: 0.75rem;
    color: var(--primary-light);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary-light);
    border: 1px solid rgba(26, 138, 92, 0.3);
}

.nav-icon { font-size: 1.2rem; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.school-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

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

.stat-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.stat-students .stat-icon { background: rgba(26, 138, 92, 0.15); }
.stat-grades .stat-icon { background: rgba(59, 130, 246, 0.15); }
.stat-sections .stat-icon { background: rgba(245, 158, 11, 0.15); }
.stat-groups .stat-icon { background: rgba(168, 85, 247, 0.15); }

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    display: block;
    line-height: 1;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.distribution-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dist-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.dist-bar-container {
    flex: 1;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.dist-bar {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.6s ease;
}

.dist-name { min-width: 140px; font-size: 0.9rem; color: var(--text-secondary); }
.dist-count { min-width: 30px; text-align: center; font-weight: 600; font-size: 0.85rem; color: var(--primary-light); }

/* ===== Quick Actions ===== */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.quick-btn {
    padding: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.quick-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

/* ===== Import Zone ===== */
.import-card { max-width: 700px; margin: 0 auto; }

.import-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.import-zone:hover, .import-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.import-icon { font-size: 4rem; margin-bottom: 1rem; }
.import-zone h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-primary); }
.import-zone p { color: var(--text-muted); margin-bottom: 1.5rem; }

.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.import-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.import-stat {
    background: var(--bg-input);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.import-stat strong { color: var(--primary-light); }

.import-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-input, .filter-select {
    padding: 0.6rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.filter-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-input { flex: 1; min-width: 200px; }
.filter-select { min-width: 150px; }

.results-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-right: auto;
}

/* ===== Tables ===== */
.table-container { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.data-table thead th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.85rem 1rem;
    text-align: right;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:nth-child(even) {
    background: var(--bg-table-alt);
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem;
    border-radius: 4px;
    transition: var(--transition);
}

.action-btn:hover { background: var(--bg-input); }

/* ===== Reports Grid ===== */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.report-category {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.report-category h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-light);
}

.report-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.report-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: right;
    transition: var(--transition);
}

.report-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary-light);
}

.custom-report-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.custom-report-item .report-btn {
    flex: 1;
}

.btn-delete-custom {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--danger);
    padding: 0.75rem 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    line-height: 1;
}

.btn-delete-custom:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

.btn-create-custom {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary-light);
    font-weight: bold;
    text-align: center;
}

.btn-create-custom:hover {
    background: var(--primary);
    color: var(--text-white);
}

.col-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 48px;
    align-items: center;
}

.col-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.col-chip-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.9rem;
    line-height: 1;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.col-chip-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* ===== Forms Grid ===== */
.forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    font-family: inherit;
    color: var(--text-primary);
}

.form-card:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.form-icon { font-size: 2.5rem; }
.form-card h4 { font-size: 0.95rem; font-weight: 600; }

/* ===== Modals ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-wide { max-width: 650px; }

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

.modal-header h3 { font-size: 1.1rem; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

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

.modal-body { padding: 1.5rem; }

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group .filter-input,
.form-group .filter-select {
    width: 100%;
}

/* ===== Student Suggestions ===== */
.student-suggestions {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.suggestion-item {
    padding: 0.65rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.suggestion-item:hover { background: var(--primary-glow); }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-name { font-weight: 600; color: var(--text-white); }
.suggestion-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.student-info-card {
    background: var(--bg-input);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
}

/* ===== Groups ===== */
.groups-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.group-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.group-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.group-card-header h4 { font-weight: 600; color: var(--text-white); }

.group-actions { display: flex; gap: 0.5rem; }

.group-members-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* ===== Settings ===== */
.settings-card { max-width: 600px; }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-icon { font-size: 4rem; display: block; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-secondary); }
.empty-state p { margin-bottom: 1.5rem; }

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--primary);
    color: var(--text-primary);
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 2000;
    box-shadow: var(--shadow);
    transition: transform 0.35s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

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

/* ===== Print Styles ===== */
.print-only { display: none; }

@media print {
    body { background: white; }
    .sidebar, .sidebar-toggle, .toast, .main-content { display: none !important; }
    .print-only {
        display: block !important;
        direction: rtl;
        font-family: 'Tajawal', 'Traditional Arabic', sans-serif;
        color: #000;
        padding: 10mm;
    }
    .print-only h2 { text-align: center; font-size: 16pt; margin-bottom: 5mm; }
    .print-only h3 { text-align: center; font-size: 12pt; margin-bottom: 3mm; color: #333; }
    .print-only table { width: 100% !important; border-collapse: collapse; font-size: 9.5pt; table-layout: fixed; margin-top: 3mm; }
    .print-only table th,
    .print-only table td {
        border: 1px solid #000;
        padding: 3px 4px;
        text-align: center;
        word-wrap: break-word;
    }
    .print-only table th { background: #f0f0f0; font-weight: bold; }
    .print-only table td:nth-child(2) { text-align: right; padding-right: 6px; }
    .official-print-header {
        display: grid;
        grid-template-columns: 30% 40% 30%;
        align-items: start;
        border-bottom: 2px solid #000;
        padding-bottom: 5mm;
        margin-bottom: 6mm;
        font-size: 10pt;
        width: 100%;
    }
    .header-col { min-width: 0; }
    .header-right { text-align: right; }
    .header-center { text-align: center; }
    .header-left { text-align: left; font-size: 9pt; }
    .bismillah { font-size: 11pt; font-weight: bold; margin-bottom: 3mm; font-family: 'Traditional Arabic', serif; }
    .print-title { font-size: 13pt; font-weight: bold; margin-top: 2mm; text-align: center; }
    .print-school { font-size: 11pt; font-weight: bold; margin-top: 2mm; }

    .print-signatures {
        margin-top: 10mm;
        display: flex;
        justify-content: space-between;
        font-size: 10pt;
        font-weight: bold;
        text-align: center;
    }
    .print-footer { margin-top: 6mm; font-size: 9pt; color: #333; text-align: right; }
    .signature-line { display: inline-block; width: 140px; border-bottom: 1px solid #333; margin-top: 8mm; }

    .page-break {
        page-break-after: always;
        break-after: page;
        height: 0;
        margin: 0;
        padding: 0;
    }

    @page { size: A4; margin: 10mm; }
}

.multi-select-box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    max-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.multi-select-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.multi-select-item:hover {
    background: var(--bg-hover);
}

.multi-select-item input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .main-content { margin-right: 0; padding: 1rem; padding-top: 4rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .quick-actions { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .reports-grid { grid-template-columns: 1fr; }
    .forms-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .filters-bar { flex-direction: column; }
    .filter-input { min-width: 100%; }
}
