/* ==========================================================================
   CHRONIQUES D'ELVARIA - STYLES PARTAGÉS (FRONTEND/SHARED)
   Variables, Reset, Layout Global & Composants Réutilisables
   ========================================================================== */

:root {
    --gold: #d4af37;
    --gold-light: #f7e7a9;
    --gold-dark: #997819;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --parchment: #f4e6c8;
    --parchment-muted: #c8b99d;
    --dark-wood: #22150c;
    --wood-translucent: rgba(35, 22, 12, 0.88);
    --card-bg: rgba(28, 18, 10, 0.92);
    --night-overlay: rgba(12, 14, 25, 0.90);
    --border-gold: 1px solid var(--gold);
    --border-gold-ornate: 2px solid var(--gold);
    --shadow-epic: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(212, 175, 55, 0.2);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition-smooth: all 0.25s cubic-bezier(0.2, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & STRUCTURE DE BASE
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    min-height: 100vh;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'MedievalSharp', cursive, 'Cinzel', Georgia, serif;
    background: url('../static/bg-day.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--parchment);
    transition: background 0.4s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Thème jour */
body.theme-jour {
    background: url('../static/bg-day.png') no-repeat center center fixed;
    background-size: cover;
}

/* Thème nuit */
body.theme-nuit {
    background: url('../static/bg-night.png') no-repeat center center fixed;
    background-size: cover;
}

body.theme-nuit .site-header,
body.theme-nuit footer {
    background-color: rgba(18, 14, 26, 0.95);
    border-color: #a88be6;
}

body.theme-nuit nav {
    background-color: rgba(12, 10, 20, 0.92);
}

body.theme-nuit .site-title,
body.theme-nuit .card h2,
body.theme-nuit .theme-gold {
    color: #e5d4ff;
    text-shadow: 0 0 12px rgba(168, 139, 230, 0.4);
}

body.theme-nuit .card,
body.theme-nuit .container,
body.theme-nuit .lore-card,
body.theme-nuit .search-item-card,
body.theme-nuit .admin-form-box,
body.theme-nuit .profile-card,
body.theme-nuit .wip-box,
body.theme-nuit .cosmology-card {
    border-color: #8a6ec7;
    background-color: rgba(15, 12, 28, 0.90);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(138, 110, 199, 0.2);
}

/* Scrollbar médiévale */
::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: rgba(20, 12, 6, 0.9);
}

::-webkit-scrollbar-thumb {
    background: var(--gold-dark);
    border-radius: 4px;
    border: 1px solid var(--gold);
}

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

/* ==========================================================================
   LAYOUT : HEADER, NAV, FOOTER, CONTENEUR
   ========================================================================== */

.site-header {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0.9rem 0;
    background: linear-gradient(180deg, rgba(45, 25, 15, 0.97) 0%, rgba(25, 15, 8, 0.95) 100%);
    border-bottom: 3px solid var(--gold);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1300px;
    padding: 0 2rem;
    gap: 1.5rem;
}

.site-title {
    margin: 0;
    font-size: 2.2rem;
    color: var(--gold);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 0 15px var(--gold-glow);
    white-space: nowrap;
    text-align: center;
    letter-spacing: 1px;
}

.site-title a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.site-title a:hover {
    color: var(--gold-light);
    text-shadow: 0 0 20px var(--gold);
}

.search-container {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 320px;
}

.search-container form {
    display: flex;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    border: 1px solid var(--gold);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
    transition: var(--transition-smooth);
}

.search-container form:focus-within {
    border-color: var(--gold-light);
    box-shadow: 0 0 10px var(--gold-glow);
}

.search-container input[type="text"] {
    flex: 1;
    padding: 0.55rem 0.9rem;
    font-family: inherit;
    background: none;
    border: none;
    color: var(--parchment);
    font-size: 0.95rem;
    outline: none;
}

.search-container input::placeholder {
    color: var(--parchment-muted);
    font-style: italic;
}

.search-container button {
    padding: 0 0.9rem;
    background: rgba(212, 175, 55, 0.2);
    border: none;
    border-left: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--gold);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition-smooth);
}

.search-container button:hover {
    background-color: rgba(212, 175, 55, 0.4);
    color: #fff;
}

.profile-and-theme {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: flex-end;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.25) 0%, rgba(140, 105, 20, 0.25) 100%);
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.header-btn:hover {
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.45) 0%, rgba(160, 120, 25, 0.45) 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--gold-glow);
}

.theme-button {
    font-size: 1.25rem;
    padding: 0.45rem 0.75rem;
    line-height: 1;
}

