/**
 * @package     vxDevis
 * @subpackage  com_vxdevis
 * @author      vaxin.fr <contact@vaxin.fr>
 * @copyright   Copyright (C) 2026 vaxin.fr. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 * @version     1.9.3
 */

/* ==========================================================================
   vxDevis - Styles frontend
   ========================================================================== */

:root {
    --vxd-primary: #5b6cff;
    --vxd-primary-hover: #4453e6;
    --vxd-primary-light: #eef0ff;
    --vxd-success: #10b981;
    --vxd-danger: #ef4444;
    --vxd-warning: #f59e0b;
    --vxd-text: #1f2937;
    --vxd-text-muted: #6b7280;
    --vxd-border: #e5e7eb;
    --vxd-border-focus: #5b6cff;
    --vxd-bg: #ffffff;
    --vxd-bg-soft: #f9fafb;
    --vxd-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --vxd-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    --vxd-radius: 12px;
    --vxd-radius-sm: 8px;
    --vxd-transition: all 0.2s ease;
}

/* ==========================================================================
   Layout principal
   ========================================================================== */

.vxdevis-wrapper {
    max-width: 860px;
    margin: 2rem auto;
    padding: 0 1rem;
    color: var(--vxd-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.vxdevis-card {
    background: var(--vxd-bg);
    border-radius: var(--vxd-radius);
    box-shadow: var(--vxd-shadow-lg);
    overflow: hidden;
    border: 1px solid var(--vxd-border);
}

.vxdevis-card-header {
    background: linear-gradient(135deg, var(--vxd-primary) 0%, #7d8aff 100%);
    color: #fff;
    padding: 2rem;
    position: relative;
}

.vxdevis-card-header::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 12px;
    background: var(--vxd-bg);
    border-radius: 12px 12px 0 0;
}

.vxdevis-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.vxdevis-description {
    margin: 0;
    opacity: 0.95;
    font-size: 1rem;
    line-height: 1.6;
}

/* ==========================================================================
   Formulaire
   ========================================================================== */

.vxdevis-form {
    padding: 2rem;
}

.vxdevis-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.vxdevis-field {
    flex: 1 1 100%;
    min-width: 0;
}

.vxdevis-field.col-md-6 {
    flex: 1 1 calc(50% - 0.625rem);
}

.vxdevis-field.col-md-4 {
    flex: 1 1 calc(33.333% - 0.834rem);
}

@media (max-width: 640px) {
    .vxdevis-field.col-md-6,
    .vxdevis-field.col-md-4 {
        flex: 1 1 100%;
    }
}

.vxdevis-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--vxd-text);
}

.vxdevis-required {
    color: var(--vxd-danger);
    margin-left: 2px;
}

.vxdevis-input,
.vxdevis-field textarea,
.vxdevis-field select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--vxd-text);
    background-color: var(--vxd-bg);
    border: 1.5px solid var(--vxd-border);
    border-radius: var(--vxd-radius-sm);
    transition: var(--vxd-transition);
    box-sizing: border-box;
    font-family: inherit;
}

.vxdevis-input:focus,
.vxdevis-field textarea:focus,
.vxdevis-field select:focus {
    outline: none;
    border-color: var(--vxd-border-focus);
    box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.15);
}

.vxdevis-input:hover:not(:focus),
.vxdevis-field textarea:hover:not(:focus),
.vxdevis-field select:hover:not(:focus) {
    border-color: #cbd5e0;
}

.vxdevis-field textarea {
    min-height: 120px;
    resize: vertical;
}

.vxdevis-help {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--vxd-text-muted);
}

/* ==========================================================================
   Radios et checkboxes
   ========================================================================== */

.vxdevis-radios,
.vxdevis-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.25rem;
}

.vxdevis-radio,
.vxdevis-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--vxd-radius-sm);
    transition: background-color 0.15s ease;
}

.vxdevis-radio:hover,
.vxdevis-checkbox:hover {
    background-color: var(--vxd-bg-soft);
}

.vxdevis-radio input,
.vxdevis-checkbox input {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--vxd-primary);
    cursor: pointer;
}

/* ==========================================================================
   Choix visuels (imagechoice) — Cartes cliquables avec images
   ========================================================================== */

.vxdevis-imagechoice {
    display: grid;
    gap: 0.875rem;
    padding-top: 0.25rem;
}

.vxdevis-imgchoice-cols-2 { grid-template-columns: repeat(2, 1fr); }
.vxdevis-imgchoice-cols-3 { grid-template-columns: repeat(3, 1fr); }
.vxdevis-imgchoice-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 640px) {
    .vxdevis-imgchoice-cols-3,
    .vxdevis-imgchoice-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
    .vxdevis-imagechoice { grid-template-columns: 1fr !important; }
}

