/* =========================================================
   Product Options UI — v2.0 (Espaço Criativo)
   - Validação visual para campos obrigatórios
   - Design mais suave e moderno
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
    --opt-brand: var(--color-accent);
    --opt-brand-strong: var(--color-primary);
    --opt-brand-light: var(--color-primary-bg);
    --opt-border: var(--color-border);
    --opt-border-hover: #c4b5fd;
    --opt-border-error: var(--color-danger);
    --opt-shadow: rgba(111, 66, 193, 0.08);
    --opt-shadow-hover: rgba(111, 66, 193, 0.15);
    --opt-card-bg: #fff;
    --opt-muted: var(--color-text-light);
    --opt-text: var(--color-text);
    --opt-radius-sm: 10px;
    --opt-radius-md: 12px;
    --opt-focus-ring: 0 0 0 3px rgba(111, 66, 193, 0.2);
    --opt-error-ring: 0 0 0 3px rgba(239, 68, 68, 0.2);
    --opt-speed: 0.2s;
}

/* =========================================================
   FORM GROUP & LABELS - Mais compacto
   ========================================================= */

.form-group {
    margin-bottom: 16px;
}

.form-group.required > label::after,
.form-group.required > .form-label::after {
    content: " *";
    color: var(--opt-border-error);
    font-weight: 600;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--opt-text);
    margin-bottom: 6px;
}

.form-label small {
    font-weight: 400;
    color: var(--opt-muted);
}

/* Container de opções - menos espaço em cima */
.ec-product-options {
    margin-top: 0;
    padding-top: 0;
}

/* =========================================================
   VALIDAÇÃO - Estado de erro (BEM DISCRETO)
   ========================================================= */

/* Mensagem de erro - mínima */
.opt-error-msg {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: #e53e3e;
    font-size: 12px;
    font-weight: 500;
    animation: optFadeIn 0.3s ease;
}

.opt-error-msg i {
    font-size: 12px;
}

.opt-error-msg.show {
    display: flex;
}

@keyframes optFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Alerta global - discreto */
.opt-global-alert {
    display: none;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: #fffbeb;
    border-radius: var(--opt-radius-sm);
    color: #92400e;
    font-size: 13px;
    font-weight: 500;
    animation: optFadeIn 0.3s ease;
}

.opt-global-alert i {
    font-size: 14px;
    color: #d97706;
}

.opt-global-alert.show {
    display: flex;
}

/* Sem tracejado - apenas cor sutil no label */
.form-group.has-error > label,
.form-group.has-error > .form-label,
.form-group.has-error > strong {
    color: #e53e3e !important;
}

/* Limpa erro quando válido */
.form-group.is-valid .opt-error-msg {
    display: none;
}

.form-group.is-valid > label,
.form-group.is-valid > .form-label,
.form-group.is-valid > strong {
    color: var(--opt-text) !important;
}

/* =========================================================
   SWATCHES (radio color/texture) - Mais bonitos
   ========================================================= */

.bb-product-attribute-swatch-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.bb-product-attribute-swatch-item {
    position: relative;
    cursor: pointer;
}

.bb-product-attribute-swatch-item label {
    display: inline-block;
}

/* Swatch circle - Mais compacto */
.bb-product-attribute-swatch-display {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--opt-border);
    box-shadow: 0 2px 6px var(--opt-shadow);
    transition: all var(--opt-speed) ease;
    background-size: cover;
    background-position: center;
}

/* Tamanhos */
.swatch-small .bb-product-attribute-swatch-display {
    width: 28px;
    height: 28px;
    border-width: 2px;
}

.swatch-medium .bb-product-attribute-swatch-display {
    width: 38px;
    height: 38px;
}

.swatch-large .bb-product-attribute-swatch-display {
    width: 48px;
    height: 48px;
}

.swatch-shape-square .bb-product-attribute-swatch-display {
    border-radius: var(--opt-radius-sm);
}

/* Hover */
.bb-product-attribute-swatch-item:hover .bb-product-attribute-swatch-display {
    border-color: var(--opt-border-hover);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px var(--opt-shadow-hover);
}

/* Focus */
.bb-product-attribute-swatch-item input[type="radio"]:focus-visible + .bb-product-attribute-swatch-display {
    outline: none;
    box-shadow: var(--opt-focus-ring), 0 2px 8px var(--opt-shadow);
}

