/* ============================================================
   TAIF AL EMARAT INTERACTIVE TRAINING PLATFORM
   File 7: styles.css - Complete Design System
   ============================================================ */

/* ============================================================
   CSS VARIABLES - TAIF BRAND COLORS
   ============================================================ */
:root {
    /* Primary Palette */
    --taif-primary: #9B8570;      /* Bare Earth / Taif Beige */
    --taif-primary-dark: #7A6A5A;
    --taif-primary-light: #B5A390;
    
    /* Accent Colors */
    --taif-accent: #B57B70;       /* Dusty Rosewood */
    --taif-accent-light: #C9958A;
    
    /* Deep Gold */
    --taif-gold: #C9A96E;         /* Golden accent */
    --taif-gold-dark: #A88B52;
    --taif-gold-light: #D4BC8E;
    
    /* Background */
    --taif-bg: #F5F0EB;          /* Soft cream */
    --taif-bg-dark: #E8E0D8;
    --taif-bg-card: #FFFFFF;
    
    /* Text */
    --taif-text: #2C2416;         /* Dark brown-black */
    --taif-text-light: #6B5D4D;
    --taif-text-muted: #9B8E7E;
    
    /* Functional Colors */
    --success: #2D6A4F;           /* Forest Green */
    --success-light: #E8F5E9;
    --error: #9B2226;             /* Deep Red */
    --error-light: #FFEBEE;
    --warning: #C9A96E;
    --info: #3D6574;              /* Stone Blue */
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(44, 36, 22, 0.06);
    --shadow-md: 0 4px 20px rgba(44, 36, 22, 0.08);
    --shadow-lg: 0 8px 40px rgba(44, 36, 22, 0.12);
    --shadow-hover: 0 12px 48px rgba(44, 36, 22, 0.15);
    
    /* Typography */
    --font-en: 'Montserrat', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-ar: 'Tajawal', 'Noto Sans Arabic', 'Segoe UI', sans-serif;
    
    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 15px;
    --radius-xl: 24px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ============================================================
   DARK MODE (optional, system preference)
   ============================================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --taif-bg: #1A1612;
        --taif-bg-dark: #2C2416;
        --taif-bg-card: #2C2416;
        --taif-text: #F5F0EB;
        --taif-text-light: #B5A390;
        --taif-text-muted: #9B8E7E;
    }
}

/* ============================================================
   BASE STYLES
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-en);
    background-color: var(--taif-bg);
    color: var(--taif-text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* RTL Support */
body[dir="rtl"] {
    font-family: var(--font-ar);
}

body[dir="rtl"] .ltr-only {
    display: none;
}

body[dir="ltr"] .rtl-only {
    display: none;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--taif-text);
}

h1 { font-size: 2.5rem; letter-spacing: -0.02em; }
h2 { font-size: 2rem; letter-spacing: -0.01em; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--taif-text-light);
}

.text-primary { color: var(--taif-primary); }
.text-accent { color: var(--taif-accent); }
.text-gold { color: var(--taif-gold); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-muted { color: var(--taif-text-muted); }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

body[dir="rtl"] .text-right { text-align: left; }
body[dir="rtl"] .text-left { text-align: right; }

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

.grid {
    display: grid;
}

.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--taif-bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
    border: 1px solid rgba(155, 133, 112, 0.1);
}

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

.card-locked {
    opacity: 0.6;
    position: relative;
    overflow: hidden;
}

.card-locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.3;
}

body[dir="rtl"] .card-locked::after {
    left: auto;
    right: 50%;
    transform: translate(50%, -50%);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(155, 133, 112, 0.15);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--taif-text);
    margin: 0;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--taif-text-muted);
    margin-top: 0.25rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

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

.btn-primary:hover {
    background: var(--taif-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-accent:hover {
    background: #9B6B60;
    transform: translateY(-2px);
}

.btn-gold {
    background: var(--taif-gold);
    color: var(--taif-text);
}

.btn-gold:hover {
    background: var(--taif-gold-dark);
    transform: translateY(-2px);
}

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

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

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

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 1rem 2.5rem;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--taif-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--taif-bg-dark);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    color: var(--taif-text);
    background: var(--taif-bg-card);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--taif-primary);
    box-shadow: 0 0 0 3px rgba(155, 133, 112, 0.15);
}

.form-input::placeholder {
    color: var(--taif-text-muted);
}

.form-input-error {
    border-color: var(--error);
}

.form-input-error:focus {
    box-shadow: 0 0 0 3px rgba(155, 34, 38, 0.15);
}

.form-error {
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    background: var(--taif-bg-card);
    box-shadow: var(--shadow-sm);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.navbar-logo {
    height: 40px;
    width: auto;
}

.navbar-brand-text {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--taif-text);
    letter-spacing: 1px;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
}

.nav-link {
    color: var(--taif-text-light);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color var(--transition-fast);
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--taif-primary);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--taif-gold);
    transition: width var(--transition-fast);
}

body[dir="rtl"] .nav-link::after {
    left: auto;
    right: 0;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* ============================================================
   LANGUAGE TOGGLE
   ============================================================ */
.lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--taif-bg-dark);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

.lang-btn {
    padding: 0.375rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--taif-text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

/* ============================================================
   PROGRESS CIRCLE
   ============================================================ */
.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
}

.progress-circle svg {
    transform: rotate(-90deg);
}

.progress-circle-bg {
    fill: none;
    stroke: var(--taif-bg-dark);
    stroke-width: 8;
}

.progress-circle-fill {
    fill: none;
    stroke: var(--taif-primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.progress-circle-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--taif-primary);
}

