/*
 * ============================================================
 * Projet : تحدي الحروف (Tahadi Al Horouf)
 * Fichier : assets/css/global.css
 * Description : Feuille de style globale de l'application
 * Direction : RTL / Arabe
 * Compatible : Navigateurs modernes / LWS / PHP 8.2+
 * ============================================================
 */

/* ============================================================
   1. Variables globales
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;

    --secondary: #7c3aed;
    --secondary-dark: #6d28d9;
    --secondary-soft: #f5f3ff;

    --success: #16a34a;
    --success-dark: #15803d;

    --danger: #dc2626;
    --warning: #f59e0b;

    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-soft: #f1f5f9;

    --text-main: #334155;
    --text-dark: #1e293b;
    --text-heading: #1e3a8a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    --shadow-sm:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 2px 4px -1px rgba(0, 0, 0, 0.03);

    --shadow-md:
        0 10px 20px -5px rgba(0, 0, 0, 0.08);

    --shadow-lg:
        0 20px 30px -10px rgba(0, 0, 0, 0.12);

    --radius-sm: 10px;
    --radius-md: 18px;
    --radius-lg: 24px;

    --transition-fast: 0.2s ease;
    --transition: 0.25s ease;
}

/* ============================================================
   2. Reset global
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    margin: 0;
    padding: 0;
    min-height: 100%;
    direction: rtl;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) var(--bg-soft);
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;

    direction: rtl;
    text-align: right;

    background: var(--bg-main);
    color: var(--text-main);

    font-family:
        "Cairo",
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Tahoma,
        Arial,
        sans-serif;

    font-size: 16px;
    line-height: 1.6;

    overflow-x: hidden;

    display: flex;
    flex-direction: column;
}

body,
button,
input,
textarea,
select {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

img {
    height: auto;
    display: block;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    cursor: not-allowed;
}

ul,
ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

p {
    margin-top: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    color: var(--text-heading);
    font-weight: 800;
    line-height: 1.35;
}

a {
    color: inherit;
    text-decoration: none;
    transition:
        color var(--transition-fast),
        background-color var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

/* ============================================================
   3. Structure générale
   ============================================================ */
#main-content {
    width: 100%;
    flex: 1 0 auto;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: 20px;
}

/* ============================================================
   4. Navigation principale
   ============================================================ */
.main-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;

    width: 100%;
    min-height: 70px;

    display: flex;
    align-items: center;

    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;

    padding: 10px 20px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.nav-logo {
    flex: 0 0 auto;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    color: var(--text-heading);
    font-size: 24px;
    font-weight: 800;

    white-space: nowrap;
}

.nav-logo:hover {
    color: var(--primary);
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.nav-item,
.nav-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;
    padding: 8px 15px;

    border-radius: 10px;

    font-weight: 600;
    white-space: nowrap;
}

.nav-item {
    color: var(--text-main);
}

.nav-item:hover,
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.nav-link-btn {
    background: var(--primary);
    color: #ffffff;

    padding-inline: 24px;
    border-radius: 50px;

    box-shadow:
        0 4px 10px rgba(37, 99, 235, 0.20);
}

.nav-link-btn:hover,
.nav-link-btn.active {
    background: var(--primary-dark);
    color: #ffffff;

    box-shadow:
        0 6px 14px rgba(37, 99, 235, 0.30);

    transform: translateY(-1px);
}

.nav-toggle {
    display: none;

    width: 44px;
    height: 44px;

    padding: 0;
    border: 0;
    border-radius: 10px;

    background: transparent;
    color: var(--text-main);

    font-size: 28px;
    line-height: 1;
}

.nav-toggle:hover {
    background: var(--bg-soft);
    color: var(--primary);
}

