/* ============================================================
   DANDALI — main.css
   Styles globaux, variables, composants réutilisables
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
    /* Couleurs principales */
    --red:         #E63946;
    --red-dark:    #C62D3B;
    --red-glow:    rgba(230,57,70,0.35);
    --gold:        #F4A261;
    --gold-light:  rgba(244,162,97,0.3);

    /* Fond & surfaces (mode sombre par défaut) */
    --bg:          #080A0F;
    --bg-2:        #0D1017;
    --bg-3:        #141820;
    --surface:     rgba(255,255,255,0.06);
    --surface-2:   rgba(255,255,255,0.10);
    --surface-3:   rgba(255,255,255,0.16);
    --border:      rgba(255,255,255,0.08);
    --border-2:    rgba(255,255,255,0.14);

    /* Texte */
    --text:        #FFFFFF;
    --text-2:      rgba(255,255,255,0.7);
    --text-3:      rgba(255,255,255,0.45);
    --text-4:      rgba(255,255,255,0.25);

    /* Layout */
    --nav-h:       72px;
    --top-h:       60px;
    --radius-sm:   10px;
    --radius-md:   16px;
    --radius-lg:   24px;
    --radius-xl:   32px;
    --radius-full: 999px;

    /* Ombres */
    --shadow-sm:   0 2px 8px rgba(0,0,0,0.4);
    --shadow-md:   0 4px 20px rgba(0,0,0,0.5);
    --shadow-lg:   0 8px 40px rgba(0,0,0,0.6);

    /* Transitions */
    --ease:        cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out:    cubic-bezier(0, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Mode clair ──────────────────────────────────────────── */
body.light-mode {
    --bg:        #F4F5F7;
    --bg-2:      #EAECF0;
    --bg-3:      #FFFFFF;
    --surface:   rgba(0,0,0,0.05);
    --surface-2: rgba(0,0,0,0.08);
    --surface-3: rgba(0,0,0,0.12);
    --border:    rgba(0,0,0,0.08);
    --border-2:  rgba(0,0,0,0.14);
    --text:      #0D1017;
    --text-2:    rgba(13,16,23,0.65);
    --text-3:    rgba(13,16,23,0.4);
    --text-4:    rgba(13,16,23,0.2);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
input, textarea, select { font-family: inherit; }

/* ── Utilitaires ─────────────────────────────────────────── */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.container {
    width: 100%;
    max-width: 480px;        /* Mobile-first, max tablette */
    margin: 0 auto;
    padding: 0 16px;
}

/* ── Logo texte ──────────────────────────────────────────── */
.logo-text {
    font-family: 'Syne', sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--red), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.15s var(--ease-spring), opacity 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.btn:active { transform: scale(0.95); }

.btn-primary {
    background: var(--red);
    color: #fff;
    box-shadow: 0 4px 16px var(--red-glow);
}
.btn-primary:hover { background: var(--red-dark); box-shadow: 0 6px 24px var(--red-glow); }

.btn-outline {
    background: var(--surface);
    border: 1px solid var(--border-2);
    color: var(--text);
    backdrop-filter: blur(12px);
}
.btn-outline:hover { background: var(--surface-2); }

.btn-ghost {
    background: transparent;
    color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface); }

.btn-block { width: 100%; }

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* ── Icône-bouton ────────────────────────────────────────── */
.icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s var(--ease-spring);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text);
}
.icon-btn:active { transform: scale(0.90); }
.icon-btn:hover  { background: var(--surface-2); }

/* Point de notification */
.notif-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 7px;
    height: 7px;
    background: var(--red);
    border-radius: 50%;
    border: 1.5px solid var(--bg);
}

/* ── Badge ───────────────────────────────────────────────── */
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    padding: 0 5px;
    margin-left: auto;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: calc(var(--nav-h) + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(20, 24, 32, 0.96);
    border: 1px solid var(--border-2);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease-out);
    backdrop-filter: blur(16px);
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow-md);
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 150;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease);
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.modal-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 32px 24px 40px;
    width: 100%;
    max-width: 480px;
    position: relative;
    transform: translateY(100%);
    transition: transform 0.35s var(--ease-out);
}
.modal-overlay.open .modal-card {
    transform: translateY(0);
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.2s;
}
.modal-logo {
    text-align: center;
    margin-bottom: 20px;
}
.modal-titre {
    font-family: 'Syne', sans-serif;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}
.modal-desc {
    font-size: 14px;
    color: var(--text-2);
    text-align: center;
    margin-bottom: 28px;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}
.modal-footer-text {
    font-size: 12px;
    color: var(--text-3);
    text-align: center;
}

/* ── Drawer latéral ──────────────────────────────────────── */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 80;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease);
}
.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease-out);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.drawer-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
}

