/* =====================================================================
   SecurityForMe — styles (RTL + LTR aware via logical properties)
   ===================================================================== */
:root {
    --navy:    #0b2545;
    --navy-2:  #13315c;
    --teal:    #14b8a6;
    --teal-d:  #0d9488;
    --bg:      #f4f6fb;
    --card:    #ffffff;
    --ink:     #1a2333;
    --muted:   #5b6677;
    --line:    #e3e8f0;
    --green:   #16a34a;
    --green-bg:#e8f7ee;
    --red:     #dc2626;
    --red-bg:  #fdeaea;
    --amber:   #d97706;
    --radius:  14px;
    --shadow:  0 6px 24px rgba(11, 37, 69, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
body.lang-ar {
    font-family: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

a { color: var(--teal-d); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { width: min(1080px, 92%); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
    background: var(--navy);
    color: #fff;
    position: sticky; top: 0; z-index: 50;
}
.header-inner {
    display: flex; align-items: center; gap: 1rem;
    padding-block: .75rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.6rem; }
.brand-logo { width: 48px; height: 48px; display: block; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.1rem; }
.brand-text small { color: #a9c2e8; font-size: .72rem; }

.main-nav { display: flex; align-items: center; gap: 1.1rem; margin-inline-start: auto; }
.main-nav a { color: #d7e3f7; font-size: .95rem; }
.main-nav a:hover { color: #fff; text-decoration: none; }
.btn-nav {
    background: var(--teal); color: #062c28 !important;
    padding: .4rem .9rem; border-radius: 999px; font-weight: 600;
}
.btn-nav:hover { background: #2dd4bf; }
.lang-link {
    border: 1px solid #34598f; padding: .3rem .7rem; border-radius: 8px;
}

.nav-toggle {
    display: none; margin-inline-start: auto;
    background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer;
}

/* ---------- Page ---------- */
.page { padding-block: 2.2rem 3rem; }
h1 { font-size: 1.9rem; margin: 0 0 .4rem; }
h2 { font-size: 1.35rem; margin: 1.6rem 0 .6rem; }
.lead { color: var(--muted); font-size: 1.05rem; margin-bottom: 1.6rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; cursor: pointer; border: 0;
    background: var(--teal-d); color: #fff; font-weight: 600;
    padding: .7rem 1.4rem; border-radius: 10px; font-size: 1rem;
    transition: background .15s;
}
.btn:hover { background: var(--teal); text-decoration: none; }
.btn-lg { padding: .9rem 1.8rem; font-size: 1.05rem; }
.btn-ghost {
    background: transparent; color: var(--navy-2);
    border: 1.5px solid var(--line);
}
.btn-ghost:hover { background: #eef2f8; color: var(--navy-2); }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.4rem 1.5rem;
}

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, var(--navy), var(--navy-2));
    color: #fff; border-radius: 20px; padding: 3rem 2.2rem;
    box-shadow: var(--shadow); margin-bottom: 2.4rem;
}
.hero h1 { font-size: 2.3rem; color: #fff; }
.hero p { color: #c7d6ee; font-size: 1.12rem; max-width: 56ch; }
.hero .btn { margin-top: 1.2rem; background: var(--teal); color: #062c28; }
.hero .btn:hover { background: #2dd4bf; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; }
.feature .ico { font-size: 1.8rem; }
.feature h3 { margin: .5rem 0 .3rem; font-size: 1.1rem; }
.feature p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- Scenario grid ---------- */
.scenario-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.2rem; }
.scenario-card { display: flex; flex-direction: column; }
.scenario-card h3 { margin: 0 0 .4rem; font-size: 1.18rem; }
.scenario-card p { color: var(--muted); flex: 1; margin: 0 0 1rem; }
.scenario-card .btn { align-self: flex-start; }

.badge {
    display: inline-block; font-size: .72rem; font-weight: 600;
    padding: .2rem .6rem; border-radius: 999px; margin-bottom: .7rem;
}
.badge.beginner { background: #e6f4ff; color: #0369a1; }
.badge.intermediate { background: #fff4e0; color: #b45309; }
.badge.advanced { background: #fde8ef; color: #be123c; }

.status-pill { font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; }
.status-pill.completed { background: var(--green-bg); color: var(--green); }
.status-pill.in_progress { background: #fff4e0; color: var(--amber); }
.status-pill.not_started { background: #eef2f8; color: var(--muted); }

/* ---------- Scenario detail ---------- */
.story-box {
    background: #f8fafc; border-inline-start: 4px solid var(--teal);
    border-radius: 10px; padding: 1.2rem 1.3rem; white-space: normal;
    font-size: 1.02rem; line-height: 1.8;
}
.lesson-box {
    background: #fefce8; border-inline-start: 4px solid var(--amber);
    border-radius: 10px; padding: 1.2rem 1.3rem; line-height: 1.8;
}

/* ---------- Quiz ---------- */
.question-block { margin-bottom: 1.4rem; }
.question-block .q-num { color: var(--teal-d); font-weight: 700; font-size: .85rem; }
.question-block h3 { margin: .2rem 0 .8rem; font-size: 1.1rem; }
.option {
    display: flex; align-items: flex-start; gap: .7rem;
    border: 1.5px solid var(--line); border-radius: 10px;
    padding: .8rem 1rem; margin-bottom: .6rem; cursor: pointer;
    transition: border-color .12s, background .12s;
}
.option:hover { border-color: var(--teal); background: #f0fdfa; }
.option input { margin-top: .25rem; accent-color: var(--teal-d); }
.option.correct { border-color: var(--green); background: var(--green-bg); }
.option.incorrect { border-color: var(--red); background: var(--red-bg); }

/* ---------- Result ---------- */
.score-banner {
    text-align: center; border-radius: 16px; padding: 1.8rem;
    margin-bottom: 1.8rem; color: #fff;
}
.score-banner.pass { background: linear-gradient(135deg, var(--green), #15803d); }
.score-banner.fail { background: linear-gradient(135deg, var(--red), #b91c1c); }
.score-banner .pct { font-size: 3rem; font-weight: 800; line-height: 1; }
.tag { font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 6px; }
.tag.ok { background: var(--green-bg); color: var(--green); }
.tag.no { background: var(--red-bg); color: var(--red); }

/* ---------- Forms ---------- */
.auth-wrap { max-width: 420px; margin-inline: auto; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .92rem; }
.field input, .field select, .field textarea {
    width: 100%; padding: .7rem .85rem; border: 1.5px solid var(--line);
    border-radius: 10px; font: inherit; background: #fff;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: var(--teal);
}
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .95rem; }
.alert.error { background: var(--red-bg); color: var(--red); }
.alert.info  { background: #e6f4ff; color: #0369a1; }
.muted-link { color: var(--muted); font-size: .92rem; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: .85rem 1rem; text-align: start; border-bottom: 1px solid var(--line); }
.table th { background: #f1f5fb; font-size: .85rem; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

.progress-bar { background: var(--line); border-radius: 999px; height: 12px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--teal); }

.btn-row { display: flex; gap: .7rem; flex-wrap: wrap; margin-top: 1.4rem; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .features { grid-template-columns: 1fr; }
    .nav-toggle { display: block; }
    .main-nav {
        display: none; position: absolute; inset-block-start: 100%; inset-inline: 0;
        background: var(--navy); flex-direction: column; align-items: stretch;
        gap: 0; padding: .5rem 0;
    }
    body.nav-open .main-nav { display: flex; }
    .main-nav a { padding: .8rem 1.2rem; }
    .hero { padding: 2rem 1.4rem; }
    .hero h1 { font-size: 1.8rem; }
}

/* =====================================================================
   Rich Content — hero images, inline media, video embeds
   ===================================================================== */

/* ---- Scenario hero image ---- */
.scenario-hero {
    margin: -1rem 0 1.5rem 0;
    border-radius: 12px;
    overflow: hidden;
    max-height: 360px;
}
.scenario-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ---- Scenario card with image ---- */
.scenario-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.scenario-card-img {
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    max-height: 180px;
    overflow: hidden;
}
.scenario-card-img img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}
.scenario-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.scenario-card-body .btn {
    margin-top: auto;
}

/* ---- Rich content (story/lesson rendered from TinyMCE) ---- */
.rich-content {
    line-height: 1.75;
}
.rich-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
}
.rich-content img.align-center,
.rich-content img[style*="margin-left: auto"] {
    margin-inline: auto;
}
.rich-content blockquote {
    border-inline-start: 4px solid #D4AF37;
    margin: 1.2rem 0;
    padding: .8rem 1.2rem;
    background: #f7f5ee;
    border-radius: 0 6px 6px 0;
    color: #333;
    font-style: italic;
}
[dir="rtl"] .rich-content blockquote {
    border-radius: 6px 0 0 6px;
}
.rich-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}
.rich-content table td,
.rich-content table th {
    border: 1px solid #ddd;
    padding: .5rem .75rem;
    text-align: start;
}
.rich-content table th {
    background: #0E3A6B;
    color: #fff;
}
.rich-content h2, .rich-content h3, .rich-content h4 {
    margin-top: 1.5rem;
    color: #0E3A6B;
}
.rich-content ul, .rich-content ol {
    padding-inline-start: 1.6rem;
    margin: .8rem 0;
}
.rich-content li {
    margin-bottom: .3rem;
}
.rich-content a {
    color: #1976D2;
    text-decoration: underline;
}
.rich-content hr {
    border: none;
    border-top: 2px solid #e5e5e5;
    margin: 1.5rem 0;
}

/* ---- Responsive video embeds ---- */
.rich-content iframe,
.rich-content video {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
}
.video-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    margin: 1rem 0;
    border-radius: 8px;
}
.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 8px;
}

/* =====================================================================
   ENHANCED UI — Animations, Hover Effects, Progress Elements
   ===================================================================== */

/* ---- Animations ---- */
@keyframes fadeInUp { from { opacity:0; transform:translateY(30px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeInLeft { from { opacity:0; transform:translateX(-30px); } to { opacity:1; transform:translateX(0); } }
@keyframes fadeInRight { from { opacity:0; transform:translateX(30px); } to { opacity:1; transform:translateX(0); } }
@keyframes countUp { from { opacity:0; transform:scale(0.5); } to { opacity:1; transform:scale(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; } }
@keyframes confettiFall { 0% { transform:translateY(-100vh) rotate(0deg); opacity:1; } 100% { transform:translateY(100vh) rotate(720deg); opacity:0; } }
@keyframes scoreReveal { 0% { stroke-dashoffset:283; } }
@keyframes slideDown { from { opacity:0; transform:translateY(-20px); } to { opacity:1; transform:translateY(0); } }
@keyframes float { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-8px); } }

.animate-in { animation: fadeInUp 0.6s ease-out both; }
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

/* ---- Enhanced Hero ---- */
.hero-enhanced {
    background: linear-gradient(135deg, #0B2D5A 0%, #0E3A6B 40%, #153d6f 70%, #1a4a7a 100%);
    padding: 4rem 2rem 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero-enhanced::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 50%, rgba(212,175,55,0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 50%, rgba(25,118,210,0.06) 0%, transparent 50%);
    pointer-events: none;
}
.hero-enhanced h1 {
    font-size: 2.8rem;
    color: #fff;
    margin-bottom: 0.5rem;
    position: relative;
}
.hero-enhanced h1 span { color: #D4AF37; }
.hero-enhanced .lead {
    color: rgba(255,255,255,0.85);
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto 2rem;
}

/* ---- Stats Counter Row ---- */
.stats-row {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}
.stat-item {
    text-align: center;
    animation: fadeInUp 0.6s ease-out both;
}
.stat-number {
    font-size: 2.5rem;
    font-weight: 800;
    color: #D4AF37;
    display: block;
    line-height: 1;
}
.stat-label {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    margin-top: 0.3rem;
}

/* ---- Feature Cards (Landing) ---- */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}
.feature-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid #e8edf2;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #0E3A6B, #D4AF37);
    opacity: 0;
    transition: opacity 0.3s;
}
.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(14,58,107,0.12);
    border-color: #D4AF37;
}
.feature-card:hover::before { opacity: 1; }
.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
    animation: float 3s ease-in-out infinite;
}
.feature-card h3 {
    color: #0E3A6B;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}
.feature-card p { color: #5b6677; line-height: 1.6; }

/* ---- Scenario Cards Enhanced ---- */
.scenario-card {
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e8edf2;
    position: relative;
    overflow: hidden;
}
.scenario-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #0E3A6B, #D4AF37);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}
.scenario-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 48px rgba(14,58,107,0.15);
}
.scenario-card:hover::after { transform: scaleX(1); }

/* ---- Difficulty badges with colors ---- */
.badge.beginner { background: #dcfce7; color: #16a34a; }
.badge.intermediate { background: #fef3cd; color: #92700c; }
.badge.advanced { background: #fde8e8; color: #dc2626; }

/* ---- Progress bar enhanced ---- */
.progress-bar-wrap {
    background: #e8edf2;
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    position: relative;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, #0E3A6B, #D4AF37);
    transition: width 1s ease-out;
    position: relative;
}
.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* ---- Progress Ring (Dashboard) ---- */
.progress-ring {
    display: inline-block;
    position: relative;
}
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring-circle {
    fill: none;
    stroke: #e8edf2;
    stroke-width: 6;
}
.progress-ring-value {
    fill: none;
    stroke: #D4AF37;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.5s ease-out;
}
.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.4rem;
    font-weight: 800;
    color: #0E3A6B;
}

/* ---- Score reveal animation ---- */
.score-circle {
    width: 160px;
    height: 160px;
    margin: 0 auto 1rem;
    position: relative;
}
.score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-circle-bg { fill: none; stroke: #e8edf2; stroke-width: 8; }
.score-circle-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    animation: scoreReveal 1.5s ease-out both;
}
.score-circle-fill.pass { stroke: #16a34a; }
.score-circle-fill.fail { stroke: #dc2626; }
.score-circle .score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.score-number {
    font-size: 2.5rem;
    font-weight: 800;
    display: block;
    animation: countUp 0.8s ease-out 0.5s both;
}
.score-number.pass { color: #16a34a; }
.score-number.fail { color: #dc2626; }
.score-label { font-size: 0.85rem; color: #5b6677; }

/* ---- Confetti ---- */
.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    z-index: 9999;
    animation: confettiFall 3s ease-in forwards;
    pointer-events: none;
}

/* ---- Dashboard stat cards ---- */
.dash-stat {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    border: 1px solid #e8edf2;
    transition: all 0.3s;
}
.dash-stat:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(14,58,107,0.1);
}
.dash-stat-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.dash-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: #0E3A6B;
}
.dash-stat-label { color: #5b6677; font-size: 0.85rem; }

/* ---- Activity timeline ---- */
.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f0f4f8;
    animation: slideDown 0.4s ease-out both;
}
.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #D4AF37;
    margin-top: 4px;
    flex-shrink: 0;
}
.timeline-dot.completed { background: #16a34a; }
.timeline-dot.in-progress { background: #1976D2; }
.timeline-content { flex: 1; }
.timeline-time { font-size: 0.8rem; color: #94a3b8; }

/* ---- Status pills enhanced ---- */
.status-pill {
    display: inline-block;
    padding: 0.25rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-pill.completed { background: #dcfce7; color: #16a34a; }
.status-pill.in_progress, .status-pill.in-progress { background: #dbeafe; color: #1976D2; }
.status-pill.not_started, .status-pill.not-started { background: #f1f5f9; color: #64748b; }

/* ---- CTA button enhanced ---- */
.btn-cta {
    display: inline-block;
    padding: 0.9rem 2.2rem;
    background: linear-gradient(135deg, #D4AF37, #E7C766);
    color: #0B2D5A;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(212,175,55,0.3);
}
.btn-cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(212,175,55,0.4);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hero-enhanced h1 { font-size: 2rem; }
    .stats-row { gap: 1.5rem; }
    .stat-number { font-size: 1.8rem; }
    .features-grid { grid-template-columns: 1fr; }
}
