:root {
    /* Apple Palette - Default Light */
    --system-bg: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #007aff;
    --glass-border: rgba(0, 0, 0, 0.08);
    --blur: blur(20px);
}

/* التحويل اليدوي أو التلقائي للوضع المظلم */
[data-theme="dark"] {
    --system-bg: #000000;
    --card-bg: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --accent: #0a84ff;
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* الالتزام بإعدادات النظام إذا لم يتم التحديد يدوياً */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --system-bg: #000000;
        --card-bg: #1c1c1e;
        --text-primary: #f5f5f7;
        --text-secondary: #86868b;
        --accent: #0a84ff;
        --glass-border: rgba(255, 255, 255, 0.1);
    }
}

/* تنسيق زر التبديل */
.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: var(--text-primary);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--system-bg);
    color: var(--text-primary);
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    transition: background-color 0.5s ease;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1000px;
}

.main-platform-title {
    font-size: 42px;
    font-weight: 800;
    margin-bottom: 40px;
    text-align: center;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
    animation: fadeInDown 0.8s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes backgroundDrift {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 500px 500px;
    }
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Cg fill='%23888888' fill-opacity='0.15'%3E%3Ctext x='30' y='50' font-family='Arial' font-size='24' transform='rotate(15,30,50)'%3Eπ%3C/text%3E%3Ctext x='180' y='40' font-family='Arial' font-size='32' transform='rotate(-10,180,40)'%3E∑%3C/text%3E%3Ctext x='110' y='120' font-family='Arial' font-size='28' transform='rotate(5,110,120)'%3E∫%3C/text%3E%3Ctext x='40' y='200' font-family='Arial' font-size='26' transform='rotate(20,40,200)'%3E∞%3C/text%3E%3Ctext x='210' y='220' font-family='Arial' font-size='30' transform='rotate(-15,210,220)'%3E√%3C/text%3E%3Ctext x='140' y='70' font-family='Arial' font-size='22' transform='rotate(-5,140,70)'%3Ex²%3C/text%3E%3Ctext x='70' y='140' font-family='Arial' font-size='20' transform='rotate(10,50,140)'%3Ef(x)%3C/text%3E%3Ctext x='170' y='170' font-family='Arial' font-size='24' transform='rotate(-10,170,170)'%3Esin%3C/text%3E%3C/g%3E%3C/svg%3E");
    background-repeat: repeat;
    animation: backgroundDrift 60s linear infinite;
    opacity: 1;
    /* يتم التحكم بالشفافية داخل الـ SVG نفسه لضمان جودة الأداء */
}

[data-theme="dark"] body::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='250' height='250'%3E%3Cg fill='%23ffffff' fill-opacity='0.12'%3E%3Ctext x='30' y='50' font-family='Arial' font-size='24' transform='rotate(15,30,50)'%3Eπ%3C/text%3E%3Ctext x='180' y='40' font-family='Arial' font-size='32' transform='rotate(-10,180,40)'%3E∑%3C/text%3E%3Ctext x='110' y='120' font-family='Arial' font-size='28' transform='rotate(5,110,120)'%3E∫%3C/text%3E%3Ctext x='40' y='200' font-family='Arial' font-size='26' transform='rotate(20,40,200)'%3E∞%3C/text%3E%3Ctext x='210' y='220' font-family='Arial' font-size='30' transform='rotate(-15,210,220)'%3E√%3C/text%3E%3Ctext x='140' y='70' font-family='Arial' font-size='22' transform='rotate(-5,140,70)'%3Ex²%3C/text%3E%3Ctext x='70' y='140' font-family='Arial' font-size='20' transform='rotate(10,50,140)'%3Ef(x)%3C/text%3E%3Ctext x='170' y='170' font-family='Arial' font-size='24' transform='rotate(-10,170,170)'%3Esin%3C/text%3E%3C/g%3E%3C/svg%3E");
}

/* Login Split Layout */
.login-split-wrapper {
    display: flex;
    width: 100%;
    max-width: 1000px;
    min-height: 600px;
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: fadeIn 0.8s ease-out;
}

.login-info-side {
    flex: 1.2;
    background: linear-gradient(135deg, var(--accent), #5856d6);
    position: relative;
    padding: 60px 40px;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

/* Login Image */
.login-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.info-content {
    position: relative;
    z-index: 2;
    text-align: right;
}

.education-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 30px;
}

.school-details h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 15px;
    line-height: 1.4;
}

.school-details h2 {
    font-size: 18px;
    opacity: 0.95;
    margin-bottom: 5px;
}

.school-details h3 {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.school-details h4 {
    font-size: 15px;
    opacity: 0.85;
    margin-bottom: 20px;
}

.divider {
    width: 50px;
    height: 4px;
    background: #ffffff;
    border-radius: 2px;
    margin-bottom: 25px;
    margin-right: 0;
}

.team-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.specialization {
    font-size: 15px;
    opacity: 0.9;
    margin-bottom: 30px;
}

.supervisor {
    font-size: 15px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.1);
    padding: 10px 20px;
    border-radius: 50px;
    display: inline-block;
}

.supervisor span {
    opacity: 0.8;
}

/* Form Side Style */
.login-form-side {
    flex: 1;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--card-bg);
}

.form-header {
    margin-bottom: 40px;
}

.form-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.form-header p {
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.forgot-link {
    font-size: 14px;
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 600;
}

.forgot-link:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Password Toggle Styles */
.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    padding-left: 50px !important;
    /* Space for the icon on the left in RTL, or right in LTR */
}

/* Since it's RTL, the icon should be on the left */
[dir="rtl"] .password-wrapper input {
    padding-left: 50px !important;
    padding-right: 16px !important;
}

