/**
 * مدرستي تُفكّر - الأنماط الرئيسية
 * التصميم: RTL، ألوان وزارة التعليم
 */

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

:root {
    --bg-primary: #F2F6F3;          /* رمادي مخضرّ فاتح */
    --bg-secondary: #FFFFFF;
    --ink: #2E3B32;                 /* نص داكن */
    --accent-green: #2E7D32;        /* أخضر */
    --accent-purple: #C7B8EA;       /* موف ناعم */
    --sand: #E9DFD1;                /* بيج */
    --success: #2E7D32;
    --warning: #FDD835;
    --danger: #C62828;
    --info: #1976D2;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.12);
    
    --radius: 8px;
    --radius-lg: 12px;
}

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

html {
    direction: rtl;
    font-size: 16px;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg-primary);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--ink);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

a {
    color: var(--accent-green);
    text-decoration: none;
    transition: all 0.3s ease;
}

a:hover {
    color: #1B5E20;
    text-decoration: underline;
}

/* Header */
.header {
    background: white;
    box-shadow: var(--shadow-sm);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow: visible;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: visible;
}

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

.logo {
    width: 60px;
    height: auto;
}

.site-title {
    display: flex;
    flex-direction: column;
}

.site-title h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--accent-green);
}

.site-title .subtitle {
    font-size: 0.9rem;
    color: #666;
    margin-top: -0.25rem;
}

.nav-menu {
    display: flex;
    gap: 2rem;
    list-style: none;
    position: relative;
    z-index: 1001;
}

.nav-menu > li {
    position: relative;
    z-index: 1001;
}

.nav-menu a {
    color: var(--ink);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.3s;
    display: block;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: var(--accent-green);
    color: white;
    text-decoration: none;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    z-index: 1002;
}

.dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.dropdown-toggle::after {
    content: " ▼";
    font-size: 0.7em;
    margin-right: 0.3rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    min-width: 220px;
    max-width: 300px;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius);
    padding: 0.5rem 0;
    list-style: none;
    margin-top: 0.5rem;
    z-index: 9999;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 120px);
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

/* تخصيص scrollbar للقائمة المنسدلة */
.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.dropdown.open .dropdown-menu {
    display: block;
}

/* تعديل موضع القائمة إذا كانت قريبة من أسفل الصفحة */
.dropdown.open .dropdown-menu {
    /* سيتم تعديل الموضع ديناميكياً عبر JavaScript */
}

.dropdown-menu li {
    margin: 0;
}

.dropdown-menu a {
    padding: 0.75rem 1.25rem;
    color: var(--ink);
    display: block;
    transition: all 0.2s;
    border-radius: 0;
}

.dropdown-menu a:hover {
    background: #f5f5f5;
    color: var(--accent-green);
    padding-right: 1.5rem;
}

.dropdown-menu .divider {
    height: 1px;
    background: #e0e0e0;
    margin: 0.5rem 0;
}

/* User Menu */
.user-menu .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-menu .dropdown-menu {
    left: 0;
    right: auto;
}

/* Container */
.container {
    max-width: 100%;
    margin: 2rem auto;
    padding: 0 2rem;
    flex: 1;
}

.container-fluid {
    width: 100%;
    padding: 0 2rem;
    position: relative;
    overflow: visible;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: transform 0.3s, box-shadow 0.3s;
}

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