/* Barre de navigation */
nav {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    background: linear-gradient(180deg, rgba(25, 16, 9, 0.96) 0%, rgba(18, 10, 5, 0.94) 100%);
    padding: 0.4rem 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 90;
}

nav a {
    color: var(--parchment);
    text-decoration: none;
    margin: 0.2rem 0.6rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    position: relative;
    transition: var(--transition-smooth);
}

nav a:hover,
nav a.active {
    color: var(--gold-light);
    background: rgba(212, 175, 55, 0.22);
    box-shadow: inset 0 0 10px rgba(212, 175, 55, 0.3);
}

nav a.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold);
}

/* Conteneur et Hero */
.container {
    max-width: 1240px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--wood-translucent);
    border: var(--border-gold-ornate);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-epic);
    backdrop-filter: blur(5px);
    box-sizing: border-box;
}

.page-hero {
    text-align: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.page-hero h1,
.page-hero h2 {
    font-size: 2.5rem;
    color: var(--gold);
    margin: 0 0 0.5rem 0;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8), 0 0 15px var(--gold-glow);
}

.page-hero p {
    font-size: 1.2rem;
    color: var(--parchment);
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Footer */
footer {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 1.5rem 1rem;
    background: linear-gradient(180deg, rgba(30, 18, 10, 0.96) 0%, rgba(18, 10, 5, 0.98) 100%);
    border-top: 3px solid var(--gold);
    margin-top: auto;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
    z-index: 50;
}

footer p {
    margin: 0.3rem 0;
    color: var(--parchment);
    font-size: 0.95rem;
}

.footer-links {
    margin-top: 0.5rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--gold);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.footer-links a:hover {
    color: var(--gold-light);
    text-decoration: underline;
}

/* ==========================================================================
   COMPOSANTS : BADGES, TAGS, BOUTONS, STATS, TOASTS
   ========================================================================== */

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-univers    { background: rgba(30, 80, 150, 0.45); color: #8ec3ff; border-color: #5c9eff; }
.badge-personnage { background: rgba(160, 40, 40, 0.45); color: #ff9e9e; border-color: #ff6464; }
.badge-race       { background: rgba(35, 130, 70, 0.45); color: #9effb8; border-color: #52e67f; }
.badge-classe     { background: rgba(110, 45, 160, 0.45); color: #e3a9ff; border-color: #cb7aff; }
.badge-objet      { background: rgba(170, 100, 20, 0.45); color: #ffd699; border-color: #f7a93b; }
.badge-regle      { background: rgba(80, 90, 100, 0.45); color: #e0e5eb; border-color: #9cb0c4; }
.badge-campagne   { background: rgba(50, 30, 110, 0.45); color: #bca6ff; border-color: #9472ff; }
.badge-musique    { background: rgba(20, 120, 130, 0.45); color: #92f7ff; border-color: #4ce5f5; }
.badge-autre      { background: rgba(90, 80, 70, 0.45); color: #eae4dd; border-color: #baa898; }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.tag-pill {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--gold-light);
    border-radius: 12px;
    padding: 0.15rem 0.55rem;
    font-size: 0.78rem;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.tag-pill:hover {
    background: var(--gold);
    color: #000;
}

.btn-medieval {
    background: linear-gradient(180deg, #d4af37 0%, #997819 100%);
    color: #1a0f07;
    font-weight: bold;
    border: 1px solid var(--gold-light);
    border-radius: var(--radius-sm);
    padding: 0.7rem 1.4rem;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-medieval:hover {
    background: linear-gradient(180deg, #f7e7a9 0%, #b89124 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(212, 175, 55, 0.4);
}

.btn-medieval.btn-secondary {
    background: rgba(0, 0, 0, 0.6);
    color: var(--parchment);
    border-color: var(--gold);
}

.btn-medieval.btn-secondary:hover {
    background: rgba(212, 175, 55, 0.25);
    color: #fff;
}

.btn-medieval.btn-danger {
    background: linear-gradient(180deg, #b32d2e 0%, #701c1c 100%);
    color: #fff;
    border-color: #ff6e6e;
}

.btn-medieval.btn-danger:hover {
    background: linear-gradient(180deg, #d93839 0%, #8a2323 100%);
    box-shadow: 0 6px 15px rgba(217, 56, 57, 0.4);
}

.stats-banner {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.stat-pill {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid var(--gold);
    border-radius: 20px;
    padding: 0.4rem 1.2rem;
    font-size: 0.95rem;
    color: var(--gold-light);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.toast {
    background: rgba(24, 15, 8, 0.95);
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1.4rem;
    color: var(--parchment);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8), 0 0 15px var(--gold-glow);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    animation: toastSlideIn 0.3s ease;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media screen and (max-width: 900px) {
    .header-content {
        flex-direction: column;
        padding: 0.8rem 1rem;
        gap: 0.8rem;
    }

    .site-title {
        font-size: 1.8rem;
    }

    .search-container {
        max-width: 100%;
        width: 100%;
    }

    .profile-and-theme {
        width: 100%;
        justify-content: center;
    }
}

@media screen and (max-width: 600px) {
    nav {
        gap: 0.2rem;
        padding: 0.4rem;
    }

    nav a {
        font-size: 0.9rem;
        padding: 0.35rem 0.6rem;
        margin: 0.15rem;
    }

    .container {
        padding: 1rem;
        margin: 1rem auto;
    }

    .page-hero h1,
    .page-hero h2 {
        font-size: 1.8rem;
    }
}

/* ==========================================================================
   AUTHENTIFICATION, ROLES RBAC & MODALES SÉCURISÉES
   ========================================================================== */

.user-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.88rem;
    font-family: inherit;
    font-weight: bold;
    letter-spacing: 0.5px;
    border: 1px solid var(--gold);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    background: rgba(20, 12, 6, 0.85);
    white-space: nowrap;
}

.role-admin {
    border-color: #ffd700;
    color: #ffe680;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
    background: linear-gradient(135deg, rgba(40, 25, 5, 0.95), rgba(70, 45, 10, 0.95));
}

.role-mj {
    border-color: #b388ff;
    color: #e0d4ff;
    box-shadow: 0 0 10px rgba(179, 136, 255, 0.35);
    background: linear-gradient(135deg, rgba(30, 18, 55, 0.95), rgba(45, 25, 80, 0.95));
}

.role-joueur {
    border-color: #4dd0e1;
    color: #b2ebf2;
    box-shadow: 0 0 10px rgba(77, 208, 225, 0.35);
    background: linear-gradient(135deg, rgba(10, 35, 40, 0.95), rgba(15, 55, 60, 0.95));
}

.header-btn-logout {
    border-color: rgba(255, 90, 90, 0.5) !important;
    color: #ff9e9e !important;
    background: rgba(40, 10, 10, 0.6) !important;
}

.header-btn-logout:hover {
    border-color: #ff5a5a !important;
    box-shadow: 0 0 12px rgba(255, 90, 90, 0.5) !important;
    transform: translateY(-2px);
}

.header-btn-login {
    border-color: var(--gold) !important;
    color: var(--gold-light) !important;
    background: rgba(45, 30, 12, 0.8) !important;
    box-shadow: 0 0 8px var(--gold-glow);
}

/* Modale bloquante de premier changement de mot de passe */
.auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 6, 4, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    animation: fadeIn 0.3s ease;
    padding: 1.5rem;
}

.auth-modal-card {
    background: linear-gradient(180deg, rgba(38, 24, 14, 0.98), rgba(22, 14, 8, 0.98));
    border: 2px solid var(--gold);
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 25px var(--gold-glow);
    max-width: 500px;
    width: 100%;
    padding: 2.2rem;
    color: var(--parchment);
    position: relative;
}

.auth-modal-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 0.8rem;
}

.auth-modal-icon {
    font-size: 2rem;
}

.auth-modal-header h3 {
    margin: 0;
    color: var(--gold-light);
    font-size: 1.4rem;
}

.auth-modal-desc {
    color: var(--parchment-muted);
    font-size: 0.96rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.auth-modal-form .auth-form-group {
    margin-bottom: 1.2rem;
}

.auth-form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.92rem;
    color: var(--gold-light);
}

.auth-form-group input,
.auth-form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gold);
    background: rgba(15, 10, 6, 0.7);
    color: var(--parchment);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition-smooth);
}

.auth-form-group input:focus,
.auth-form-group select:focus {
    outline: none;
    border-color: #ffe680;
    box-shadow: 0 0 10px var(--gold-glow);
}

.auth-modal-error {
    background: rgba(120, 20, 20, 0.4);
    border: 1px solid #ff6b6b;
    color: #ffb4b4;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.temp-password-badge {
    background: rgba(212, 175, 55, 0.15);
    border: 1px dashed var(--gold);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1.2rem 0;
    text-align: center;
}

.temp-password-code {
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffe680;
    letter-spacing: 2px;
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-sm);
    user-select: all;
    margin: 0.5rem 0;
}
