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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #059669;
    --warning-color: #ea580c;
    --error-color: #dc2626;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 0.5rem;
    --transition: all 0.2s ease-in-out;
}

/* Fonts */
body {
    font-family: 'Inter', 'Cairo', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background);
}

[lang="ar"], [dir="rtl"] {
    font-family: 'Cairo', 'Inter', system-ui, sans-serif;
    direction: rtl;
    text-align: right;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Page System */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Landing Page */
.landing-header {
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 1rem 0;
}

.landing-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.logo p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.lang-switch {
    display: flex;
    align-items: center;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.lang-btn:hover {
    background: var(--background);
}

.landing-main {
    padding: 4rem 0;
}

.hero {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--success-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin: 4rem 0;
}

.feature-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    transition: var(--transition);
}

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

.feature-card i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--text-secondary);
}

/* Access Portals */
.access-portals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 4rem;
}

.portal-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    transition: var(--transition);
}

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

.supervisor-portal {
    border-top: 4px solid var(--primary-color);
}

.student-portal {
    border-top: 4px solid var(--success-color);
}

.portal-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.portal-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.portal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-success, .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--background);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #047857;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

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

.full-width {
    width: 100%;
    justify-content: center;
}

/* Authentication */
.auth-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    position: relative;
}

.back-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
}

[dir="rtl"] .back-btn {
    right: auto;
    left: 2rem;
}

.back-btn:hover {
    background: var(--background);
}

.auth-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: var(--transition);
    background: var(--surface);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

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

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-container {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

/* Navigation */
.navbar {
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 1rem 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.nav-links a:hover {
    color: var(--primary-color);
}

.nav-actions {
    display: flex;
    gap: 1rem;
}

/* Dashboard */
.dashboard-main {
    padding: 2rem 0;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card i {
    font-size: 2.5rem;
    color: var(--primary-color);
}

.stat-info h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Students Table */
.students-list {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.students-table th,
.students-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

[dir="ltr"] .students-table th,
[dir="ltr"] .students-table td {
    text-align: left;
}

.students-table th {
    background: var(--background);
    font-weight: 600;
}

.students-table tr:hover {
    background: var(--background);
}

/* Evaluation */
.domains-grid h3 {
    margin: 2rem 0 1rem 0;
    font-size: 1.25rem;
}

.domain-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.domain-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

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

.domain-card.selected {
    border-color: var(--primary-color);
    background: rgb(37 99 235 / 0.05);
}

.domain-card i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.domain-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.domain-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Evaluation Progress */
.evaluation-progress {
    max-width: 800px;
    margin: 2rem auto;
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.question-container {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    min-height: 300px;
}

.question h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.options-grid {
    display: grid;
    gap: 1rem;
}

.option {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.option:hover {
    border-color: var(--primary-color);
}

.option.selected {
    border-color: var(--primary-color);
    background: rgb(37 99 235 / 0.05);
}

.evaluation-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Activities */
.activities-list {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.activity-icon.evaluation {
    background: rgb(37 99 235 / 0.1);
    color: var(--primary-color);
}

.activity-icon.student {
    background: rgb(5 150 105 / 0.1);
    color: var(--success-color);
}

.activity-icon.report {
    background: rgb(234 88 12 / 0.1);
    color: var(--warning-color);
}

.activity-content h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.activity-content p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Reports */
.reports-controls {
    display: flex;
    gap: 1rem;
    align-items: end;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.reports-controls .form-group {
    margin-bottom: 0;
    min-width: 200px;
}

.reports-list {
    display: grid;
    gap: 1rem;
}

.report-item {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.report-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.report-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.report-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

/* Report Preview */
.report-preview {
    background: var(--surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin: 2rem 0;
}

.report-header {
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 2rem;
    margin-bottom: 2rem;
}

.report-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.report-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.report-section {
    margin-bottom: 2rem;
}

.report-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

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

.score-item {
    background: var(--background);
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
}

.score-item h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.score-value.high {
    color: var(--success-color);
}

.score-value.medium {
    color: var(--warning-color);
}

.score-value.low {
    color: var(--error-color);
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Student Dashboard */
.student-main {
    padding: 2rem 0;
}

.student-welcome {
    text-align: center;
    margin-bottom: 3rem;
}

.student-welcome h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.student-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.student-card {
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: var(--surface);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.close {
    color: var(--text-secondary);
    float: left;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 1rem;
    left: 1rem;
    cursor: pointer;
}

[dir="rtl"] .close {
    float: right;
    left: auto;
    right: 1rem;
}

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

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .access-portals {
        grid-template-columns: 1fr;
    }
    
    .portal-buttons {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .domain-cards {
        grid-template-columns: 1fr;
    }
    
    .evaluation-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .reports-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .report-meta {
        grid-template-columns: 1fr;
    }
    
    .student-content {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .navbar, .evaluation-controls, .report-actions, .back-btn, .lang-switch {
        display: none !important;
    }
    
    .report-preview {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
    
    body {
        background: white;
    }
    
    .page {
        display: block !important;
    }
    
    .content-section {
        display: block !important;
    }
}

/* RTL Specific Adjustments */
[dir="rtl"] .nav-links {
    direction: rtl;
}

[dir="rtl"] .form-actions {
    flex-direction: row-reverse;
}

[dir="rtl"] .evaluation-controls {
    flex-direction: row-reverse;
}

[dir="rtl"] .report-actions {
    flex-direction: row-reverse;
}

[dir="rtl"] .activity-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .stat-card {
    flex-direction: row-reverse;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles */
button:focus,
input:focus,
select:focus,
textarea:focus,
.domain-card:focus,
.option:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}