/* --- Variables & Base --- */
:root {
    --primary: #00f2fe;
    --secondary: #4facfe;
    --bg-dark: #000000;
}

body {
    font-family: sans-serif;
    margin: 0;
    background: #f0f0f0;
    display: flex;
    justify-content: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow: hidden;
}

.app-container {
    display: none;
    /* Piloté par le JS */
    /* width: 360px; */
    /* height: 620px; */
    width: 360px;
    height: 740px;
    background: white;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #333;
    opacity: 0;
    transition: opacity 0.8s ease-in;
}

/* --- Splash Screen & Loader --- */
#splash-screen {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    /* width: 360px; */
    /* height: 620px; */
    width: 360px;
    height: 740px;
    top: env(safe-area-inset-top, 0px);
    background: var(--bg-dark);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

.background-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

.blob {
    position: absolute;
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    filter: blur(80px);
    opacity: 0.2;
    animation: move 15s infinite alternate;
}

.app-shell-loader {
    width: 100%;
    text-align: center;
    z-index: 1;
    padding-top: 150px;
}

.logo-wrapper {
    margin-top: -40px;
    margin-bottom: 20px;
    animation: float 4s infinite ease-in-out;
    display: flex;
    justify-content: center;
}

.logo-img {
    width: 150px !important;
    height: auto;
    filter: drop-shadow(0 0 15px var(--primary));
}

.brand-name {
    color: #fff;
    font-size: 24px;
    letter-spacing: 5px;
    margin-bottom: 5px;
}

.version-tag {
    color: var(--primary);
    font-size: 10px;
    margin-bottom: 30px;
    opacity: 0.8;
}

.progress-container {
    width: 80%;
    /* Ajusté pour ne pas coller aux bords */
    margin: 0 auto 15px auto;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    box-shadow: 0 0 15px var(--primary);
    border-radius: 10px;
}

/* --- Header (Layout Haut) --- */
.layout-haut {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background-color: #1b1b1b;
    border-bottom: 1px solid #ddd;
    color: white;
}

.total-box {
    display: flex;
    height: 25px;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.left-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Style commun pour l'uniformité */
.btn-action-pay {
    height: 25px;
    /* Hauteur identique */
    min-width: 120px;
    /* Largeur minimale identique */
    border: none;
    border-radius: 5px;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, filter 0.2s;
}

/* Couleur VERTE pour la Caisse */
#btn-payer {
    background-color: #27ae60;
}

/* Couleur VIOLETTE pour la Carte */
#btn-carte {
    background-color: #635bff !important;
    /* !important pour écraser le style inline si besoin */
}

/* Effet au survol (devient un peu plus clair) */
.btn-action-pay:hover {
    filter: brightness(1.1);
}

/* Effet au clic (s'enfonce légèrement) */
.btn-action-pay:active {
    transform: scale(0.95);
}

.logo-box {
    text-align: center;
    width: 100%;
    height: 15px;
    font-size: 0.7em;
    color: #00c6ff;
    padding-top: 2px;
    border-top: 1px solid #333;
    background: #040404;
}

/* --- Panier (Layout Main) --- */
.layout-main {
    height: 445px;
    overflow-y: auto;
    background: #fff;
    border-bottom: 3px solid #ddd;
    scroll-behavior: smooth;
}

/* --- Articles (Layout Sous-Main) --- */
.layout-sous-main {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 48px;
    gap: 6px;
    padding: 10px;
    overflow-y: auto;
    background: #ececec;
}

/* --- Familles & Footer (Layout Bas) --- */
.layout-bas {
    height: 200px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 64px;
    gap: 6px;
    padding: 10px;
    background: #ececec;
    overflow-y: auto;
    border-top: 1px solid #444;
}

.art-card {
    background: #3498db;
    color: white;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fam-card {
    background: #64748b !important;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: grab;
    user-select: none;
    transition: transform 0.2s ease, background 0.2s;

    /* MODIFICATIONS ICI */
    padding: 10px 5px;
    /* Padding vertical et horizontal léger */
    width: 90%;
    /* Prend toute la largeur de sa colonne de grille */
    min-height: 45px;
    /* On définit une hauteur minimum plutôt que fixe */
    font-size: 0.7rem;
    text-align: center;
    word-break: break-word;
    /* Évite que le texte dépasse si le mot est long */
}

.fam-card i {
    font-size: 1.5rem;
    /* Taille de l'icône */
    color: #f39c12;
    /* Couleur de l'icône */
}

.fam-card i.icon-vert {
    color: hsl(74, 100%, 51%);
}

.fam-card:active {
    cursor: grabbing;
}

/* Style pendant que l'élément est survolé lors d'un drag */
.fam-card.over {
    border: 2px dashed #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
}

#panier thead th {
    background: #f8f8f8;
    position: sticky;
    top: 0;
    height: 36px;
    /* Hauteur fixe pour l'entête */
    padding: 0 5px;
    z-index: 10;
}