/* Checked */
.bb-product-attribute-swatch-item input[type="radio"]:checked + .bb-product-attribute-swatch-display {
    border-color: var(--opt-brand-strong);
    box-shadow: 0 0 0 2px rgba(111, 66, 193, 0.25);
    transform: scale(1.05);
}

.bb-product-attribute-swatch-item input[type="radio"]:checked + .bb-product-attribute-swatch-display::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12' /%3E%3C/svg%3E") center/16px no-repeat;
    mix-blend-mode: difference;
    pointer-events: none;
}

/* Disabled */
.bb-product-attribute-swatch-item input[disabled] + .bb-product-attribute-swatch-display {
    filter: grayscale(0.5) brightness(0.95);
    opacity: 0.5;
    cursor: not-allowed;
}

.bb-product-attribute-swatch-item input[disabled] + .bb-product-attribute-swatch-display::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.1) 0 4px, transparent 4px 8px);
}

/* Tooltip */
.bb-product-attribute-swatch-item-tooltip {
    position: absolute;
    left: 50%;
    top: calc(100% + 10px);
    transform: translateX(-50%) translateY(-4px);
    min-width: 100px;
    max-width: 200px;
    background: var(--opt-brand-strong);
    color: #fff;
    font-size: 12px;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: var(--opt-radius-sm);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all var(--opt-speed) ease;
    text-align: center;
    white-space: normal;
}

.bb-product-attribute-swatch-item-tooltip::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--opt-brand-strong);
}

.bb-product-attribute-swatch-item:hover .bb-product-attribute-swatch-item-tooltip,
.bb-product-attribute-swatch-item:focus-within .bb-product-attribute-swatch-item-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =========================================================
   CHECKBOX CARDS - Mais compactos e bonitos
   ========================================================= */

.custom-option-box-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.custom-option-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 110px;
    max-width: 140px;
    padding: 16px 18px;
    background: var(--opt-card-bg);
    border: 2px solid var(--opt-border);
    border-radius: var(--opt-radius-md);
    color: var(--opt-text);
    cursor: pointer;
    text-align: center;
    transition: all var(--opt-speed) ease;
    box-shadow: 0 2px 8px var(--opt-shadow);
}

.custom-option-box .color-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--opt-border);
    box-shadow: 0 2px 6px var(--opt-shadow);
}

.custom-option-box img {
    width: 50px;
    height: 50px;
    border-radius: var(--opt-radius-sm);
    object-fit: cover;
    box-shadow: 0 2px 6px var(--opt-shadow);
}

.custom-option-box > .fw-bold {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--opt-text);
}

.custom-option-box > small {
    font-size: 12px;
    color: var(--opt-muted);
}

/* Hover */
.custom-option-box:hover {
    border-color: var(--opt-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--opt-shadow-hover);
}

/* Checked */
.btn-check:checked + .custom-option-box {
    border-color: var(--opt-brand);
    background: linear-gradient(135deg, #f0fdfa 0%, var(--color-primary-bg) 100%);
    box-shadow: 0 0 0 3px rgba(12, 195, 206, 0.15), 0 6px 16px var(--opt-shadow-hover);
}

.btn-check:checked + .custom-option-box::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    background: var(--opt-brand);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' width='12' height='12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 6L9 17l-5-5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.btn-check:checked + .custom-option-box > .fw-bold {
    color: var(--opt-brand-strong);
}

/* Focus */
.btn-check:focus-visible + .custom-option-box {
    box-shadow: var(--opt-focus-ring);
}

/* Disabled */
.btn-check:disabled + .custom-option-box,
.custom-option-box.is-unavailable {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
}

/* =========================================================
   TEXT / TEXTAREA - Mais bonitos
   ========================================================= */

.custom-text-input,
.custom-textarea {
    width: 100%;
    background: var(--opt-card-bg);
    border: 2px solid var(--opt-border);
    color: var(--opt-text);
    font-size: 14px;
    border-radius: var(--opt-radius-sm);
    padding: 12px 14px;
    transition: all var(--opt-speed) ease;
}

.custom-text-input::placeholder,
.custom-textarea::placeholder {
    color: var(--opt-muted);
}

.custom-text-input:hover,
.custom-textarea:hover {
    border-color: var(--opt-border-hover);
}

.custom-text-input:focus,
.custom-textarea:focus {
    outline: none;
    border-color: var(--opt-brand-strong);
    box-shadow: var(--opt-focus-ring);
}

.custom-textarea {
    resize: vertical;
    min-height: 100px;
}

/* =========================================================
   SELECT2 - Mais bonito e maior
   ========================================================= */

.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    height: 54px;
    padding: 12px 16px;
    border: 2px solid var(--opt-border);
    border-radius: var(--opt-radius-sm);
    background: var(--opt-card-bg);
    transition: all var(--opt-speed) ease;
}

