/* ======================================================================
   CHAUMAO PHOTOS — Espace Client Privé
   Thème premium sombre, style Apple
   ====================================================================== */

/* ──────────────────────────────────────────────────────────────────────
   Variables globales
   ────────────────────────────────────────────────────────────────────── */
:root {
    --bg-color: #000000;
    --surface-color: #0b0b0c;
    --border-color: #1d1d1f;
    --text-primary: #ffffff;
    --text-secondary: #86868b;
    --text-muted: #515154;
    --accent-color: #ffffff;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Glassmorphisme */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-blur: 40px;

    /* Courbe d'animation premium */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);

    /* Espacements */
    --header-height: 72px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────────────────
   Barre de défilement personnalisée
   ────────────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ──────────────────────────────────────────────────────────────────────
   Animations @keyframes
   ────────────────────────────────────────────────────────────────────── */

/* Flottement des orbes d'arrière-plan */
@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -50px) scale(1.05);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
    75% {
        transform: translate(15px, 40px) scale(1.02);
    }
}

/* Apparition des éléments de galerie */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Pulsation pour les états de chargement */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

/* Effet shimmer pour le skeleton loading */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Rotation du loader bouton */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Secousse pour erreur */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-6px); }
    30%, 70% { transform: translateX(6px); }
}

/* Fade in de la carte login */
@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Barre de progression shimmer */
@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* ──────────────────────────────────────────────────────────────────────
   Orbes flottantes — Arrière-plan décoratif
   ────────────────────────────────────────────────────────────────────── */
.bg-orbs {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.07;
    will-change: transform;
}

.orb--1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #ffffff 0%, transparent 70%);
    top: -15%;
    left: -10%;
    animation: float 20s ease-in-out infinite;
}

.orb--2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #a0a0a0 0%, transparent 70%);
    top: 50%;
    right: -8%;
    animation: float 25s ease-in-out infinite 3s;
}

.orb--3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #c0c0c0 0%, transparent 70%);
    bottom: -10%;
    left: 30%;
    animation: float 18s ease-in-out infinite 6s;
}

.orb--4 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, #ffffff 0%, transparent 70%);
    top: 20%;
    right: 25%;
    animation: float 22s ease-in-out infinite 2s;
}

.orb--5 {
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, #d0d0d0 0%, transparent 70%);
    bottom: 30%;
    left: 10%;
    animation: float 16s ease-in-out infinite 4s;
}

/* ──────────────────────────────────────────────────────────────────────
   Vues — Transitions entre login et galerie
   ────────────────────────────────────────────────────────────────────── */
.view {
    position: relative;
    z-index: 1;
    transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
}

.view[aria-hidden="true"] {
    display: none;
    opacity: 0;
    transform: translateY(20px);
}

