/**
 * CSS Complémentaire - Gestion des quantités personnalisées (v2.9)
 * Fichier : assets/css/frontend-quantity-addon.css
 * 
 * À ajouter APRÈS frontend.css ou à intégrer directement dedans
 */

/* ============================================================================
   SECTION QUANTITÉ PERSONNALISÉE
   ============================================================================ */

/* Avertissement superficie manquante */
.stp-surface-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    margin: 16px 0 20px 0;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    color: #92400e;
    font-size: 14px;
    font-weight: 500;
}

.stp-surface-warning svg {
    flex-shrink: 0;
    color: #f59e0b;
}

/* Champ requis */
.stp-required {
    color: #ef4444;
    font-weight: 600;
    margin-left: 2px;
}

.stp-quantity-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 20px;
}

/* Ligne quantité par défaut */
.stp-qty-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--stp-text);
}

.stp-qty-label {
    font-weight: 500;
}

.stp-qty-default-value {
    color: var(--stp-primary);
}

.stp-qty-default-value strong {
    font-weight: 600;
}

/* Ligne personnalisation inline */
.stp-qty-custom-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stp-inline-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.stp-toggle-label-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--stp-text-light);
    transition: color 0.2s;
}

.stp-qty-custom-row.stp-custom-active .stp-toggle-label-text {
    color: var(--stp-primary);
}

/* Input inline pour la quantité */
.stp-qty-inline-input {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: all 0.25s ease;
}

.stp-qty-custom-row.stp-custom-active .stp-qty-inline-input {
    opacity: 1;
    max-width: 150px;
}

.stp-qty-inline-input .stp-custom-qty-value {
    width: 70px;
    padding: 6px 10px;
    border: 1px solid var(--stp-border);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: var(--stp-text);
    background: white;
}

.stp-qty-inline-input .stp-custom-qty-value:focus {
    outline: none;
    border-color: var(--stp-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.stp-qty-unit {
    font-size: 13px;
    color: var(--stp-text-light);
    white-space: nowrap;
}

/* Toggle tiny pour personnalisation */
.stp-toggle.stp-toggle-tiny {
    width: 34px;
    height: 18px;
}

.stp-toggle.stp-toggle-tiny .stp-toggle-slider::before {
    height: 12px;
    width: 12px;
}

.stp-toggle.stp-toggle-tiny input:checked + .stp-toggle-slider::before {
    transform: translateX(16px);
}

/* ============================================================================
   TOGGLE STYLE IPHONE
   ============================================================================ */

.stp-toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 8px 0;
}

/* Toggle à gauche du texte */
.stp-toggle-label.stp-toggle-left {
    justify-content: flex-start;
    gap: 12px;
}

.stp-toggle-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--stp-text);
}

.stp-toggle {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

/* Toggle petit */
.stp-toggle.stp-toggle-small {
    width: 40px;
    height: 22px;
}

.stp-toggle.stp-toggle-small .stp-toggle-slider::before {
    height: 16px;
    width: 16px;
}

.stp-toggle.stp-toggle-small input:checked + .stp-toggle-slider::before {
    transform: translateX(18px);
}

/* Toggle pour les travaux */
.stp-toggle.stp-toggle-work {
    width: 44px;
    height: 24px;
}

.stp-toggle.stp-toggle-work .stp-toggle-slider::before {
    height: 18px;
    width: 18px;
}

.stp-toggle.stp-toggle-work input:checked + .stp-toggle-slider::before {
    transform: translateX(20px);
}

.stp-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.stp-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: 0.3s;
    border-radius: 26px;
}

.stp-toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stp-toggle input:checked + .stp-toggle-slider {
    background-color: var(--stp-primary);
}

.stp-toggle input:checked + .stp-toggle-slider::before {
    transform: translateX(22px);
}

.stp-toggle input:focus + .stp-toggle-slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Variante verte pour "Je fais moi-même" */
.stp-toggle-success input:checked + .stp-toggle-slider {
    background-color: var(--stp-success);
}

