:root {
    --bg-main: #F8FAFC;
    --bg-secondary: #EFEDE3;
    --primary: #1D2C3A;
    --white: #FFFFFF;
    --border: #E5E7EB;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--primary);
    line-height: 1.6;
}

.page-content {
    flex: 1;
}

.container {
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

/* HEADER */
.header {
    position: fixed;
    top: 0;
    left: 0;
    height: 55px;
    width: 100%;
    z-index: 1000;
    padding: 10px 0;
    background-color: var(--bg-secondary);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.header-content .logo img {
  height: 36px;
  width: auto;
  max-width: 180px;
}

.nav a {
  margin-left: 24px;
  text-decoration: none;
  color: var(--primary);
  font-weight: 500;
}

.nav a:hover {
  text-decoration: underline;
}

.logo a {
    display: flex;
    align-items: center;
    line-height: 0;
}

/* Bouton aide avec icône */
.nav-help {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
    text-decoration: none;
    color: var(--primary);
    font-weight: 500;
}

/* Cercle icône */
.help-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.gallery-container {
    position: relative;
}

.beta-badge {
    position: absolute;
    top: 12px;
    left: 12px;

    background: linear-gradient(135deg, #ff4d4d, #ff9f43);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;

    padding: 4px 10px;
    border-radius: 999px;

    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);

    z-index: 10;
}

/* Hover */
.nav-help:hover .help-icon {
    opacity: 0.9;
}

.nav-help:hover {
    text-decoration: none;
}

#gallery-root {
    padding-top: 55px; /* correspond à la hauteur du header */
}

.form-tabs {
    display: flex;
    margin-bottom: 15px;
    gap: 5px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: #eee;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 500;
}

.tab-btn.active {
    background: #000;
    color: #fff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Bouton menu */
.btn-menu {
  padding: 10px 18px;
  border-radius: 8px;
  background-color: var(--primary);
  color: white !important;
  font-weight: 500;
  text-decoration: none;
  margin-left: 16px;
}

.btn-menu:hover {
  opacity: 0.9;
}

.center {
    text-align: center;
}

/* PAGE CENTRÉE */
.gallery-hero {
    min-height: calc(100vh - 55px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: var(--bg-main);
}

.gallery-container {
    background-color: var(--white);
    padding: 50px 40px;
    border-radius: 18px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 600px; /* plus large que 500px */
    margin: 0 auto;
}

.gallery-container h1 {
    font-size: 1.6rem;
    margin-bottom: 10px;
    color: var(--primary);
    text-align: center;
}

/* FORM */
#settings-form .form-group, .gallery-form .form-group {
    margin-bottom: 18px;
    text-align: left;
}

#settings-form label, .gallery-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

#settings-form input:not([type="checkbox"]),
.gallery-form input:not([type="checkbox"]) {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 1rem;
}

#settings-form input:focus, .gallery-form input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Conditions d'utilisation */
.terms-group {
    margin-top: 16px;
    font-size: 0.9rem;
}

.terms-label {
    display: flex;
    align-items: flex-start; /* aligne la checkbox avec le début du texte */
    gap: 8px;
    cursor: pointer;
    line-height: 1.4; /* reste identique */
    position: relative;
}

/* ===========================
   CHECKBOX CUSTOM - CGU
=========================== */

/* Cacher la checkbox native mais la garder accessible */
.terms-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Conteneur du texte */
.terms-label span {
    position: relative;
    padding-left: 30px; /* espace pour la checkbox */
    cursor: pointer;
}

/* Boîte de la checkbox */
.terms-label span::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;                  /* aligne avec le haut du texte */
    width: 14px;
    height: 14px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background-color: var(--white);
    transition: all 0.2s ease;
}

/* Icône check */
.terms-label span::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 2px;                /* ajuste la coche à l’intérieur de la boîte */
    width: 6px;
    height: 10px;
    border-right: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(45deg) scale(0);
    transition: transform 0.15s ease;
}

/* État checked */
.terms-label input[type="checkbox"]:checked + span::before {
    background-color: var(--primary);
    border-color: var(--primary);
}

.terms-label input[type="checkbox"]:checked + span::after {
    transform: rotate(45deg) scale(1);
}

/* Focus clavier (accessibilité) */
.terms-label input[type="checkbox"]:focus-visible + span::before {
    outline: 2px solid rgba(29, 44, 58, 0.4);
    outline-offset: 2px;
}

.terms-link {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 500;
}

.terms-link:hover {
    text-decoration: none;
}

.terms-beta {
    font-size: 0.8em;
    color: #888;
    margin-left: 4px;
}

/* BOUTON */
.btn-primary {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background-color: var(--primary);
    color: var(--white);
    font-weight: 500;
    cursor: pointer;
    margin-top: 10px;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--primary);
    background-color: var(--white);
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    margin-top: 10px;
    transition: 0.2s all ease;
}

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