/* Classe pour l'animation de sortie */
.view--exiting {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* ──────────────────────────────────────────────────────────────────────
   VUE CONNEXION
   ────────────────────────────────────────────────────────────────────── */
.view--login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

/* Carte glassmorphisme */
.login-card {
    width: 100%;
    max-width: 440px;
    padding: 56px 48px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    text-align: center;
    animation: cardReveal 0.8s var(--ease-out-expo) forwards;
}

.login-card__logo {
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card .logo-img {
    height: 60px;
    width: auto;
    transition: transform 0.6s var(--ease-out-expo);
}

.login-card:hover .logo-img {
    transform: scale(1.03);
}

/* Sous-titre */
.login-card__subtitle {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-bottom: 40px;
    margin-top: 16px;
    letter-spacing: 0.04em;
}

/* Formulaire */
.login-card__form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Groupe input */
.input-group {
    position: relative;
}

.input-code {
    width: 100%;
    padding: 16px 0;
    font-family: var(--font-family);
    font-size: 1.125rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    outline: none;
    text-align: center;
    transition: border-color 0.4s var(--ease-out-expo);
    caret-color: var(--text-primary);
}

.input-code::placeholder {
    color: var(--text-muted);
    font-weight: 300;
    letter-spacing: 0.04em;
    font-size: 0.95rem;
}

/* Ligne animée sous l'input */
.input-line {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 1px;
    background: var(--text-primary);
    transition: width 0.4s var(--ease-out-expo), left 0.4s var(--ease-out-expo);
}

.input-code:focus ~ .input-line {
    width: 100%;
    left: 0;
}

/* État erreur sur l'input */
.input-code.input-code--error {
    border-bottom-color: #ff453a;
    animation: shake 0.5s var(--ease-out-expo);
}

/* Message d'erreur */
.login-card__error {
    font-size: 0.8rem;
    color: #ff453a;
    min-height: 1.2em;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.login-card__error.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Bouton principal */
.btn-primary {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 32px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #000;
    background: var(--text-primary);
    border: none;
    border-radius: 100px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.4s var(--ease-out-expo), box-shadow 0.4s var(--ease-out-expo);
}

.btn-primary:hover {
    transform: scale(1.03);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.15);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary__loader {
    display: none;
    animation: spin 0.8s linear infinite;
}

/* État de chargement */
.btn-primary.loading .btn-primary__text {
    opacity: 0;
}

.btn-primary.loading .btn-primary__loader {
    display: block;
    position: absolute;
}

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

.back-to-home {
    align-self: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.3s ease, transform 0.3s ease;
    margin-top: 4px;
}

.back-to-home:hover {
    color: var(--text-primary);
    transform: translateX(-4px);
}

/* Mention légale */
.login-card__legal {
    margin-top: 32px;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ──────────────────────────────────────────────────────────────────────
   VUE GALERIE
   ────────────────────────────────────────────────────────────────────── */

/* En-tête galerie */
.gallery-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 40px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.gallery-header__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* Marque dans l'en-tête */
.gallery-header__brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    white-space: nowrap;
}

.gallery-header__brand .logo-img {
    height: 24px;
    width: auto;
    transition: transform 0.6s var(--ease-out-expo);
}

.gallery-header__brand:hover .logo-img {
    transform: scale(1.03);
}

.gallery-header__sep {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.gallery-header__title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-header__right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.gallery-header__count {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Bouton télécharger tout */
.btn-download-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-family: var(--font-family);
    font-size: 0.78rem;
    font-weight: 500;
    color: #000;
    background: var(--text-primary);
    border: none;
    border-radius: 100px;
    cursor: pointer;
    transition: transform 0.3s var(--ease-out-expo), box-shadow 0.3s var(--ease-out-expo);
    white-space: nowrap;
}

.btn-download-all:hover {
    transform: scale(1.04);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.12);
}

.btn-download-all:active {
    transform: scale(0.97);
}

/* Bouton déconnexion */
.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: var(--font-family);
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
    white-space: nowrap;
}

.btn-logout:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.04);
}

/* ──────────────────────────────────────────────────────────────────────
   Indicateur de téléchargement ZIP
   ────────────────────────────────────────────────────────────────────── */
.download-progress {
    position: fixed;
    top: calc(var(--header-height) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 200;
    padding: 16px 28px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--ease-out-expo), transform 0.4s var(--ease-out-expo);
}

.download-progress.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.download-progress__bar {
    width: 240px;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.download-progress__fill {
    height: 100%;
    width: 30%;
    background: var(--text-primary);
    border-radius: 2px;
    animation: progressShimmer 1.5s ease-in-out infinite;
}

.download-progress__text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ──────────────────────────────────────────────────────────────────────
   Grille masonry
   ────────────────────────────────────────────────────────────────────── */
.gallery-grid {
    column-count: 3;
    column-gap: 16px;
    padding: 24px 40px 80px;
}

/* Carte photo */
.photo-card {
    position: relative;
    display: inline-block;
    width: 100%;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    break-inside: avoid;

    /* Animation d'apparition échelonnée */
    opacity: 0;
    animation: fadeInUp 0.7s var(--ease-out-expo) forwards;
}

.photo-card img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.6s var(--ease-out-expo);
    will-change: transform;
}

/* Effet zoom au survol */
.photo-card:hover img {
    transform: scale(1.04);
}

/* Overlay de téléchargement au survol */
.photo-card__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 16px;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.6) 0%,
        rgba(0, 0, 0, 0) 60%
    );
    opacity: 0;
    transition: opacity 0.4s var(--ease-out-expo);
}

.photo-card:hover .photo-card__overlay {
    opacity: 1;
}

/* Bouton de téléchargement individuel */
.photo-card__download {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: transform 0.3s var(--ease-out-expo), background 0.3s ease;
}