/* ============================================================
   5. Boutons globaux
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    min-height: 48px;
    padding: 12px 35px;

    border: 0;
    border-radius: 100px;

    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;

    text-align: center;
    text-decoration: none;

    transition:
        background-color var(--transition-fast),
        color var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast),
        opacity var(--transition-fast);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;

    box-shadow:
        0 4px 14px rgba(37, 99, 235, 0.30);
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #ffffff;

    box-shadow:
        0 6px 20px rgba(37, 99, 235, 0.40);
}

.btn-secondary {
    background: #ffffff;
    color: var(--primary);

    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-color: var(--primary);
}

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

.btn-success:hover {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-warning {
    background: var(--warning);
    color: #ffffff;
}

.btn.loading,
.btn:disabled {
    opacity: 0.65;
    pointer-events: none;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   6. Formulaires globaux
   ============================================================ */
input,
textarea,
select {
    max-width: 100%;
    color: var(--text-main);

    background: #ffffff;
    border: 2px solid var(--border-dark);
    border-radius: var(--radius-sm);

    outline: none;

    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background-color var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-light);
}

textarea {
    resize: vertical;
}

/* ============================================================
   7. Cards générales
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card-hover {
    transition:
        transform var(--transition),
        box-shadow var(--transition);
}

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

/* ============================================================
   8. Alertes
   ============================================================ */
.alert {
    width: 100%;
    margin: 20px 0;
    padding: 14px 18px;

    border-radius: 12px;

    font-weight: 600;
    line-height: 1.6;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ============================================================
   9. Footer
   ============================================================ */
.main-footer {
    width: 100%;
    flex: 0 0 auto;

    margin-top: 60px;

    background: #0f172a;
    color: #ffffff;

    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.footer-container {
    width: 100%;
    max-width: 1200px;

    margin-inline: auto;
    padding: 50px 20px;

    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(220px, 1fr));

    gap: 40px;
}

.footer-section {
    min-width: 0;
}

.footer-section h4,
.footer-section h6 {
    margin-bottom: 15px;
    color: #ffffff;
    font-weight: 700;
}

.footer-section h4 {
    font-size: 20px;
}

.footer-section h6 {
    display: inline-block;

    padding-bottom: 6px;

    border-bottom: 2px solid var(--primary);

    font-size: 16px;
}

.footer-section p,
.footer-section li {
    color: #cbd5e1;
    font-size: 15px;
}

.footer-section p {
    line-height: 1.8;
}

.footer-section ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-section a {
    color: #cbd5e1;
}

.footer-section a:hover {
    color: #ffffff;
    padding-right: 4px;
}

.sub-text {
    opacity: 0.7;
    font-size: 13px !important;
}

/* ============================================================
   10. NoScript
   ============================================================ */
.noscript-alert {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;

    z-index: 9999;

    width: 100%;
    padding: 12px;

    background: #fef3c7;
    color: #92400e;

    border-top: 1px solid #fde68a;

    text-align: center;
    font-size: 15px;
    font-weight: 700;
}

/* ============================================================
   11. Accessibilité
   ============================================================ */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
}

