:root {
    /* Professional Blue & Gold Theme */
    --primary: #1E3A8A; /* Deep Blue */
    --primary-light: #3B82F6;
    --primary-dark: #1e293b;
    --secondary: #D97706; /* Gold/Amber */
    --secondary-light: #FCD34D;
    --bg-color: #F3F4F6;
    --surface: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px rgba(30, 58, 138, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Ensure mobile app touches the top edge */
    min-height: 100vh;
    color: var(--text-main);
}

/* Mobile App Container shell for desktop preview */
.app-container {
    width: 100%;
    max-width: 414px; /* iPhone Max width */
    height: 100vh;
    height: 100dvh;
    /* max-height removed for mobile so it fits the whole screen without gaps */
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
}

@media (min-width: 480px) {
    body {
        align-items: center; /* Center vertically on desktop displays */
    }
    .app-container {
        height: 90vh;
        max-height: 896px; /* Retain max-height only on desktop */
        border-radius: 40px;
        border: 8px solid #111;
    }
}

/* Screens MPA adaptation */
.screen {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 80px; /* Space for bottom nav */
}

/* Typography */
h1, h2, h3 { color: var(--text-main); font-weight: 700; }
p { color: var(--text-muted); line-height: 1.5; }

/* Header */
.header {
    padding: 24px 20px 16px;
    background: var(--surface);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title { font-size: 1.25rem; font-weight: 800; color: var(--primary); }
.back-btn { font-size: 1.2rem; color: var(--text-main); cursor: pointer; padding: 8px;}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 15px rgba(30, 58, 138, 0.3);
}

.btn-primary:active { transform: scale(0.98); box-shadow: none; }

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

/* Forms */
.input-group { margin-bottom: 20px; position: relative; }
.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}
.input-group input, .input-group select {
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border: 1.5px solid #E5E7EB;
    background: var(--surface);
    font-size: 1rem;
    transition: var(--transition);
    color: var(--text-main);
}
.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}
.input-icon {
    position: absolute;
    left: 20px;
    top: 42px;
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.02);
    position: relative;
    overflow: hidden;
}

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

/* Specific Screen Styles */

/* Auth Screens */
.auth-container {
    padding: 40px 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--surface);
}
.auth-header { text-align: center; margin-bottom: 40px; }
.logo-placeholder {
    width: 80px; height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-xl);
    display: flex; justify-content: center; align-items: center;
    margin: 0 auto 20px;
    color: white; font-size: 2rem;
    box-shadow: var(--shadow-md);
}
.auth-links { margin-top: 24px; text-align: center; font-size: 0.95rem;}
.auth-links a { color: var(--primary); font-weight: 700; text-decoration: none;}

/* Home / Categories */
.p-20 { padding: 20px; }
.user-welcome {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px;
}
.avatar {
    width: 50px; height: 50px; border-radius: 50%;
    background: var(--secondary-light);
    display: flex; justify-content: center; align-items: center;
    font-weight: bold; color: var(--secondary); font-size: 1.2rem;
}

.search-bar {
    background: var(--surface); border-radius: var(--radius-md);
    padding: 14px 20px; display: flex; align-items: center;
    box-shadow: var(--shadow-soft); margin-bottom: 24px;
}
.search-bar input { border: none; outline: none; flex: 1; margin-right: 12px; font-size: 1rem; }

.section-title { font-size: 1.2rem; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center;}

