/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    direction: rtl;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px 30px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #4a5568;
    font-size: 2rem;
    font-weight: 700;
}

.header h1 i {
    color: #667eea;
    margin-left: 10px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.nav-tab {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.nav-tab:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.nav-tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Tab Content */
.tab-content {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.section-header h2 {
    color: #2d3748;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #ed8936, #dd6b20);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

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

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

th {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 15px;
    text-align: right;
    font-weight: 600;
    font-size: 0.9rem;
}

td {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
    text-align: right;
}

tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

tr:last-child td {
    border-bottom: none;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 0;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px) scale(0.9); }
    to { transform: translateY(0) scale(1); }
}

.modal-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px 30px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.7;
}

/* Forms */
form {
    padding: 30px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #2d3748;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f7fafc;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* Export Options */
.export-options {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.export-options .btn {
    justify-content: center;
    padding: 15px;
    font-size: 1rem;
}

/* Loading Spinner */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-right: 4px solid;
    animation: toastSlideIn 0.3s ease;
    max-width: 400px;
}

@keyframes toastSlideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success {
    border-color: #48bb78;
}

.toast.error {
    border-color: #f56565;
}

.toast.info {
    border-color: #4299e1;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .nav-tabs {
        flex-direction: column;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn-sm {
        padding: 10px;
        font-size: 0.8rem;
    }
}


/* Editable cells styling */
.editable-cell {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
}

.editable-cell:hover {
    background-color: #f7fafc !important;
    border: 1px solid #e2e8f0;
}

.editable-cell:hover::after {
    content: "انقر للتعديل";
    position: absolute;
    top: -25px;
    right: 0;
    background: #4a5568;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0.8;
}

.inline-edit-input {
    width: 100% !important;
    border: 2px solid #667eea !important;
    border-radius: 4px !important;
    padding: 5px 8px !important;
    font-size: 14px !important;
    font-family: 'Cairo', sans-serif !important;
    background: white !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.inline-edit-input:focus {
    border-color: #4c51bf !important;
    box-shadow: 0 0 0 3px rgba(76, 81, 191, 0.2) !important;
}

/* Responsive adjustments for editable cells */
@media (max-width: 768px) {
    .editable-cell:hover::after {
        display: none;
    }
    
    .inline-edit-input {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
}


/* Import modal styling */
.import-section {
    padding: 20px 0;
}

.import-template {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
}

.import-template h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 16px;
}

.import-template table {
    font-size: 12px;
    margin-top: 10px;
}

.import-template th,
.import-template td {
    text-align: center;
    font-size: 11px;
}

.import-template ol {
    margin: 10px 0;
    padding-right: 20px;
}

.import-template ol li {
    margin: 5px 0;
    font-size: 14px;
}

/* File input styling */
input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="file"]:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

input[type="file"]:focus {
    outline: none;
    border-color: #4c51bf;
    box-shadow: 0 0 0 3px rgba(76, 81, 191, 0.1);
}


/* Report page styling */
.report-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.report-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.report-controls select {
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Cairo', sans-serif;
    background: white;
    min-width: 200px;
}

.report-content {
    margin-top: 30px;
}

.report-placeholder,
.report-error {
    text-align: center;
    padding: 60px 20px;
    color: #718096;
}

.report-placeholder i,
.report-error i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

.report-error {
    color: #e53e3e;
}

/* Level report card */
.level-report-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f7fafc;
}

.level-header h3 {
    color: #2d3748;
    font-size: 24px;
    margin: 0;
}

.level-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    background: #667eea;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.level-details {
    margin-bottom: 25px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}

.detail-row strong {
    color: #4a5568;
    font-weight: 600;
}

.students-section h4 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 18px;
}

.students-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.students-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.students-table th,
.students-table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
}

.students-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #4a5568;
}

.students-table tr:hover {
    background: #f8fafc;
}

.no-students {
    text-align: center;
    color: #718096;
    font-style: italic;
    padding: 20px;
}

/* All levels report */
.all-levels-report {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card i {
    font-size: 32px;
    opacity: 0.8;
}

.stat-info h3 {
    font-size: 28px;
    margin: 0;
    font-weight: 700;
}

.stat-info p {
    margin: 5px 0 0 0;
    opacity: 0.9;
    font-size: 14px;
}

.levels-breakdown {
    display: grid;
    gap: 20px;
}

.level-summary-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.level-summary-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.level-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.level-summary-header h4 {
    color: #2d3748;
    margin: 0;
    font-size: 18px;
}

.student-count {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

.level-summary-details p {
    margin: 8px 0;
    color: #4a5568;
    font-size: 14px;
}

.students-preview ul {
    margin: 10px 0 0 20px;
    color: #718096;
}

.students-preview li {
    margin: 3px 0;
    font-size: 13px;
}

/* Responsive design for reports */
@media (max-width: 768px) {
    .report-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .report-controls select {
        min-width: auto;
        width: 100%;
    }
    
    .level-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .detail-row {
        flex-direction: column;
        gap: 5px;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        text-align: center;
        flex-direction: column;
    }
    
    .level-summary-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

