:root {
    --primary-color: #0d47a1;
    --primary-gradient: linear-gradient(135deg, #0d47a1, #1976d2);
    --secondary-color: #b8860b;
    /* Gold */
    --accent-color: #ffca28;
    --background-light: #fafafa;
    /* Off-white premium look */
    --text-dark: #333;
    --text-light: #777;
    --white: #ffffff;
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--background-light);
    color: var(--text-dark);
    direction: rtl;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    /* Remove mobile tap highlight */
}



/* Security Overlay - Anti-Screenshot/Blur */
#security-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

/* Watermark */
.watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 4.5rem;
    /* Even larger */
    font-weight: 900;
    /* Extra Bold */
    color: rgba(0, 0, 0, 0.12);
    pointer-events: none;
    z-index: 9998;
    white-space: nowrap;
    user-select: none;
    text-transform: uppercase;
}

/* Print Protection */
@media print {
    body {
        display: none !important;
    }
}

.contact-info {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    text-align: center;
}

.contact-info p {
    margin-bottom: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

.phone-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    background: rgba(13, 71, 161, 0.05);
    border-radius: 50px;
    transition: all 0.3s ease;
}

.phone-link:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(13, 71, 161, 0.2);
}

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

/* WhatsApp Button */
.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25d366;
    color: white;
    font-weight: 700;
    text-decoration: none;
    font-size: 1rem;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
}

.whatsapp-btn:hover {
    background: #128c7e;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 211, 102, 0.4);
}

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

/* Developer Credits */
.developer-credit {
    margin-top: 1rem;
    padding-top: 1rem;
    font-size: 0.9rem;
    color: #888;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: inline-block;
    width: 100%;
    direction: ltr;
    /* Ensure English text flows Left-to-Right */
    transition: transform 0.3s ease;
    cursor: default;
}

.developer-credit:hover {
    transform: scale(1.02);
}

.developer-name {
    background: linear-gradient(90deg, #0d47a1, #b8860b, #0d47a1);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
    text-transform: uppercase;
    margin: 0 5px;
    font-size: 1.3rem;
    animation: textShine 3s linear infinite;
}

.developer-phone {
    color: #0d47a1;
    /* Match primary brand color */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 900;
    /* Extra Bold */
    margin-left: 8px;
    direction: ltr;
    display: inline-block;
    font-size: 1.2rem;
    /* Larger number */
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.1);
}

@keyframes textShine {
    to {
        background-position: 200% center;
    }
}

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

/* Modern Utilities */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    /* Pill shape */
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(13, 71, 161, 0.3);
}

.card {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

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

/* Subject Cards Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

.subject-card {
    background: var(--white);
    text-decoration: none;
    color: var(--text-dark);
    padding: 2.5rem 1.5rem;
    border-radius: 20px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(13, 71, 161, 0.05);
    position: relative;
    overflow: hidden;
}

.subject-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform 0.4s ease;
    transform-origin: left;
}

.subject-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(13, 71, 161, 0.1);
    border-color: rgba(13, 71, 161, 0.1);
}

.subject-card:hover::before {
    transform: scaleX(1);
}

.subject-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    transition: transform 0.4s ease;
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.1));
}

.subject-card:hover .subject-icon {
    transform: scale(1.2) rotate(10deg);
}

.subject-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 0;
}

.subject-card p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}


/* Material Card Enhanced */
.material-item {
    background: rgba(255, 255, 255, 0.85);
    /* Glass feel */
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    border-right: 5px solid transparent;
    /* Right border for RTL */
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.material-item:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: var(--shadow-lg);
    background: rgba(255, 255, 255, 0.95);
}

/* Specific Border Colors based on context - handled via JS or specific classes usually.
   For now, default primary. */
.material-item {
    border-right: 5px solid var(--accent-color);
}

.material-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #e3f2fd, #ffffff);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* Login Page Only */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--primary-gradient);
}

.login-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* Responsive Navigation */
.main-nav {
    background: var(--primary-gradient);
    padding: 0.5rem 1rem;
    color: white;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    /* Ensure Logout is distinct if needed */
}

/* Logout Button - Distinct Style */
.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    margin-right: 15px;
    /* Extra spacing from profile */
}

.logout-btn:hover {
    background: rgba(255, 235, 238, 0.9);
    color: var(--danger);
    transform: translateX(-5px);
    /* Move left slightly on hover */
}

/* ... existing nav structure ... */

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    /* Subtle bubble */
    padding: 5px 15px 5px 5px;
    border-radius: 50px;
    transition: background 0.3s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.25);
}

.avatar-wrapper {
    position: relative;
    cursor: pointer;
    width: 48px;
    height: 48px;
    transition: transform 0.3s;
}

