/**
 * Cartes — Composant carte (cards) pour les tableaux de bord
 *
 * Système de cartes réutilisable pour les formulaires admin :
 * carte de base, groupes inline, sous-sections et modificateurs de taille.
 *
 * @file        cc-cartes.css
 * @package     CaisseConnect
 * @subpackage  CSS\Components
 * @since       0.9
 * @version     1.7.3
 * @author      Microlibre <contact@microlibre.net>
 * @copyright   2026 Microlibre
 * @license     GPL-2.0+ https://www.gnu.org/licenses/gpl-2.0.html
 * @link        https://microlibre.net/caisse-connect
 */

/* ============================================
   CARTE DE BASE
   ============================================ */

.cc-carte {
    max-width: 800px;
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid var(--cc-menu-border, #e5e7eb);
    border-radius: 8px;
    background-color: var(--cc-menu-bg, #f9fafb);
}

/* Séparation verticale entre cartes successives */
.cc-carte + .cc-carte {
    margin-top: 20px;
}

/* Titre de carte */
.cc-carte h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 500;
    color: var(--cc-wp-text, #1d2327);
}

/* ============================================
   MODIFICATEURS DE TAILLE
   ============================================ */

.cc-carte--large {
    max-width: 1000px;
}

.cc-carte--small {
    max-width: 600px;
}

.cc-carte--full {
    max-width: none;
}

/* ============================================
   VARIANTES D'ÉTAT
   ============================================ */

.cc-carte--critique {
    border-left: 4px solid var(--cc-error, #dc3545);
}

.cc-carte--warning {
    border-left: 4px solid var(--cc-warning, #ffc107);
}

/* ============================================
   CARTE REPLIABLE (collapsible)
   ============================================ */

.cc-carte--collapsible > h3 {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.cc-carte--collapsible > h3 .dashicons {
    transition: transform 0.3s;
    transform: rotate(90deg); /* carte ouverte : flèche pointe vers le bas */
}

.cc-carte--collapsible > h3.collapsed {
    margin-bottom: 0;
}

.cc-carte--collapsible > h3.collapsed .dashicons {
    transform: rotate(0); /* carte fermée : flèche pointe vers la droite */
}

/* Bouton d'action dans le titre d'une carte repliable : aligné à droite, et son icône
   échappe à la rotation de la flèche de repli. Son clic ne replie pas la carte (cc-utils.js). */
.cc-carte--collapsible > h3 .cc-carte-titre-action {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cc-carte--collapsible > h3 .cc-carte-titre-action .dashicons,
.cc-carte--collapsible > h3.collapsed .cc-carte-titre-action .dashicons {
    transform: none;
    transition: none;
    line-height: 1; /* la hauteur de ligne du bouton (38px) décalerait le glyphe sous le libellé */
}

.cc-carte-collapsible-body {
    display: none;
}

.cc-carte-collapsible-body.open {
    display: block;
}

/* Badge de statut dans le titre d'une carte */
.cc-carte-statut {
    display: inline-block;
    margin-left: 10px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    vertical-align: middle;
    background-color: var(--cc-gray-300, #f0f0f0);
    color: var(--cc-text-light, #555);
}

/* L'attribut HTML `hidden` (règle user-agent) est sinon écrasé par le `display`
   ci-dessus (règle auteur). Sélecteur attribut+classe → spécificité supérieure. */
.cc-carte-statut[hidden] {
    display: none;
}

.cc-carte-statut--ok {
    background-color: var(--cc-success-bg, #d4edda);
    color: var(--cc-success-text, #155724);
}

.cc-carte-statut--ko {
    background-color: var(--cc-error-bg, #f8d7da);
    color: var(--cc-error-text, #721c24);
}

.cc-carte-statut--neutre {
    background-color: #e2e3e5;
    color: var(--cc-secondary-btn, #6c757d);
}

.cc-carte-statut--warning {
    background-color: var(--cc-warning-bg, #fff3cd);
    color: var(--cc-warning-text, #856404);
}

.cc-carte-statut--warning .cc-icone-information {
    font-size: 14px;
    margin-left: 4px;
    color: var(--cc-warning-text, #856404);
}

/* Bloc de boutons d'action en pied de carte. Remplace un style="margin-top:12px"
   inline — la convention du dépôt est « pas de CSS inline, classes préfixées
   cc- ». Volontairement GÉNÉRIQUE (carte), jamais préfixée à un module. */
.cc-carte-actions {
    margin-top: 12px;
}

/* Form-table dans carte (largeur réduite pour cartes) */
.cc-carte .form-table th {
    width: 200px;
}

/* ============================================
   CARTE SÉLECTIONNABLE (avec radio/checkbox)
   ============================================ */

.cc-carte--selectable {
    transition: border-color 0.3s, background-color 0.3s;
    cursor: pointer;
}

.cc-carte--selectable:hover {
    border-color: var(--cc-secondary, #0073aa);
}

/* État sélectionné (quand le radio/checkbox interne est coché) */
.cc-carte--selectable:has(input[type="radio"]:checked),
.cc-carte--selectable:has(input[type="checkbox"]:checked) {
    border-color: var(--cc-wp-link, #2271b1);
    background-color: var(--cc-wp-highlight-bg, #f0f6fc);
}

/* Label principal dans carte sélectionnable */
.cc-carte-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    margin: 0;
}

.cc-carte-label input[type="radio"],
.cc-carte-label input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Titre dans le label */
.cc-carte-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--cc-wp-text, #1d2327);
}

/* ============================================
   GROUPE INLINE (label + input + bouton)
   ============================================ */

.cc-carte-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.cc-carte-inline label {
    font-weight: normal;
    margin: 0;
}

/* Inputs dans groupe inline */
.cc-carte-inline select,
.cc-carte-inline input[type="text"],
.cc-carte-inline input[type="number"] {
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid var(--cc-wp-border, #8c8f94);
    border-radius: 4px;
    background-color: var(--cc-white, #fff);
}

.cc-carte-inline select {
    min-width: 120px;
}

.cc-carte-inline input[type="number"] {
    width: 100px;
}

/* Input petit (coefficient, pourcentage, etc.) */
.cc-input-petit {
    width: 80px !important;
}

/* Focus des inputs */
.cc-carte-inline select:focus,
.cc-carte-inline input[type="text"]:focus,
.cc-carte-inline input[type="number"]:focus {
    border-color: var(--cc-wp-link, #2271b1);
    box-shadow: 0 0 0 1px var(--cc-wp-link, #2271b1);
    outline: none;
}

/* ============================================
   SOUS-SECTION DANS UNE CARTE
   ============================================ */

.cc-carte-sub {
    margin-top: 20px;
    padding: 15px;
    background: var(--cc-white, #fff);
    border: 1px solid var(--cc-menu-border, #e5e7eb);
    border-radius: 4px;
}

/* Groupe d'action dans sous-section */
.cc-carte-action-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Select dans sous-section */
.cc-carte-select {
    min-width: 250px;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--cc-wp-border, #8c8f94);
    border-radius: 4px;
    background-color: var(--cc-white, #fff);
}

.cc-carte-select:focus {
    border-color: var(--cc-wp-link, #2271b1);
    box-shadow: 0 0 0 1px var(--cc-wp-link, #2271b1);
    outline: none;
}

/* Description dans sous-section */
.cc-carte-sub .description {
    margin-top: 10px;
    color: var(--cc-wp-text-secondary, #646970);
    font-style: italic;
}

/* ============================================
   EN-TÊTE ET PIED DE CARTE
   ============================================ */

.cc-carte-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.cc-carte-header h3 {
    margin: 0;
}

.cc-carte-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
}

/* ============================================
   ZONE UPLOAD (variante de sous-section)
   ============================================ */

.cc-carte-upload {
    margin-top: 15px;
    padding: 15px;
    background: var(--cc-white, #fff);
    border: 2px dashed var(--cc-wp-link, #2271b1);
    border-radius: 4px;
}

.cc-carte-upload p {
    margin-top: 0;
}

.cc-carte-upload input[type="file"] {
    margin-bottom: 10px;
}

/* ============================================
   BOUTON PERSONNALISE INPUT FILE
   ============================================ */

input[type="file"].cc-file-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.cc-carte-upload .cc-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cc-file-input-label {
    display: inline-block;
    padding: 4px 10px;
    font-size: 13px;
    line-height: 2.15384615;
    color: var(--cc-white, #fff);
    background: var(--cc-wp-link, #2271b1);
    border: 1px solid var(--cc-wp-link, #2271b1);
    border-radius: 3px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.cc-file-input-label:hover {
    background: var(--cc-wp-link-dark, #135e96);
    border-color: var(--cc-wp-link-dark, #135e96);
    color: var(--cc-white, #fff);
}

.cc-file-name {
    font-style: italic;
    color: var(--cc-wp-text-secondary, #646970);
    font-size: 13px;
}

/* Actions upload (boutons Uploader + Annuler) */
.cc-carte-upload .cc-upload-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

/* ============================================
   TABLEAU DANS UNE CARTE
   ============================================ */

.cc-carte-tableau-container {
    overflow-y: auto;
    border: 1px solid var(--cc-wp-border-light, #c3c4c7);
    border-radius: 4px;
}

.cc-carte-tableau-container table {
    margin: 0;
}

/* Compteur (utilisé dans les headers) */
.cc-carte-compteur {
    color: var(--cc-wp-text-secondary, #646970);
    font-style: italic;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 782px) {
    .cc-carte {
        padding: 15px;
    }

    .cc-carte-inline,
    .cc-carte-action-group {
        flex-direction: column;
        align-items: stretch;
    }

    .cc-carte-inline select,
    .cc-carte-select {
        min-width: 100%;
    }
}