.vxdevis-imgchoice-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 1.25rem 0.75rem;
    border: 2px solid var(--vxd-border, #e5e7eb);
    border-radius: var(--vxd-radius-sm, 8px);
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    position: relative;
    min-height: 80px;
}

.vxdevis-imgchoice-card:hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

/* Carte sélectionnée */
.vxdevis-imgchoice-input:checked + .vxdevis-imgchoice-img + .vxdevis-imgchoice-label,
.vxdevis-imgchoice-input:checked ~ .vxdevis-imgchoice-label {
    font-weight: 700;
}

.vxdevis-imgchoice-card:has(.vxdevis-imgchoice-input:checked) {
    border-color: var(--vxd-primary, #5b6cff);
    box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.12), 0 2px 8px rgba(91, 108, 255, 0.08);
    background: rgba(91, 108, 255, 0.03);
}

/* Coche en haut à droite quand sélectionné */
.vxdevis-imgchoice-card:has(.vxdevis-imgchoice-input:checked)::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--vxd-primary, #5b6cff);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}

/* Input radio caché visuellement */
.vxdevis-imgchoice-input {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none;
}

/* Image */
.vxdevis-imgchoice-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: 120px;
    overflow: hidden;
}

.vxdevis-imgchoice-img img {
    max-width: 100%;
    max-height: 100px;
    height: auto;
    object-fit: contain;
}

/* Libellé */
.vxdevis-imgchoice-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--vxd-text, #1f2937);
    line-height: 1.3;
}

/* ==========================================================================
   Headings / paragraphes (sections)
   ========================================================================== */

.vxdevis-heading {
    margin: 1rem 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--vxd-text);
    border-bottom: 2px solid var(--vxd-primary-light);
    padding-bottom: 0.5rem;
}

.vxdevis-paragraph {
    margin: 0;
    color: var(--vxd-text-muted);
    line-height: 1.6;
}

/* ==========================================================================
   Honeypot anti-spam (caché aux humains)
   ========================================================================== */

.vxdevis-hp {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ==========================================================================
   Boutons et actions
   ========================================================================== */

.vxdevis-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--vxd-border);
}

.vxdevis-btn,
.vxdevis-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    border-radius: var(--vxd-radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--vxd-transition);
    text-decoration: none;
    font-family: inherit;
}

.vxdevis-btn-primary,
.vxdevis-submit {
    background: linear-gradient(135deg, var(--vxd-primary) 0%, var(--vxd-primary-hover) 100%);
    color: #fff;
    box-shadow: 0 4px 6px -1px rgba(91, 108, 255, 0.25);
}

.vxdevis-btn-primary:hover,
.vxdevis-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -2px rgba(91, 108, 255, 0.35);
    color: #fff;
    text-decoration: none;
}

.vxdevis-btn-primary:active,
.vxdevis-submit:active {
    transform: translateY(0);
}

.vxdevis-submit:disabled,
.vxdevis-submit.is-loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.vxdevis-submit-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: vxd-spin 0.7s linear infinite;
}

.vxdevis-submit.is-loading .vxdevis-submit-spinner {
    display: inline-block;
}

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

/* ==========================================================================
   Feedback (succès / erreur)
   ========================================================================== */

.vxdevis-feedback {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--vxd-radius-sm);
    font-size: 0.9375rem;
    display: none;
    animation: vxd-fade-in 0.3s ease;
}

.vxdevis-feedback.is-visible {
    display: block;
}

.vxdevis-feedback.is-success {
    background-color: #ecfdf5;
    color: #047857;
    border: 1px solid #6ee7b7;
}

.vxdevis-feedback.is-error {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

@keyframes vxd-fade-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* États invalides */
.vxdevis-input.is-invalid,
.vxdevis-field textarea.is-invalid,
.vxdevis-field select.is-invalid {
    border-color: var(--vxd-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.vxdevis-error-message {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--vxd-danger);
    font-weight: 500;
}

/* ==========================================================================
   Page de succès
   ========================================================================== */

.vxdevis-success-card {
    padding: 3rem 2rem;
    text-align: center;
}

.vxdevis-success-icon {
    color: var(--vxd-success);
    margin-bottom: 1.5rem;
    display: inline-block;
    animation: vxd-pop 0.4s ease;
}

@keyframes vxd-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.vxdevis-success-title {
    margin: 0 0 1rem 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--vxd-text);
}

.vxdevis-success-message {
    margin: 0 0 2rem 0;
    color: var(--vxd-text-muted);
    font-size: 1.0625rem;
    line-height: 1.6;
}

.vxdevis-reference-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 2rem;
    background: var(--vxd-primary-light);
    border-radius: var(--vxd-radius);
    margin-bottom: 2rem;
}