.drawer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.drawer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-2);
}
.drawer-user-name {
    font-weight: 600;
    font-size: 15px;
}
.drawer-user-role {
    font-size: 12px;
    color: var(--text-3);
}

.drawer-menu {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}
.drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-2);
    transition: color 0.2s, background 0.2s;
    border-radius: 0;
}
.drawer-link:hover, .drawer-link.active {
    color: var(--text);
    background: var(--surface);
}
.drawer-link.highlight {
    color: var(--red);
}
.drawer-link.admin-link {
    color: var(--gold);
}
.drawer-link.logout-link {
    color: var(--red);
}

.drawer-separator {
    height: 1px;
    background: var(--border);
    margin: 8px 20px;
}

.drawer-theme {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    width: 100%;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.theme-toggle:hover { background: var(--surface-2); }

/* ── Navigation inférieure ───────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(8,10,15,0.88);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    height: var(--nav-h);
}

body.light-mode .bottom-nav {
    background: rgba(244,245,247,0.9);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, transform 0.12s var(--ease-spring);
    min-width: 48px;
    padding: 4px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    border: none;
    background: none;
    font-family: inherit;
}
.nav-item:active   { transform: scale(0.88); }
.nav-item.active   { color: var(--text); }
.nav-item.active .nav-icon-wrap svg { color: var(--red); }

.nav-icon-wrap {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Bouton publier */
.nav-publish { color: var(--text-2); }
.publish-circle {
    width: 50px;
    height: 50px;
    background: var(--red);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--red-glow);
    transition: transform 0.15s var(--ease-spring), box-shadow 0.2s;
    margin-bottom: 1px;
}
.nav-publish:active .publish-circle {
    transform: scale(0.90);
    box-shadow: 0 2px 10px var(--red-glow);
}

/* Badge notification nav */
.nav-notif-dot {
    position: absolute;
    top: -4px;
    right: -6px;
    background: var(--red);
    color: white;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 1.5px solid var(--bg);
}

/* ── Formulaires ─────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 7px;
    letter-spacing: 0.2px;
}

.form-control {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text);
    transition: border-color 0.2s, background 0.2s;
    outline: none;
    -webkit-appearance: none;
}
.form-control::placeholder { color: var(--text-4); }
.form-control:focus {
    border-color: rgba(230,57,70,0.5);
    background: var(--surface-2);
    box-shadow: 0 0 0 3px rgba(230,57,70,0.12);
}
.form-control.error {
    border-color: var(--red);
}

.form-error {
    font-size: 12px;
    color: var(--red);
    margin-top: 5px;
    display: none;
}
.form-error.show { display: block; }

.form-hint {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 5px;
}

/* ── Cards vidéo (pour les pages liste/search) ───────────── */
.video-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}
.video-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-2);
}
.video-card-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--bg-3);
}
.video-card-body {
    padding: 14px;
}
.video-card-title {
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.video-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-3);
}
.video-card-votes {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--red);
    font-weight: 600;
}

/* ── Pages structure ─────────────────────────────────────── */
.page-wrapper {
    min-height: 100vh;
    padding-top: calc(var(--top-h) + 8px);
    padding-bottom: calc(var(--nav-h) + 16px);
}

/* Barre top des pages internes */
.page-top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--top-h);
    background: rgba(8,10,15,0.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 50;
}
body.light-mode .page-top-bar {
    background: rgba(244,245,247,0.92);
}

.page-title {
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 0;
}
.page-link {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.2s;
}
.page-link.active, .page-link:hover {
    background: var(--red);
    border-color: var(--red);
    color: white;
}

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-3);
}
.avatar-sm  { width: 32px;  height: 32px;  }
.avatar-md  { width: 48px;  height: 48px;  }
.avatar-lg  { width: 72px;  height: 72px;  }
.avatar-xl  { width: 96px;  height: 96px;  }
.avatar-2xl { width: 120px; height: 120px; }

/* ── Alertes ─────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.25); color: #4ade80; }
.alert-error   { background: rgba(230,57,70,0.12); border: 1px solid rgba(230,57,70,0.25); color: #f87171; }
.alert-info    { background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.25); color: #60a5fa; }

/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 640px) {
    .container { padding: 0 24px; }
}
@media (min-width: 1024px) {
    body { font-size: 16px; }
    .container { max-width: 680px; }
}

/* ── Scrollbar custom (desktop) ─────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-fade-in  { animation: fadeIn  0.3s var(--ease) forwards; }
.animate-slide-up { animation: slideUp 0.4s var(--ease) forwards; }
.animate-pulse    { animation: pulse   1.5s ease-in-out infinite; }
.animate-spin     { animation: spin    1s linear infinite; }