.toggle-password {
    position: absolute;
    top: 50%;
    left: 15px;
    /* In RTL, left is where the pointer ends */
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    transition: color 0.2s;
    z-index: 10;
}

.toggle-password:hover {
    color: var(--accent);
}

.toggle-password svg {
    width: 22px;
    height: 22px;
}

.form-footer {
    margin-top: 30px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* الشاشات المتوسطة والكبيرة - تكبير العناصر */
@media (min-width: 1024px) {
    .form-header h2 {
        font-size: 42px;
    }

    .form-header p {
        font-size: 18px;
    }

    .form-group label {
        font-size: 16px;
        font-weight: 600;
    }

    .form-group input {
        padding: 20px 24px;
        font-size: 19px;
    }

    .btn {
        padding: 20px;
        font-size: 19px;
        margin-top: 20px;
    }

    .form-footer {
        font-size: 16px;
        margin-top: 50px;
    }

    .login-form-side {
        padding: 100px 80px;
    }

    .login-info-side {
        padding: 100px 80px;
    }

    .school-details h1 {
        font-size: 32px;
        margin-bottom: 20px;
    }

    .school-details h2 {
        font-size: 22px;
        margin-bottom: 8px;
    }

    .school-details h3 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .school-details h4 {
        font-size: 18px;
        margin-bottom: 30px;
    }

    .team-name {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .specialization {
        font-size: 17px;
        margin-bottom: 40px;
    }

    .supervisor {
        font-size: 17px;
        padding: 12px 24px;
    }

    .education-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 40px;
    }
}

/* الشاشات العريضة جداً */
@media (min-width: 1400px) {
    .form-header h2 {
        font-size: 40px;
    }

    .form-group input {
        padding: 20px 24px;
        font-size: 19px;
    }

    .btn {
        padding: 20px;
        font-size: 19px;
    }
}

@media (max-width: 850px) {
    .login-split-wrapper {
        flex-direction: column;
        max-width: 450px;
        margin: 20px;
    }

    .main-platform-title {
        font-size: 28px;
        margin-bottom: 25px;
    }

    .login-info-side {
        padding: 40px 30px;
    }

    .login-form-side {
        padding: 40px 30px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-container {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.8s ease-out;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: all 0.2s;
}

.form-group input:focus {
    background: transparent;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 12px;
}

.btn:hover {
    filter: brightness(1.1);
    transform: scale(1.01);
}

.btn:active {
    transform: scale(0.98);
}

.footer-links {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.footer-links a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

/* Dashboard Layout fixes for RTL */
body.dashboard-body {
    display: block;
    padding: 0;
    margin: 0;
    overflow: hidden;
    height: 100vh;
}

.dashboard-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
    background-color: var(--system-bg);
}

.sidebar {
    width: 280px;
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-left: 1px solid var(--glass-border);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    transition: width 0.3s ease;
}

.main-footer {
    background: var(--accent);
    color: #ffffff;
    padding: 15px 25px;
    width: 100%;
    margin-top: auto;
    /* Pushes it to the bottom if content is short */
    position: relative;
    z-index: 50;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
}

.footer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 11px;
    flex-wrap: wrap;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-container span,
.footer-container a {
    color: #ffffff;
    text-decoration: none;
    white-space: nowrap;
}

.footer-container .sep {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 300;
}

.main-content {
    flex: 1;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    background-color: var(--system-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.view-content {
    padding: 40px;
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.nav-item {
    padding: 14px 20px;
    border-radius: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 16px;
    font-weight: 500;
}

.nav-item.active {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.15);
}

.nav-item:hover:not(.active) {
    background: rgba(128, 128, 128, 0.08);
    color: var(--text-primary);
    transform: translateX(-5px);
    /* Slide left on hover in RTL */
}

/* Headers & Actions */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    width: 100%;
}

.header-actions h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Stats Grid - Apple Style Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-box {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    transition: transform 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.stat-box h3 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--accent);
}

.stat-box p {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
}

/* Question Cards Management */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.q-card {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    border-radius: 24px;
    padding: 30px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
}

.q-card:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
}

/* Modal SF Style Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 30px;
    padding: 40px;
    border: 1px solid var(--glass-border);
    transform: scale(0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* Responsiveness overrides */

/* شاشات اللابتوب المتوسطة */
@media (max-width: 1200px) {
    .sidebar {
        width: 220px;
        padding: 30px 16px;
    }

    .sidebar h2 {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .nav-item {
        font-size: 14px;
        padding: 12px 16px;
    }

    .main-content {
        padding: 0;
    }

    .header-actions h1 {
        font-size: 22px;
    }
}

/* شاشات اللابتوب الصغيرة والتابلت */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
        padding: 20px 12px;
    }

    .main-content {
        padding: 0;
    }

    .header-actions {
        margin-bottom: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 16px;
    }

    .stat-box {
        padding: 16px;
    }

    .stat-box h3 {
        font-size: 24px;
    }
}

/* التابلت والموبايل */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 12px 16px;
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        border-left: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .sidebar h2,
    .sidebar-footer {
        display: none;
        /* إخفاء العناصر لتوفير المساحة على الموبايل */
    }

    .main-content {
        padding: 0;
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 16px;
    }

    .header-actions .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 12px;
    }

    .nav-item {
        margin-bottom: 0;
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* Chrome Recommendation Modal */
.chrome-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.chrome-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 24px;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(0);
    animation: slideUpModal 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes slideUpModal {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chrome-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
}

.chrome-content h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.chrome-content p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 25px;
}

.chrome-btn {
    background: var(--accent);
    color: white;
    padding: 14px 30px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.chrome-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}