.vxdevis-reference-label {
    font-size: 0.875rem;
    color: var(--vxd-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.vxdevis-reference-value {
    font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--vxd-primary);
    letter-spacing: 0.025em;
}

.vxdevis-success-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

/* ==========================================================================
   Mode sombre (respect des préférences système)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .vxdevis-wrapper {
        --vxd-text: #f3f4f6;
        --vxd-text-muted: #9ca3af;
        --vxd-border: #374151;
        --vxd-bg: #1f2937;
        --vxd-bg-soft: #111827;
        --vxd-primary-light: #312e81;
    }
}

/* ==========================================================================
   Toasts (notifications empilées en bas à gauche)
   ========================================================================== */

.vxdevis-toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.625rem;
    max-width: 420px;
    pointer-events: none;
}

@media (max-width: 480px) {
    .vxdevis-toast-container {
        left: 0.75rem;
        right: 0.75rem;
        max-width: none;
    }
}

.vxdevis-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-radius: 10px;
    font-size: 0.9375rem;
    line-height: 1.4;
    pointer-events: all;
    opacity: 0;
    transform: translateX(-20px) scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.vxdevis-toast.is-visible {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.vxdevis-toast.is-dismissing {
    opacity: 0;
    transform: translateX(-30px) scale(0.92);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Variantes */
.vxdevis-toast-error {
    background: rgba(254, 242, 242, 0.97);
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.vxdevis-toast-success {
    background: rgba(236, 253, 245, 0.97);
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.vxdevis-toast-info {
    background: rgba(238, 242, 255, 0.97);
    border: 1px solid #a5b4fc;
    color: #3730a3;
}

.vxdevis-toast-icon {
    flex-shrink: 0;
    font-size: 1.125rem;
    line-height: 1.3;
}

.vxdevis-toast-text {
    flex: 1;
    font-weight: 500;
}

.vxdevis-toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s;
    padding: 0 0 0 0.5rem;
    line-height: 1;
    color: inherit;
}

.vxdevis-toast-close:hover {
    opacity: 1;
}

/* Bordure rouge sur les champs imagechoice invalides */
.vxdevis-imagechoice.is-invalid {
    border: 2px solid #ef4444;
    border-radius: 8px;
    padding: 0.5rem;
}

/* ==========================================================================
   Consentement RGPD
   ========================================================================== */
.vxdevis-gdpr {
    display: flex;
    align-items: flex-start;
}
.vxdevis-gdpr-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--vxd-text, #1f2937);
    cursor: pointer;
    margin: 0;
}
.vxdevis-gdpr-check {
    margin-top: 0.2rem;
    flex-shrink: 0;
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--vxd-primary, #5b6cff);
    cursor: pointer;
}
.vxdevis-gdpr-text a {
    color: var(--vxd-primary, #5b6cff);
    text-decoration: underline;
}
.vxdevis-gdpr.is-invalid .vxdevis-gdpr-text {
    color: #dc2626;
}
.vxdevis-gdpr.is-invalid .vxdevis-gdpr-check {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
}

/* ==========================================================================
   Champ fichier joint (v1.7.0)
   ========================================================================== */
.vxdevis-file {
    cursor: pointer;
}
.vxdevis-file-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.25rem;
}
/* Transition douce pour les champs conditionnels */
.vxdevis-field[data-vxcond] {
    transition: opacity 0.2s ease;
}

/* ==========================================================================
   Message conditionnel (v1.9.0)
   ========================================================================== */
.vxdevis-message-cond {
    transition: opacity 0.2s ease;
}
.vxdevis-message-hidden {
    display: none;
}
.vxdevis-message-inner {
    background: color-mix(in srgb, var(--vxd-primary, #5b6cff) 8%, #fff);
    border-left: 4px solid var(--vxd-primary, #5b6cff);
    border-radius: 8px;
    padding: 0.875rem 1.125rem;
    color: var(--vxd-text, #1f2937);
    font-size: 0.9375rem;
    line-height: 1.5;
}
.vxdevis-message-inner p:last-child { margin-bottom: 0; }

/* ==========================================================================
   Message conditionnel affiché à côté d'un champ (v1.9.2)
   ========================================================================== */
.vxdevis-inline-message {
    margin-top: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: color-mix(in srgb, var(--vxd-primary, #5b6cff) 8%, #fff);
    border-left: 3px solid var(--vxd-primary, #5b6cff);
    border-radius: 6px;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--vxd-text, #1f2937);
}