#panier td {
    height: 40px;
    /* Hauteur fixe par ligne d'article */
    padding: 0 5px;
    text-align: center;
    border-bottom: 1px solid #eee;
    box-sizing: border-box;
}

#panier td:first-child,
#panier th:first-child {
    text-align: left;
    padding-left: 10px;
    width: 50%;
}

#panier td:nth-child(2),
#panier th:nth-child(2) {
    text-align: right;
    width: 15%;
}

#panier td:nth-child(3),
#panier th:nth-child(3) {
    text-align: right;
    padding-right: 10px;
    width: 25%;
    font-weight: bold;
}

/* --- Modales & Numpad --- */
.num-btn {
    background: #333;
    border: 1px solid #444;
    color: white;
    padding: 20px;
    font-size: 20px;
    border-radius: 1px;
    cursor: pointer;
}

.num-btn:active {
    background: var(--primary);
    color: black;
}

#choice-container {
    display: none;
    flex-direction: column;
    gap: 15px;
    position: fixed;
    bottom: 100px;
    left: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    z-index: 1000;
    animation: fadeIn 0.5s ease-in;
}

.btn-choice {
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
    background: transparent;
    border: 2px solid var(--primary);
    color: white;
    padding: 15px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
}

/* --- Animations & Utilitaires --- */
@keyframes move {
    from {
        transform: translate(-20%, -20%);
    }

    to {
        transform: translate(120%, 120%);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Overlay identique au Numpad pour la cohérence */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: none;
    /* Piloté par JS : .style.display = 'flex' */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    /* Petit effet de flou en arrière-plan */
}

/* Boîte de paiement Stripe */
.stripe-box {
    background: #ffffff;
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    color: #333;
}

.stripe-box h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: #1a1f36;
    text-transform: uppercase;
}

.stripe-amount-banner {
    background: #f7f8ff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px dashed #6772e5;
}

.stripe-amount-banner span {
    display: block;
    font-size: 0.8rem;
    color: #6772e5;
}

.stripe-amount-banner strong {
    font-size: 1.8rem;
    color: #1a1f36;
}

/* Le conteneur où Stripe injecte l'Element */
#card-element {
    background: #fcfcfc;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 15px;
}

#payment-message {
    color: #df1b41;
    font-size: 0.9rem;
    margin-bottom: 15px;
    min-height: 1rem;
}

/* Boutons */
#submit-payment {
    background: #6772e5;
    /* Couleur officielle Stripe */
    color: white;
    border: none;
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#submit-payment:disabled {
    background: #aab7c4;
}

.btn-cancel-stripe {
    background: none;
    border: none;
    color: #697386;
    margin-top: 15px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

/* Empêche le zoom automatique sur les boutons et éléments interactifs */
button,
.art-card,
.fam-card,
.num-btn,
.btn-action-pay {
    touch-action: manipulation;
}

/* Optionnel : Désactivation globale sur le body si c'est une Web App stricte */
body {
    touch-action: pan-x pan-y;
    /* Autorise le scroll mais bloque le double-tap zoom */
}

/* Style spécifique pour le bouton Table */
#btn-table {
    background-color: #f39c12;
    /* Orange pour le différencier de la caisse */
    min-width: 50px;
    /* Plus étroit car il n'y a souvent qu'un chiffre */
    padding: 0 10px;
    border: none;
    /* La hauteur de 35px est déjà héritée de .btn-action-pay */
}

/* Optionnel : Si vous voulez que le cercle "?" soit bien centré */
#affichage-table {
    font-size: 1rem;
    font-weight: lighter;
}

/* Ajustement de la boîte qui contient les boutons pour l'alignement vertical */
.total-box {
    display: flex;
    height: 30px;
    /* Légèrement augmenté pour laisser respirer les boutons de 35px */
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