/* ============================================================
   QUIZ STYLES
   ============================================================ */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

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

.quiz-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--taif-bg-dark);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--taif-text);
}

.question-card {
    background: var(--taif-bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.question-number {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--taif-gold);
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.question-image {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    background: var(--taif-bg-dark);
}

/* Answer Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--taif-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
    color: var(--taif-text);
}

body[dir="rtl"] .option-btn {
    text-align: right;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--taif-primary);
    background: var(--taif-bg-card);
    transform: translateX(4px);
}

body[dir="rtl"] .option-btn:hover:not(:disabled) {
    transform: translateX(-4px);
}

.option-btn.selected {
    border-color: var(--taif-primary);
    background: rgba(155, 133, 112, 0.1);
}

.option-btn.correct {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}

.option-btn.incorrect {
    border-color: var(--error);
    background: var(--error-light);
    color: var(--error);
}

.option-btn:disabled {
    cursor: default;
}

.option-key {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: var(--taif-primary);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

.option-btn.correct .option-key {
    background: var(--success);
}

.option-btn.incorrect .option-key {
    background: var(--error);
}

/* Explanation */
.explanation-box {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: rgba(61, 101, 116, 0.1);
    border-left: 4px solid var(--info);
}

body[dir="rtl"] .explanation-box {
    border-left: none;
    border-right: 4px solid var(--info);
}

.explanation-box.correct {
    background: var(--success-light);
    border-left-color: var(--success);
    color: var(--success);
}

body[dir="rtl"] .explanation-box.correct {
    border-right-color: var(--success);
    color: var(--success);
}

.explanation-box.incorrect {
    background: var(--error-light);
    border-left-color: var(--error);
    color: var(--error);
}

body[dir="rtl"] .explanation-box.incorrect {
    border-right-color: var(--error);
    color: var(--error);
}

/* ============================================================
   RESULTS SCREEN
   ============================================================ */
.results-container {
    text-align: center;
    padding: 3rem 1rem;
}

.results-score {
    font-size: 4rem;
    font-weight: 700;
    color: var(--taif-primary);
    line-height: 1;
}

.results-score.passed {
    color: var(--success);
}

.results-score.failed {
    color: var(--error);
}

.results-message {
    font-size: 1.5rem;
    margin: 1rem 0;
}

.results-message.passed {
    color: var(--success);
}

.results-message.failed {
    color: var(--error);
}

.certificate-card {
    background: linear-gradient(135deg, var(--taif-gold) 0%, var(--taif-primary) 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--radius-xl);
    margin-top: 2rem;
    text-align: center;
}

.certificate-code {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-top: 0.5rem;
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard-header {
    margin-bottom: 2rem;
}

.welcome-text {
    font-size: 1.5rem;
    color: var(--taif-text-light);
}

.welcome-text strong {
    color: var(--taif-text);
}

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

.stat-card {
    background: var(--taif-bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--taif-primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--taif-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.module-card {
    position: relative;
    padding: 1.5rem;
}

.module-status {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body[dir="rtl"] .module-status {
    right: auto;
    left: 1rem;
}

.module-status.passed {
    background: var(--success-light);
    color: var(--success);
}

.module-status.in-progress {
    background: rgba(201, 169, 110, 0.2);
    color: var(--taif-gold-dark);
}

.module-status.locked {
    background: var(--taif-bg-dark);
    color: var(--taif-text-muted);
}

.module-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--taif-bg-dark);
    border-radius: 3px;
    margin-top: 1rem;
    overflow: hidden;
}

.module-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--taif-primary), var(--taif-gold));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ============================================================
   ADMIN DASHBOARD
   ============================================================ */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--taif-bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-table th,
.admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--taif-bg-dark);
}

body[dir="rtl"] .admin-table th,
body[dir="rtl"] .admin-table td {
    text-align: right;
}

.admin-table th {
    background: var(--taif-bg-dark);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    color: var(--taif-text-muted);
}

.admin-table tr:hover {
    background: rgba(155, 133, 112, 0.05);
}

.status-pill {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pill.passed {
    background: var(--success-light);
    color: var(--success);
}

.status-pill.failed {
    background: var(--error-light);
    color: var(--error);
}

.status-pill.pending {
    background: rgba(201, 169, 110, 0.2);
    color: var(--taif-gold-dark);
}

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

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.animate-slide-in {
    animation: slideIn 0.5s ease forwards;
}

.animate-pulse {
    animation: pulse 2s ease infinite;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--taif-bg-dark) 25%, var(--taif-bg) 50%, var(--taif-bg-dark) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--taif-bg) 0%, var(--taif-bg-dark) 100%);
    padding: 2rem;
}

.login-card {
    background: var(--taif-bg-card);
    padding: 3rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
}

.login-title {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--taif-text-muted);
    margin-bottom: 2rem;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

body[dir="rtl"] .toast-container {
    right: auto;
    left: 1rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--info); }
.toast.warning { background: var(--warning); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    
    .login-card {
        padding: 2rem 1.5rem;
    }
    
    .quiz-container {
        padding: 1rem;
    }
    
    .question-card {
        padding: 1.5rem;
    }
    
    .navbar-nav {
        display: none; /* Mobile menu would need JS toggle */
    }
}

/* ============================================================
   PRINT STYLES (for certificates)
   ============================================================ */
@media print {
    .no-print {
        display: none !important;
    }
    
    .certificate-card {
        box-shadow: none;
        border: 2px solid var(--taif-gold);
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden {
    display: none !important;
}

.screen {
    min-height: calc(100vh - 80px);
}

#screen-login {
    min-height: 100vh;
}

#navbar.hidden {
    display: none !important;
}