.select2-container--default .select2-selection--single:hover {
    border-color: var(--opt-border-hover);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    font-size: 15px;
    font-weight: 500;
    color: var(--opt-text);
    padding-left: 0;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 50px;
    right: 14px;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--opt-muted);
    font-size: 15px;
}

/* Focus */
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--opt-brand-strong);
    box-shadow: var(--opt-focus-ring);
}

/* Dropdown */
.select2-dropdown {
    border: 2px solid var(--opt-border);
    border-radius: var(--opt-radius-sm);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-top: 4px;
}

.select2-results__option {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background var(--opt-speed) ease;
}

.select2-results__option--highlighted[aria-selected] {
    background: var(--opt-brand-light) !important;
    color: var(--opt-brand-strong) !important;
}

.select2-results__option[aria-selected="true"] {
    background: linear-gradient(135deg, #f0fdfa 0%, var(--color-primary-bg) 100%);
}

.select2-results__option[aria-disabled=true] {
    opacity: 0.5;
}

/* =========================================================
   UPLOAD - Mais bonito
   ========================================================= */

.custom-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: var(--opt-brand-light);
    border: 2px dashed var(--opt-border-hover);
    color: var(--opt-brand-strong);
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--opt-radius-sm);
    cursor: pointer;
    transition: all var(--opt-speed) ease;
}

.custom-upload-btn:hover {
    background: #ede9fe;
    border-color: var(--opt-brand-strong);
    transform: translateY(-1px);
}

.custom-upload-btn i {
    font-size: 18px;
}

/* =========================================================
   DATE / DATETIME - Mais bonitos
   ========================================================= */

.custom-date-input,
.custom-datetime-input {
    background: var(--opt-card-bg);
    border: 2px solid var(--opt-border);
    color: var(--opt-text);
    font-weight: 500;
    border-radius: var(--opt-radius-sm);
    padding: 12px 14px;
    transition: all var(--opt-speed) ease;
}

.custom-date-input:hover,
.custom-datetime-input:hover {
    border-color: var(--opt-border-hover);
}

.custom-date-input:focus,
.custom-datetime-input:focus {
    outline: none;
    border-color: var(--opt-brand-strong);
    box-shadow: var(--opt-focus-ring);
}

.custom-date-btn {
    background: var(--opt-brand-light);
    border: 2px solid var(--opt-border);
    color: var(--opt-brand-strong);
    border-radius: var(--opt-radius-sm);
    cursor: pointer;
    padding: 12px 14px;
    transition: all var(--opt-speed) ease;
}

.custom-date-btn:hover {
    background: #ede9fe;
    border-color: var(--opt-border-hover);
}

/* =========================================================
   TOTAL ADICIONAL - Mais bonito
   ========================================================= */

.options_total {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f0fdfa 0%, #ecfdf5 100%);
    border: 1px solid #a7f3d0;
    border-radius: var(--opt-radius-sm);
    color: #047857;
    font-size: 14px;
}

.options_total.show {
    display: flex;
}

.options_total strong {
    color: var(--color-success);
}

/* =========================================================
   RESPONSIVO
   ========================================================= */

@media (max-width: 640px) {
    .custom-option-box {
        min-width: calc(50% - 6px);
        max-width: calc(50% - 6px);
        padding: 14px 12px;
    }

    .custom-option-box img {
        width: 40px;
        height: 40px;
    }

    .custom-option-box .color-circle {
        width: 30px;
        height: 30px;
    }

    .bb-product-attribute-swatch-display {
        width: 42px;
        height: 42px;
    }

    .bb-product-attribute-swatch-list {
        gap: 8px;
    }

    .opt-global-alert {
        padding: 12px 14px;
        font-size: 13px;
        flex-direction: column;
        text-align: center;
    }

    .opt-error-msg {
        padding: 12px 14px;
        font-size: 13px;
    }

    .select2-container--default .select2-selection--single {
        height: 50px;
        padding: 10px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0s !important;
        animation-duration: 0s !important;
    }
}