/*
 * SP Gestion v3 — Styles frontend partagés
 * Mobile First — 390px d'abord, desktop en enrichissement
 *
 * Signature visuelle cohérente avec SP Gestion v2 :
 * - .sp-card avec border-top rouge et hover ombre colorée
 * - Boutons avec hover explicite, pas seulement opacity
 * - Badges arrondis, inputs avec focus rouge, labels visibles
 *
 * GeneratePress contrôle : font-family, font-size, font-weight,
 * letter-spacing, text-transform — jamais surchargés ici.
 *
 * @since  3.0.0
 * @author Christian Pelletier
 */


/* ─── Variables ──────────────────────────────────────────────────────────── */

:root {
    --sp-red:        #e31837;
    --sp-red-hover:  #c0152e;
    --sp-bordeaux:   #7b1e3a;
    --sp-blue:       #1e3a5f;
    --sp-blue-hover: #162d4a;
    --sp-dark:       #1e293b;
    --sp-gray:       #64748b;
    --sp-light:      #f8fafc;
    --sp-border:     #e2e8f0;

    --sp-radius:     8px;
    --sp-gap:        16px;

    /* Zones tactiles — standard Apple / Google */
    --sp-tap-min:    44px;
}


/* ─── Base ───────────────────────────────────────────────────────────────── */

.sp-wrap {
    width: 100%;
    max-width: 100%;
    padding: 0 var(--sp-gap);
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .sp-wrap {
        max-width: 900px;
        margin: 0 auto;
        padding: 0;
    }
}


/* ─── Grilles ────────────────────────────────────────────────────────────── */

.sp-cards-grid {
    display: flex;
    flex-direction: column;
    gap: var(--sp-gap);
}

@media (min-width: 768px) {
    .sp-cards-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .sp-cards-grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* ─── Cartes ─────────────────────────────────────────────────────────────── */

.sp-card {
    background: #fff;
    border: 1px solid var(--sp-border);
    border-top: 3.5px solid var(--sp-red);
    border-radius: var(--sp-radius);
    padding: 24px;
    position: relative;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.sp-card:hover {
    box-shadow: 0 4px 20px rgba(227, 24, 55, 0.15);
    border-color: var(--sp-red);
}

/* Variante bleue — historique, rapports */
.sp-card--bleu {
    border-top-color: var(--sp-blue);
}

.sp-card--bleu:hover {
    box-shadow: 0 4px 20px rgba(30, 58, 95, 0.15);
    border-color: var(--sp-blue);
}

/* Variante neutre — sans accent coloré */
.sp-card--neutre {
    border-top: 1px solid var(--sp-border);
}

.sp-card--neutre:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-color: #94a3b8;
}

.sp-card__titre {
    color: var(--sp-red);
    margin: 0 0 8px;
}

/* Carte cliquable (lien) */
a.sp-card-lien {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

a.sp-card-lien:hover {
    box-shadow: 0 4px 20px rgba(227, 24, 55, 0.22);
    border-color: var(--sp-red);
}

a.sp-card-lien:visited {
    color: inherit;
}


/* ─── Formulaires ────────────────────────────────────────────────────────── */

.sp-champ {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--sp-gap);
}

.sp-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    /* Labels toujours visibles — jamais seulement des placeholders */
}

.sp-label-case {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--sp-dark);
    cursor: pointer;
    min-height: var(--sp-tap-min);
}

.sp-champ label,
.sp-label {
    font-weight: 600;
    color: #475569;
}

.sp-input,
.sp-champ input,
.sp-champ select,
.sp-champ textarea {
    min-height: var(--sp-tap-min);
    padding: 10px 12px;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    color: var(--sp-dark);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sp-select {
    min-height: var(--sp-tap-min);
    padding: 8px 12px;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    font-size: 0.9rem;
    background: #fff;
    color: var(--sp-dark);
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
}

.sp-input:focus,
.sp-select:focus,
.sp-champ input:focus,
.sp-champ select:focus,
.sp-champ textarea:focus {
    outline: none;
    border-color: var(--sp-red);
    box-shadow: 0 0 0 2px rgba(227, 24, 55, 0.12);
}

.sp-textarea,
.sp-champ textarea {
    min-height: 120px;
    resize: vertical;
}

.sp-checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    accent-color: var(--sp-red);
    cursor: pointer;
}

.sp-input-file {
    font-size: 0.88rem;
    color: var(--sp-gray);
    cursor: pointer;
}


/* ─── Badges ─────────────────────────────────────────────────────────────── */