/* Actions formulaire settings */
#settings-form .form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

#settings-form .form-actions .btn-primary,
#settings-form .form-actions .btn-secondary {
    width: 100%;       /* chaque bouton prend la moitié */
    margin-top: 0;     /* supprime l’empilement vertical */
}

/* ALERT */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.alert-error {
    background-color: #FEE2E2;
    color: #991B1B;
}

/* Galerie factice */
.test-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    width: 100%;
    padding: 20px; /* espace autour de la grille */
}

.test-gallery h2 {
    text-align: center;
    margin-bottom: 20px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 5px;
    justify-items: left; /* centre les items si la grille n’est pas pleine */
    width: 100%;
    padding: 0 5px 5px;
}

/* Floating Action Button */
.floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--primary);
    color: #fff;
    font-size: 28px;
    display: flex !important;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1000;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.floating-btn.bottom-left {
    left: 20px;
    right: auto;
}

.floating-btn.is-hidden {
    opacity: 0;
    transform: scale(0.85);
    pointer-events: none;
}

.floating-btn:hover {
    transform: scale(1.1);
}
@media (hover: none) and (pointer: coarse) {
    .floating-btn:hover {
        transform: none; /* pas d'effet hover sur mobile */
    }
}

/* Modale verticale */
.fab-modal {
    position: fixed;
    bottom: 90px; /* juste au-dessus du FAB */
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.fab-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.gallery-item {
    position: relative;
    width: 100%;
    max-width: 300px; /* taille maximale de chaque photo */
    aspect-ratio: 1 / 1; 
    overflow: hidden;
    border-radius: 12px;
    background-color: #eee;
}

/* Placeholder avec bordure animée */
.gallery-item.loading {
  position: relative;
  background-color: #eee;
  border-radius: 12px;
  overflow: hidden;
}

/* Bordure animée fixe avec gradient qui défile */
.gallery-item.loading::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  padding: 3px; /* épaisseur de la bordure */
  background: conic-gradient(
    from 0deg,
    #FF5C5C,
    #AD4949,
    #FF5C5C,
    #AD4949,
    #FF5C5C
  );
  mask: 
      linear-gradient(#fff 0 0) content-box, 
      linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask: 
      linear-gradient(#fff 0 0) content-box, 
      linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;

  /* Ici on fait défiler le gradient via background-position */
  background-size: 200% 200%;
  animation: gradientShift 1.5s linear infinite;
  pointer-events: none;
  z-index: 10;
}

/* Animation du gradient le long de la bordure */
@keyframes gradientShift {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}

@keyframes rotateGradient {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cercle de progression */
.gallery-item.loading .progress-circle {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 11;
}

.gallery-item.loading .progress-circle::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid #AD4949;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Fade-in pour l'image */
.gallery-item img {
    opacity: 0;
    transition: opacity 0.3s ease;
}
.gallery-item img.loaded {
    opacity: 1;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* remplissage propre et recadrage */
    display: block;
}

.gallery-item.portrait img {
    object-position: center top;
}

.gallery-item.landscape img {
    object-position: center;
}

/* 🔒 Protection images galerie & lightbox */
.gallery-item img,
#lightbox-image {
    -webkit-touch-callout: none; /* iOS : désactive "Enregistrer l’image" */
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
    -webkit-user-drag: none;
}

/* Empêche le drag desktop */
.gallery-item img,
#lightbox-image {
    user-drag: none;
    -webkit-user-drag: none;
}

/* Options */
.fab-option {
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    background-color: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: background 0.2s;
}

.fab-option:hover {
    background-color: #0f1a25; /* plus foncé au hover */
}

/* FOOTER */
.gallery-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 40px 24px 24px;
    width: 100%;
}

.gallery-footer .footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    text-align: center;
}

/* --- Social icon --- */
.footer-socials a {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    text-decoration: none;
}

.footer-socials a:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

/* --- Liens centraux --- */
.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* CTA inscription */
.footer-cta {
    position: relative;
}

/* Badge Gratuit */
.badge-free {
    background-color: var(--primary);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    text-transform: uppercase;
}

/* --- Copyright --- */
.footer-copy {
    font-size: 0.8rem;
    color: #6B7280;
}

/* RESPONSIVE */
@media (max-width: 400px) {
    .test-gallery {
        gap: 8px;
        padding: 10px;
    }
}
@media (max-width: 500px) {
    .help-text {
        display: none;
    }

    .nav-help {
        margin-left: 12px;
    }

    .gallery-container {
    padding: 40px 20px;
    }

    .gallery-container h1 {
    font-size: 1.5rem;
    }
}

@media (min-width: 768px) {
    .gallery-grid {
        gap: 10px;
    }
}

@media (min-width: 1024px) {
    .gallery-grid {
        gap: 15px;
    }
}