/*
 * Composants partages EZ Link.
 *
 * Source de verite unique pour les briques UI reutilisees par plusieurs pages
 * (cartes, etats vides, tuiles de synthese, boutons icone). Objectif : sortir
 * les blocs <style> des templates - cf docs/audit-uiux.md section 1.
 * Les tokens (--primary, --radius-lg, ...) viennent de app_common.css.
 */

/* ===== Cartes ===== */

/* Carte "douce" : sans bordure, ombre legere, coins arrondis. Variante par
   defaut des pages dashboard et admin. S'utilise avec la classe Bootstrap .card */
.card-soft {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* ===== Tuiles de synthese (KPI) ===== */

.overview-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    background: var(--gradient-purple);
}

/* ===== Etats vides ===== */

.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state > i {
    font-size: 48px;
    color: var(--gray-300);
    margin-bottom: 16px;
    display: block;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-tertiary);
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* ===== Boutons icone ===== */

/* Cible tactile minimale 44x44 (WCAG 2.5.5) tout en gardant un rendu compact */
.btn-icon-action {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== Composants applicatifs partages =====
 *
 * Ces regles etaient dupliquees a l'identique dans app_common.css ET
 * dashboard.css (valeurs parfois divergentes selon l'ordre de chargement) :
 * elles vivent desormais ici, une seule fois, pour toutes les pages
 * - cf docs/audit-uiux.md section 1. */

.btn {
    display: inline-flex;
    align-items: center;
    /* Un conteneur flex ignore text-align : sans justify-content, le libelle
       d'un bouton pleine largeur (.w-100, .d-grid) se colle a gauche. C'etait
       le cas du bouton « Se connecter » de la page de connexion. */
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all .2s ease;
    cursor: pointer
}

/* Fonctionnalite annoncee mais pas encore livree. Volontairement discret :
   il accompagne un libelle, il ne doit pas le voler. */
.badge-soon {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--gray-200, #e5e7eb);
    color: var(--gray-700, #374151);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    vertical-align: middle;
    white-space: nowrap;
    text-decoration: none;
}

.btn i {
    width: 1.25em;
    text-align: center
}

/* Depart du degrade sur --primary-dark et non --primary : le texte blanc
   n'atteignait que 3.66:1 sur #667eea (WCAG AA demande 4.5:1). */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, .25)
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, .35)
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-primary)
}

/* Au survol, seul le fond changeait : la couleur du texte restait celle du
   repos, et selon le theme on obtenait du blanc sur blanc. Les deux bougent
   ensemble desormais. */
.btn-secondary:hover,
.btn-secondary:focus-visible {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

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

.btn-success:hover {
    background: #059669
}

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

.btn-danger:hover {
    background: #dc2626
}

.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 12px
}

.alert i {
    width: 1.25em;
    text-align: center;
    flex-shrink: 0
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border)
}

.alert-danger, .alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border)
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-border)
}

.alert-info {
    background: var(--info-bg);
    color: var(--info-text);
    border: 1px solid var(--info-border)
}

.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 24px;
    transition: all .3s ease
}

.card:hover {
    box-shadow: 0 4px 12px var(--shadow-md)
}

.form-group {
    margin-bottom: 20px
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all .2s ease
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, .1)
}

.form-group input::placeholder, .form-group textarea::placeholder, .form-group select::placeholder {
    color: var(--text-tertiary)
}

.form-group textarea {
    resize: vertical;
    min-height: 100px
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important
    }
}

@media (min-width: 769px) {
    .show-mobile {
        display: none !important
    }
}


/* ===== Selecteur de langue =====
   Sans style dedie, ces liens heritaient du bleu Bootstrap (3.42:1 sur le pied
   de page sombre) et offraient une cible tactile de ~20px. */
.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.lang-switcher__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.lang-switcher__item:hover {
    background: var(--bg-tertiary);
    color: var(--primary-accessible);
}

.lang-switcher__item.is-active {
    color: var(--primary-accessible);
    background: var(--bg-tertiary);
}

/* Drapeaux SVG (les emojis d'indicateurs regionaux ne sont pas composes par
   Windows, qui affichait alors les lettres du code pays). */
.lang-switcher__flag {
    width: 21px;
    height: 14px;
    border-radius: 2px;
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
}

/* Sur fond sombre (pied de page vitrine, bandeau degrade) */
.bg-dark .lang-switcher__item,
.gradient-footer .lang-switcher__item,
footer.bg-dark .lang-switcher__item {
    color: #dee2e6;
}