.avatar-wrapper:hover {
    transform: scale(1.1);
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    /* Glow */
    object-fit: cover;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-img {
    max-width: 150px;
    height: auto;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.login-header h1,
.brand-text {
    /* Gradient Text */
    background: linear-gradient(to right, #0d47a1, #b8860b, #0d47a1);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    background-size: 200% auto;
    animation: shine 5s linear infinite;

    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 1px;
}

.brand-text {
    margin-bottom: 0;
    font-size: 2.2rem;
    /* Slightly smaller than login or same */
}

@keyframes shine {
    to {
        background-position: 200% center;
    }
}

.login-header p {
    color: #666;
    margin-bottom: 1rem;
    letter-spacing: 1px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: right;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

.error-msg {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.9rem;
    display: none;
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: rgba(0, 0, 0, 0.5);
    line-height: 1.6;
}

/* Header Section Gradient */
.header-section {
    background: var(--primary-gradient);
    color: white;
    padding: 3rem 0;
    /* More spacing */
    text-align: center;
    clip-path: ellipse(150% 100% at 50% 0%);
    /* Curved bottom effect */
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

/* Security Warning Modal */
#security-warning-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
}

.warning-card {
    background: white;
    width: 90%;
    max-width: 500px;
    padding: 2.5rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    border-top: 10px solid #dc3545;
    animation: slideInDown 0.5s ease-out;
}

@keyframes slideInDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

.warning-card h2 {
    color: #dc3545;
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    font-weight: 800;
}

.warning-card p {
    font-size: 1.1rem;
    color: #444;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.warning-card .btn-confirm {
    background: #dc3545;
    color: white;
    padding: 1rem 3rem;
    border: none;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.warning-card .btn-confirm:hover {
    background: #a71d2a;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.4);
}

/* Persistent Warning Banner */
.persistent-warning {
    background: #fff5f5;
    border: 2px solid #dc3545;
    color: #dc3545;
    padding: 0.8rem 1.2rem;
    margin: 1rem auto;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.15);
    animation: pulseWarning 2s infinite;
    position: sticky;
    top: 75px;
    /* Stay below sticky nav */
    z-index: 999;
    width: 95%;
    max-width: 1100px;
}

@keyframes pulseWarning {
    0% {
        border-color: #dc3545;
        box-shadow: 0 4px 15px rgba(220, 53, 69, 0.1);
    }

    50% {
        border-color: #ff8787;
        box-shadow: 0 4px 25px rgba(220, 53, 69, 0.3);
    }

    100% {
        border-color: #dc3545;
        box-shadow: 0 4px 15px rgba(220, 53, 69, 0.1);
    }
}

/* --- MOBILE RESPONSIVENESS OVERHAUL --- */

@media (max-width: 768px) {
    .container {
        padding: 0 1.25rem;
    }

    /* Brand Header on Mobile */
    .brand-text {
        font-size: 1.6rem !important;
        letter-spacing: 1px;
    }

    .nav-container {
        padding: 0.5rem 1rem;
    }

    .main-nav {
        padding: 0;
    }

    .nav-actions {
        gap: 10px;
    }

    .welcome-msg {
        display: none;
        /* Hide 'Welcome' text on very small screens to save space */
    }

    .logout-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        margin-right: 5px;
    }

    /* Header Section */
    .header-section {
        padding: 2.5rem 1rem;
        clip-path: ellipse(200% 100% at 50% 0%);
    }

    .header-section h1 {
        font-size: 1.8rem !important;
    }

    /* Grid Layouts */
    .dashboard-grid {
        grid-template-columns: 1fr;
        /* Single column on mobile */
        gap: 1.2rem;
        padding: 1.5rem 0;
    }

    .subject-card {
        padding: 1.8rem 1.2rem;
        flex-direction: row;
        /* Horizontal layout on mobile for easier tapping */
        text-align: right;
        justify-content: flex-start;
        gap: 1.5rem;
    }

    .subject-icon {
        font-size: 2.8rem;
        margin-bottom: 0;
    }

    .subject-card h2 {
        font-size: 1.3rem;
    }

    /* Material Items */
    .material-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.2rem;
    }

    .material-item .action-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
        padding: 0.8rem;
    }

    /* Modals for Mobile */
    .modal-content {
        width: 95% !important;
        margin: 10px;
        max-height: 90vh;
    }

    .warning-card {
        padding: 1.5rem;
    }

    .warning-card h2 {
        font-size: 1.5rem;
    }

    .warning-card p {
        font-size: 1rem;
    }

    /* Persistent Warning */
    .persistent-warning {
        top: 60px;
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }
}

/* Small devices (phones, 480px and down) */
@media (max-width: 480px) {
    .brand-text {
        font-size: 1.3rem !important;
    }

    .subject-icon {
        font-size: 2.2rem;
    }

    .subject-card h2 {
        font-size: 1.1rem;
    }

    .header-section {
        padding: 2rem 1rem;
    }
}

/* Native App Feel Fixes */
.subject-card,
.material-item,
.btn,
.logout-btn {
    user-select: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.subject-card:active {
    transform: scale(0.96);
    background-color: #f0f4f8;
}

.persistent-warning i {
    font-size: 1.5rem;
}