.visually-hidden {
    position: absolute !important;

    width: 1px !important;
    height: 1px !important;

    padding: 0 !important;
    margin: -1px !important;

    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;

    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================================
   12. Scrollbar
   ============================================================ */
html,
* {
    scrollbar-width: thin;
    scrollbar-color:
        var(--border-dark)
        var(--bg-soft);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ============================================================
   13. Responsive
   ============================================================ */
@media (max-width: 768px) {

    .container {
        padding-inline: 15px;
    }

    .main-navbar {
        min-height: 64px;
        padding-block: 5px;
    }

    .nav-container {
        padding-inline: 15px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        display: none;

        width: 100%;
        flex-direction: column;
        align-items: stretch;

        margin-top: 8px;
        padding: 15px;

        background: #ffffff;
        border: 1px solid var(--border);
        border-radius: 12px;

        box-shadow: var(--shadow-md);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-item,
    .nav-link-btn {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .footer-container {
        grid-template-columns: 1fr;
        gap: 35px;
        padding: 40px 20px;
        text-align: center;
    }

    .footer-section h6 {
        display: block;
        width: fit-content;
        max-width: 150px;
        margin-inline: auto;
        margin-bottom: 15px;
    }

    .footer-section a:hover {
        padding-right: 0;
    }

    .btn {
        min-height: 46px;
        padding-inline: 25px;
    }
}

@media (max-width: 420px) {

    body {
        font-size: 15px;
    }

    .nav-logo {
        font-size: 20px;
    }

    .btn {
        width: 100%;
    }

    .footer-container {
        padding-inline: 15px;
    }
}

/* ============================================================
   14. Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .btn:hover,
    .card-hover:hover,
    .nav-link-btn:hover {
        transform: none !important;
    }
}
/* ============================================================
   V34 — Design premium / Mobile First
   ============================================================ */
:root {
    --v35-primary: #2563eb;
    --v35-secondary: #7c3aed;
    --v35-accent: #06b6d4;
    --v35-success: #16a34a;
    --v35-surface: rgba(255,255,255,.92);
    --v35-glass: rgba(255,255,255,.78);
}

body {
    background:
        radial-gradient(circle at 15% 10%, rgba(37,99,235,.08), transparent 28%),
        radial-gradient(circle at 85% 18%, rgba(124,58,237,.08), transparent 30%),
        var(--bg-main);
}

.btn, button, input, select, textarea, .feature-card, .step-card, .summary-card,
.stat-card, .answer-card, .room-home-button {
    transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease, background-color .22s ease;
}

.btn:hover, button:hover:not(:disabled), .room-home-button:hover {
    transform: translateY(-2px);
}

.btn:active, button:active:not(:disabled), .room-home-button:active { transform: translateY(0); }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 3px solid rgba(37,99,235,.28);
    outline-offset: 3px;
}

@keyframes v35Float {
    0%,100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

@keyframes v35Glow {
    0%,100% { box-shadow: 0 10px 28px rgba(37,99,235,.12); }
    50% { box-shadow: 0 16px 38px rgba(124,58,237,.20); }
}

.v35-animate { animation: v35Float 4s ease-in-out infinite; }
.v35-glow { animation: v35Glow 3.2s ease-in-out infinite; }

@media (max-width: 700px) {
    body { font-size: 15px; }
    .container { padding-inline: 12px; }
    .main-navbar { min-height: 60px; }
    .nav-container { padding: 8px 12px; gap: 10px; }
    .nav-logo { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition-duration: .01ms !important; }
}

/* V42 : statistiques visiteurs et pays des joueurs */
.admin-live-statistics .stats-grid { margin-bottom: 1rem; }
.live-stat-card { position: relative; }
.live-stat-card small { display:block; margin-top:.35rem; opacity:.7; }
.user-country { white-space: nowrap; font-weight: 600; }
.user-country span:first-child { font-size: 1.25rem; margin-inline-end: .35rem; }

/* V42 : compteur public discret */
.footer-live-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .65rem;
    flex-wrap: wrap;
    width: 100%;
    margin: 0 auto 1rem;
}
.footer-live-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .45rem .8rem;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    font-size: .9rem;
}
@media (max-width: 600px) {
    .footer-live-pill { width: 100%; justify-content: center; }
}

/* ============================================================
   V52 — نظام بصري موحد لجميع الصفحات العامة
   ============================================================ */
html{scroll-behavior:smooth}body{min-width:320px}
.main-footer{margin-top:auto}
button,.btn,input,select,textarea{font-family:inherit}
.session-nav,.game-session-nav{max-width:1180px;margin:12px auto 18px;padding-inline:4px}
.session-nav a,.game-session-nav a{min-height:52px;min-width:160px;font-size:16px;border-radius:15px}
@media(max-width:600px){.session-nav,.game-session-nav{width:calc(100% - 16px);gap:8px}.session-nav a,.game-session-nav a{flex:1 1 calc(50% - 8px);min-width:0;min-height:50px;font-size:15px}}