.bg-dark .lang-switcher__item:hover,
.gradient-footer .lang-switcher__item:hover,
.bg-dark .lang-switcher__item.is-active,
.gradient-footer .lang-switcher__item.is-active {
    background: rgba(255, 255, 255, .15);
    color: #fff;
}

/* Variante compacte : pas de fond au repos, memes cibles tactiles */
.lang-switcher--compact .lang-switcher__item {
    padding: 0 8px;
}

/* ===== Pages d'authentification =====
   Utilise par auth_base.html.twig (connexion, inscription, mot de passe oublie,
   double authentification) : ces pages dupliquaient chacune le meme bloc CSS. */
.auth-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.auth-card {
    max-width: 450px;
    width: 100%;
    border-radius: var(--radius-xl);
}

.auth-card .form-label {
    font-weight: 600;
}

/* Pied de carte : lien de retour, bascule connexion / inscription */
.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-tertiary);
}

.auth-footer a {
    color: var(--primary-accessible);
    text-decoration: none;
    font-weight: 600;
}

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

/* Champs de code a usage unique (TOTP, codes de secours) : caracteres espaces
   et centres pour une saisie lisible. */
.auth-code-input {
    letter-spacing: 8px;
    font-variant-numeric: tabular-nums;
}

.auth-code-input--backup {
    letter-spacing: 4px;
    text-transform: uppercase;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Lien texte a la couleur de marque, contraste AA garanti */
.link-accent {
    color: var(--primary-accessible);
}

.link-accent:hover {
    color: var(--primary-dark);
}

/* ===== Champs de formulaire =====
   Surcharge unique de .form-control (Bootstrap) pour l'aligner sur les champs
   .form-group du design system. Trois templates du tableau de bord la
   redefinissaient chacun avec des bordures et des rayons differents. */
.form-control,
.form-select {
    padding: 12px 16px;
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, .1);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.form-control-lg {
    padding: 14px 18px;
    font-size: 16px;
}

/* Champs de formulaire sur mobile : Safari iOS zoome la page des qu'un champ
   sous 16px recoit le focus. L'utilisateur touche un champ, l'ecran se recadre,
   et il doit dezoomer a la main pour lire la suite. */
@media (max-width: 768px) {
    .form-control,
    .form-select,
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px;
    }
}

/* Cibles tactiles : le seuil recommande est de 44x44 px. Les boutons standard
   plafonnaient a 42px, et les paginations a 35. */
.btn {
    min-height: 44px;
}

.pagination {
    flex-wrap: wrap;
}

.pagination .page-link,
.pagination a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Rythme vertical -----------------------------------------------------
   Les gabarits posaient leurs espacements au cas par cas : deux cartes
   collées ici, quarante pixels de vide là. Ces règles donnent un rythme par
   défaut, que les pages n'ont plus à réinventer. */
.card-soft + .card-soft {
    margin-top: 24px;
}

.card-soft .card-body {
    padding: 28px;
}

/* Un titre de section annonce ce qui suit : il doit être plus proche de son
   contenu que du bloc précédent. */
.section-heading {
    margin: 8px 0 16px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-heading + .section-subtitle {
    margin-top: -8px;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

/* Formulaires : les champs d'un même groupe se suivent, les groupes se
   séparent. */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .card-soft .card-body {
        padding: 20px;
    }

    .card-soft + .card-soft {
        margin-top: 16px;
    }
}

/* --- Interrupteur --------------------------------------------------------- */
/* Une case a cocher ne dit pas qu'elle bascule un etat : l'interrupteur montre
   la position, se touche plus facilement au doigt, et garde la case en dessous
   pour le clavier et les technologies d'assistance. */
.ez-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ez-switch label {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    margin: 0;
}

.ez-switch-track {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 30px;
    border-radius: var(--radius-full);
    background: var(--gray-300);
    transition: background .2s ease;
}

.ez-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--elevation-sm);
    transition: transform .2s ease;
}

.ez-switch input:checked + label .ez-switch-track {
    background: var(--primary-surface);
}

.ez-switch input:checked + label .ez-switch-thumb {
    transform: translateX(22px);
}

.ez-switch input:focus-visible + label .ez-switch-track {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

.ez-switch-text strong {
    display: block;
    line-height: 1.3;
}

@media (prefers-reduced-motion: reduce) {
    .ez-switch-track,
    .ez-switch-thumb {
        transition: none;
    }
}