.photo-card__download:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.25);
}

/* ──────────────────────────────────────────────────────────────────────
   Skeleton loading
   ────────────────────────────────────────────────────────────────────── */
.gallery-skeleton {
    column-count: 3;
    column-gap: 16px;
    padding: 24px 40px;
}

.gallery-skeleton[aria-hidden="true"] {
    display: none;
}

.gallery-skeleton.visible {
    display: block;
}

.skeleton-card {
    display: inline-block;
    width: 100%;
    height: 280px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 25%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.03) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    break-inside: avoid;
}

.skeleton-card:nth-child(2) { height: 340px; animation-delay: 0.1s; }
.skeleton-card:nth-child(3) { height: 260px; animation-delay: 0.2s; }
.skeleton-card:nth-child(4) { height: 320px; animation-delay: 0.3s; }
.skeleton-card:nth-child(5) { height: 300px; animation-delay: 0.15s; }
.skeleton-card:nth-child(6) { height: 250px; animation-delay: 0.25s; }

/* ──────────────────────────────────────────────────────────────────────
   LIGHTBOX
   ────────────────────────────────────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--ease-out-expo);
}

.lightbox[aria-hidden="false"] {
    opacity: 1;
    pointer-events: auto;
}

/* Fond flouté */
.lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

/* Barre supérieure */
.lightbox__topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
}

.lightbox__counter {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.lightbox__actions {
    display: flex;
    gap: 8px;
}

.lightbox__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s var(--ease-out-expo);
}

.lightbox__btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.08);
}

/* Conteneur de l'image */
.lightbox__image-wrap {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 80px 100px;
}

.lightbox__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    transition: opacity 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox__image.loading {
    opacity: 0.3;
    animation: pulse 1.2s ease-in-out infinite;
}

/* Flèches de navigation */
.lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 10;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s var(--ease-out-expo);
}

.lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.12);
}

.lightbox__nav:active {
    transform: translateY(-50%) scale(0.92);
}

.lightbox__nav--prev {
    left: 24px;
}

.lightbox__nav--next {
    right: 24px;
}

/* ──────────────────────────────────────────────────────────────────────
   Responsive — Tablette (≤ 768px)
   ────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .gallery-grid,
    .gallery-skeleton {
        column-count: 2;
        padding: 16px 20px 60px;
    }

    .gallery-header {
        padding: 0 20px;
        gap: 8px;
    }

    .gallery-header__brand {
        display: none;
    }

    .gallery-header__sep {
        display: none;
    }

    .btn-download-all span,
    .btn-logout span {
        display: none;
    }

    .btn-download-all,
    .btn-logout {
        padding: 8px 12px;
    }

    .lightbox__image-wrap {
        padding: 70px 20px;
    }

    .lightbox__nav {
        width: 42px;
        height: 42px;
    }

    .lightbox__nav--prev {
        left: 12px;
    }

    .lightbox__nav--next {
        right: 12px;
    }

    .login-card {
        padding: 40px 28px;
    }
}

/* ──────────────────────────────────────────────────────────────────────
   Responsive — Mobile (≤ 480px)
   ────────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .gallery-grid,
    .gallery-skeleton {
        column-count: 1;
        padding: 12px 16px 60px;
    }

    .gallery-header {
        padding: 0 16px;
        height: 60px;
    }

    .gallery-header__title {
        font-size: 0.8rem;
    }

    .gallery-header__count {
        display: none;
    }

    .login-card {
        padding: 32px 20px;
        border-radius: 20px;
    }

    .logo-text {
        font-size: 1.4rem;
    }

    .input-code {
        font-size: 1rem;
    }

    .lightbox__nav {
        width: 36px;
        height: 36px;
    }

    .lightbox__nav--prev {
        left: 8px;
    }

    .lightbox__nav--next {
        right: 8px;
    }

    .lightbox__topbar {
        padding: 12px 16px;
    }
}

/* ──────────────────────────────────────────────────────────────────────
   Utilitaires
   ────────────────────────────────────────────────────────────────────── */

/* Désactiver la sélection sur les éléments interactifs */
.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* Masquer le body scroll quand le lightbox est ouvert */
body.lightbox-open {
    overflow: hidden;
}