.card-header {
    border-bottom: 2px solid var(--bg-primary);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.card-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.card-body {
    padding: 0;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: linear-gradient(135deg, var(--accent-green) 0%, #1B5E20 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.kpi-card.purple {
    background: linear-gradient(135deg, var(--accent-purple) 0%, #9575CD 100%);
}

.kpi-card.sand {
    background: linear-gradient(135deg, var(--sand) 0%, #D7CCC8 100%);
    color: var(--ink);
}

.kpi-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 3rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.kpi-meta {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--ink);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #E0E0E0;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    padding-left: 2.5rem;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-green);
    color: white;
}

.btn-primary:hover {
    background: #1B5E20;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--accent-purple);
    color: white;
}

.btn-secondary:hover {
    background: #9575CD;
}

.btn-outline {
    background: transparent;
    color: var(--accent-green);
    border: 2px solid var(--accent-green);
}

.btn-outline:hover {
    background: var(--accent-green);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.table th,
.table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid #E0E0E0;
}

.table th {
    background: var(--bg-primary);
    font-weight: 600;
    color: var(--ink);
}

.table tbody tr:hover {
    background: #F5F5F5;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-success { background: var(--success); color: white; }
.badge-warning { background: var(--warning); color: var(--ink); }
.badge-danger { background: var(--danger); color: white; }
.badge-info { background: var(--info); color: white; }
.badge-secondary { background: #757575; color: white; }

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    border-right: 4px solid;
}

.alert-success {
    background: #E8F5E9;
    border-color: var(--success);
    color: #1B5E20;
}

.alert-error {
    background: #FFEBEE;
    border-color: var(--danger);
    color: #B71C1C;
}

.alert-warning {
    background: #FFF9C4;
    border-color: var(--warning);
    color: #F57F17;
}

.alert-info {
    background: #E3F2FD;
    border-color: var(--info);
    color: #0D47A1;
}

/* Footer */
.footer {
    background: white;
    border-top: 3px solid var(--accent-green);
    padding: 2rem;
    margin-top: auto;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-info {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.footer-info div {
    font-size: 0.95rem;
}

.footer-version {
    color: #757575;
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* Print Button */
.print-btn {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: var(--accent-green);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.5rem;
    z-index: 999;
}

.print-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
}

/* Loading Spinner */
.spinner {
    border: 4px solid rgba(0,0,0,0.1);
    border-right-color: var(--accent-green);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

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

/* Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: #757575; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Mobile Drawer Navigation */
.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-backdrop.show {
    opacity: 1;
}

.mobile-drawer {
    display: none;
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    background: white;
    z-index: 9999;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-drawer.show {
    transform: translateX(0);
}

.drawer-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    flex-shrink: 0;
}

.drawer-logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.drawer-logo-area .logo {
    width: 40px;
    height: auto;
    flex-shrink: 0;
}

.drawer-title {
    color: var(--accent-green);
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drawer-close-btn {
    background: transparent;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #666;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.drawer-close-btn:hover {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: white;
    transform: rotate(90deg);
}

.drawer-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

.drawer-nav::-webkit-scrollbar {
    width: 6px;
}

.drawer-nav::-webkit-scrollbar-track {
    background: #f7fafc;
}

.drawer-nav::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.drawer-nav::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.drawer-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.drawer-menu > li {
    margin: 0;
}

.drawer-menu > li > a {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.5rem;
    color: var(--ink);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 0;
    position: relative;
}

.drawer-menu > li > a:hover,
.drawer-menu > li > a.active {
    background: linear-gradient(90deg, var(--accent-green) 0%, #1B5E20 100%);
    color: white;
    padding-right: 1.75rem;
}

.drawer-menu > li > a.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: white;
    border-radius: 0 4px 4px 0;
}

/* Dropdown في Drawer */
.drawer-menu .dropdown {
    position: relative;
}

.drawer-menu .dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.drawer-menu .dropdown-toggle::after {
    content: "▼";
    font-size: 0.7em;
    transition: transform 0.3s ease;
    margin-right: 0;
}

.drawer-menu .dropdown.open .dropdown-toggle::after {
    transform: rotate(180deg);
}

.drawer-menu .dropdown-menu {
    display: none;
    position: static;
    top: auto;
    right: auto;
    background: #f8f9fa;
    box-shadow: none;
    border-radius: 0;
    padding: 0.25rem 0;
    margin: 0;
    max-height: none;
    overflow: visible;
    z-index: auto;
    border-top: 1px solid #e9ecef;
    border-bottom: 1px solid #e9ecef;
}

.drawer-menu .dropdown.open .dropdown-menu {
    display: block;
}

.drawer-menu .dropdown-menu li {
    margin: 0;
}

.drawer-menu .dropdown-menu a {
    padding: 0.75rem 1.5rem 0.75rem 2.5rem;
    color: #555;
    font-size: 0.95rem;
    border-radius: 0;
}

.drawer-menu .dropdown-menu a:hover {
    background: #e9ecef;
    color: var(--accent-green);
    padding-right: 2.75rem;
}

.drawer-menu .dropdown-menu .divider {
    height: 1px;
    background: #dee2e6;
    margin: 0.5rem 1.5rem;
}

.drawer-footer {
    padding: 1rem 1.5rem;
    border-top: 2px solid #f0f0f0;
    background: #f8f9fa;
    flex-shrink: 0;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .header-content {
        flex-direction: row;
        gap: 1rem;
        justify-content: space-between;
    }
    
    .logo-area {
        flex: 1;
        min-width: 0;
    }
    
    .site-title h1 {
        font-size: 1.2rem;
    }
    
    .site-title .subtitle {
        font-size: 0.8rem;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    #menuToggle { display: inline-block !important; }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .footer-info {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media print {
    .header, .nav-menu, .print-btn, .btn {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