.sp-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.sp-badge--rouge    { background: #fee2e2; color: #991b1b; }
.sp-badge--vert     { background: #dcfce7; color: #15803d; }
.sp-badge--bleu     { background: #dbeafe; color: #1d4ed8; }
.sp-badge--jaune    { background: #fef9c3; color: #a16207; }
.sp-badge--gris     { background: #f1f5f9; color: var(--sp-gray); }
.sp-badge--orange   { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }


/* ─── Messages ───────────────────────────────────────────────────────────── */

.sp-msg {
    padding: 10px 16px;
    border-radius: var(--sp-radius);
    font-size: 0.9rem;
    margin-top: 10px;
}

.sp-msg--succes {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.sp-msg--erreur {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.sp-msg--info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0369a1;
}

.sp-msg--avertissement {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #c2410c;
}

/* Alias V2 */
.sp-msg-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.sp-msg-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }


/* ─── Notifications toast ────────────────────────────────────────────────── */

#sp-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--sp-dark);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--sp-radius);
    font-size: 0.92rem;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    max-width: calc(100vw - 48px);
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

#sp-toast.sp-toast--visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

#sp-toast.sp-toast--succes       { background: #166534; }
#sp-toast.sp-toast--erreur       { background: #991b1b; }
#sp-toast.sp-toast--avertissement { background: #92400e; }


/* ─── Tableaux ───────────────────────────────────────────────────────────── */

.sp-tableau-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sp-tableau {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.sp-tableau th {
    background: var(--sp-light);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid var(--sp-border);
    white-space: nowrap;
    font-size: 0.85rem;
}

.sp-tableau td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--sp-dark);
    vertical-align: middle;
}

.sp-tableau tr:hover td {
    background: #fafafa;
}


/* ─── En-têtes de section ────────────────────────────────────────────────── */

.sp-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sp-section-titre {
    color: var(--sp-red);
    margin-bottom: 1rem;
}

.sp-section-desc {
    color: #666;
    font-size: 0.9rem;
    max-width: 700px;
    margin: 0 auto 0.5rem;
    line-height: 1.6;
}


/* ─── États ──────────────────────────────────────────────────────────────── */

.sp-acces-refuse {
    padding: 24px;
    text-align: center;
    color: var(--sp-gray);
    font-style: italic;
}

.sp-chargement {
    text-align: center;
    padding: 32px;
    color: var(--sp-gray);
}

.sp-vide {
    text-align: center;
    padding: 32px;
    color: var(--sp-gray);
    font-style: italic;
}

.sp-erreur {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--sp-radius);
    padding: var(--sp-gap);
    color: #991b1b;
}

/* Spinner */
.sp-spinner {
    display: block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--sp-border);
    border-top-color: var(--sp-red);
    border-radius: 50%;
    animation: sp-spin 0.8s linear infinite;
    margin: 24px auto;
}

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


/* ─── Onglets (tabs) ─────────────────────────────────────────────────────── */

.sp-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--sp-border);
    margin-bottom: 24px;
}

.sp-tab {
    background: none;
    border: none;
    padding: 10px 20px;
    min-height: var(--sp-tap-min);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--sp-gray);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.sp-tab.active,
.sp-tab[aria-selected="true"] {
    color: var(--sp-red);
    border-bottom-color: var(--sp-red);
}

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


/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .sp-cards-grid { gap: 12px; }
    .sp-tableau th,
    .sp-tableau td  { padding: 8px 10px; font-size: 0.82rem; }
    .sp-tabs        { flex-wrap: wrap; }
    .sp-btn         { font-size: 0.85rem; }
}


/* ─── Popup maintenance ──────────────────────────────────────────────────────── */

.sp-maintenance-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.sp-maintenance-boite {
    background: #fff;
    border-top: 4px solid var(--sp-red);
    border-radius: var(--sp-radius);
    padding: 40px 36px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.sp-maintenance-icone {
    font-size: 2.5rem;
    margin-bottom: 16px;
    display: block;
}

.sp-maintenance-titre {
    color: var(--sp-red);
    margin: 0 0 12px;
}

.sp-maintenance-message {
    color: var(--sp-dark);
    margin: 0 0 8px;
}

.sp-maintenance-sous {
    color: var(--sp-gray);
    font-size: 0.9rem;
    margin: 0;
}


/* ─── Popup maintenance ───────────────────────────────────────────────────── */

.sp-maintenance {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 300px;
    padding: 48px 24px;
    background: #fff;
    border: 1px solid var(--sp-border);
    border-top: 3.5px solid #f59e0b;
    border-radius: var(--sp-radius);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.12);
}

.sp-maintenance__icone {
    font-size: 3rem;
    margin-bottom: 16px;
    animation: sp-maintenance-rock 2s ease-in-out infinite;
}

@keyframes sp-maintenance-rock {
    0%, 100% { transform: rotate(-8deg); }
    50%       { transform: rotate(8deg); }
}

.sp-maintenance__titre {
    color: #92400e;
    margin: 0 0 12px;
}

.sp-maintenance__texte {
    color: var(--sp-gray);
    line-height: 1.7;
    margin: 0;
    max-width: 400px;
}

/* Retiré — les styles du bouton Maintenance sont dans sp-ui.css */

/* ─── Alias de compatibilité v2 ──────────────────────────────────────────────
 *
 * Les modules portés depuis la v2 utilisent --sp-rouge, --sp-bordure, etc.
 * Ces alias pointent vers les valeurs v3 pour assurer la rétrocompatibilité.
 *
 * @since  3.1.0
 * @author Christian Pelletier
 */

:root {
    --sp-rouge:   var(--sp-red);
    --sp-bordure: var(--sp-border);
    --sp-texte:   var(--sp-dark);
    --sp-muted:   var(--sp-gray);
    --sp-bg:      var(--sp-light);
    --sp-blanc:   #ffffff;
}

/* ── Bandeau mode aperçu (user switch, lecture seule) ─────────────────────── */
/* @since 3.3.7 — porté et adapté depuis SP Gestion v2. */

#sp-apercu-bandeau {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
    height: 46px;
    background: #7b1e3a;
    color: #fff;
    font-size: .875rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}

.sp-apercu-bandeau__label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-weight: 600;
}

.sp-apercu-bandeau__label > span,
.sp-apercu-bandeau__nom {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-apercu-bandeau__icone {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sp-apercu-bandeau__nom {
    opacity: .9;
}

.sp-apercu-bandeau__badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .15);
    font-size: .75rem;
    white-space: nowrap;
}

.sp-apercu-bandeau__quitter {
    flex-shrink: 0;
    padding: 5px 14px;
    border: 1.5px solid rgba(255, 255, 255, .5);
    border-radius: 6px;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s;
}

.sp-apercu-bandeau__quitter:hover {
    background: rgba(255, 255, 255, .28);
    color: #fff;
}

body.sp-apercu-actif {
    padding-top: 46px !important;
}