.stp-toggle-success input:focus + .stp-toggle-slider {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Animation du toggle */
.stp-toggle-slider,
.stp-toggle-slider::before {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   FIN TOGGLE STYLE IPHONE
   ============================================================================ */

/* Toggle tiny pour personnalisation */
.stp-toggle.stp-toggle-tiny {
    width: 34px;
    height: 18px;
}

.stp-toggle.stp-toggle-tiny .stp-toggle-slider::before {
    height: 12px;
    width: 12px;
}

.stp-toggle.stp-toggle-tiny input:checked + .stp-toggle-slider::before {
    transform: translateX(16px);
}

/* ============================================================================
   MODALE D'ERREURS
   ============================================================================ */

.stp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s;
    padding: 20px;
}

.stp-modal-overlay.stp-modal-visible {
    opacity: 1;
}

.stp-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
    transition: transform 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

.stp-modal-visible .stp-modal-content {
    transform: scale(1);
}

.stp-modal-header {
    padding: 30px 30px 20px 30px;
    text-align: center;
}

.stp-modal-header svg {
    margin-bottom: 16px;
}

.stp-modal-header h3 {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--stp-text);
}

.stp-modal-header p {
    margin: 0;
    font-size: 14px;
    color: var(--stp-text-light);
}

.stp-modal-body {
    padding: 0 30px 20px 30px;
}

.stp-modal-error-item {
    padding: 14px 16px;
    background: var(--stp-bg-alt);
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
    margin-bottom: 12px;
}

.stp-modal-error-item:last-child {
    margin-bottom: 0;
}

.stp-modal-error-piece {
    font-weight: 600;
    color: var(--stp-text);
    font-size: 14px;
    margin-bottom: 4px;
}

.stp-modal-error-message {
    font-size: 13px;
    color: var(--stp-text-light);
}

.stp-modal-footer {
    padding: 20px 30px 30px 30px;
    text-align: center;
}

.stp-modal-footer .stp-btn {
    margin: 0;
    min-width: 150px;
}

/* Responsive */
@media (max-width: 600px) {
    .stp-modal-content {
        margin: 20px;
    }
    
    .stp-modal-header,
    .stp-modal-body,
    .stp-modal-footer {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ============================================================================
   INDICATEURS VISUELS (BADGES)
   ============================================================================ */

.stp-badge-custom {
    display: inline-block;
    margin-left: 10px;
    padding: 3px 10px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: #92400e;
}

/* Badge pour les quantités par défaut (optionnel) */
.stp-badge-default {
    display: inline-block;
    padding: 4px 10px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

/* ============================================================================
   AMÉLIORATION DU BADGE CALCUL AUTOMATIQUE
   ============================================================================ */

.stp-calc-badge {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
    color: #15803d;
    font-size: 14px;
}

.stp-calc-badge strong {
    font-weight: 600;
    margin-right: 8px;
}

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

@media (max-width: 768px) {
    .stp-quantity-section {
        padding: 12px;
    }
    
    .stp-qty-default-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .stp-custom-qty-input {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stp-custom-qty-input .stp-unit-label {
        text-align: left;
        padding-top: 4px;
    }
}

/* ============================================================================
   ÉTATS DÉSACTIVÉS
   ============================================================================ */

.stp-custom-qty-input input[disabled] {
    background: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.6;
}

.stp-qty-custom-option input[type="checkbox"][disabled] {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ============================================================================
   AMÉLIORATION DE L'AFFICHAGE DES UNITÉS
   ============================================================================ */

.stp-work-unit-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--stp-text-light);
    margin-top: 4px;
}

/* Distinction visuelle selon le type d'unité */
.stp-work-unit-badge[data-unite="forfait"],
.stp-work-unit-badge[data-unite="unité"],
.stp-work-unit-badge[data-unite="u"] {
    background: #fef3c7;
    color: #92400e;
}

.stp-work-unit-badge[data-unite="m²"],
.stp-work-unit-badge[data-unite="m2"] {
    background: #dbeafe;
    color: #1e40af;
}

.stp-work-unit-badge[data-unite="ml"],
.stp-work-unit-badge[data-unite="m"] {
    background: #e0e7ff;
    color: #4338ca;
}

/* ============================================================================
   TOOLTIPS ET AIDE CONTEXTUELLE
   ============================================================================ */

.stp-quantity-help {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--stp-text-light);
    margin-top: 6px;
    font-style: italic;
}

.stp-quantity-help::before {
    content: "ℹ️";
    font-style: normal;
}