.grid-categories { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px;}
.cat-card {
    background: var(--surface); border-radius: var(--radius-lg);
    padding: 20px 16px; text-align: center;
    box-shadow: var(--shadow-soft);
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-main);
}
.cat-icon {
    width: 60px; height: 60px; border-radius: var(--radius-md);
    display: flex; justify-content: center; align-items: center;
    font-size: 1.8rem;
}
.cat-1 { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }
.cat-2 { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }
.cat-3 { background: rgba(16, 185, 129, 0.1); color: #10B981; }
.cat-4 { background: rgba(239, 68, 68, 0.1); color: #EF4444; }

/* Exams List */
.exam-item { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--text-main); }
.exam-icon {
    width: 50px; height: 50px; border-radius: var(--radius-sm);
    background: var(--bg-color); display: flex; justify-content: center; align-items: center;
    color: var(--primary); font-size: 1.5rem;
}
.exam-info { flex: 1; }
.exam-title { font-weight: 700; margin-bottom: 4px; font-size: 1.1rem;}
.exam-meta { font-size: 0.85rem; color: var(--text-muted); display: flex; gap: 12px;}
.exam-arrow { color: var(--primary); }

/* Question Screen */
.progress-container { margin-bottom: 24px; }
.progress-text { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 700; margin-bottom: 8px;}
.progress-bar { height: 8px; background: #E5E7EB; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); width: 25%; border-radius: 4px; transition: 0.3s;}

.question-card {
    background: var(--surface); padding: 24px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md); margin-bottom: 24px;
}
.question-text { font-size: 1.25rem; font-weight: 800; line-height: 1.6; color: var(--text-main);}

.options-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px;}
.option {
    padding: 16px 20px; border: 2px solid #E5E7EB; border-radius: var(--radius-md);
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 500; cursor: pointer; transition: all 0.2s; background: var(--surface);
}
.option.selected {
    border-color: var(--primary); background: rgba(59, 130, 246, 0.05); color: var(--primary);
}
.option-radio {
    width: 20px; height: 20px; border-radius: 50%; border: 2px solid #D1D5DB;
    display: flex; justify-content: center; align-items: center;
}
.option.selected .option-radio { border-color: var(--primary); }
.option.selected .option-radio::after {
    content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
}

/* Result Screen */
.result-container {
    text-align: center; padding: 40px 20px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%;
}
.result-circle {
    width: 150px; height: 150px; border-radius: 50%;
    background: rgba(16, 185, 129, 0.1); border: 8px solid var(--success);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    margin-bottom: 30px;
}
.result-score { font-size: 2.5rem; font-weight: 800; color: var(--success); line-height: 1;}
.result-total { font-size: 1rem; color: var(--text-muted); font-weight: bold;}
.result-title { font-size: 1.8rem; margin-bottom: 10px; color: var(--text-main);}
.result-desc { color: var(--text-muted); margin-bottom: 40px;}

/* Profile */
.profile-header {
    text-align: center; padding: 30px 20px; background: var(--surface);
    border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft); margin-bottom: 20px;
}
.profile-avatar {
    width: 100px; height: 100px; border-radius: 50%; background: var(--bg-color);
    margin: 0 auto 16px; border: 4px solid var(--primary-light); overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-stats {
    display: flex; justify-content: center; gap: 30px; margin-top: 20px;
}
.stat-item { text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--primary);}
.menu-list { padding: 0 20px; }
.menu-item {
    background: var(--surface); padding: 16px 20px; border-radius: var(--radius-md);
    margin-bottom: 12px; display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow-soft); cursor: pointer; font-weight: 700;
    text-decoration: none; color: var(--text-main);
}
.menu-item-icon {
    width: 40px; height: 40px; border-radius: 50%; background: rgba(59, 130, 246, 0.1);
    color: var(--primary); display: flex; justify-content: center; align-items: center;
}
.menu-item-text { flex: 1; }

/* Bottom Navigation */
.bottom-nav {
    position: fixed; 
    bottom: 0; 
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 414px;
    background: var(--surface); 
    display: flex; 
    justify-content: space-around;
    padding: 12px 10px calc(20px + env(safe-area-inset-bottom, 0px)); 
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    z-index: 9999; 
    border-top-left-radius: var(--radius-lg); 
    border-top-right-radius: var(--radius-lg);
}

@media (min-width: 480px) {
    .bottom-nav {
        position: absolute;
        left: 0;
        transform: none;
        max-width: none;
        padding-bottom: 20px;
    }
}

.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    color: var(--text-muted); cursor: pointer; transition: 0.3s;
    text-decoration: none;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 1.4rem; }
.nav-text { font-size: 0.75rem; font-weight: 700; }

.hide-nav .bottom-nav { display: none; }
