/**
 * MindSpark Voucher - Frontend Styles
 *
 * Uses Elementor CSS custom properties when available (--e-global-color-accent),
 * falls back to neutral defaults otherwise.
 *
 * @package MindSpark_Voucher
 */

/* ─── Form container (flexbox) ─────────────────────────────── */
.msv-voucher-form {
    --msv-accent: var(--e-global-color-accent, #333);
    --msv-border: #ddd;
    --msv-radius: 6px;
    --msv-text: #333;
    --msv-muted: #666;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 600px;
}

/* ─── Field groups ─────────────────────────────────────────── */
.msv-field-group {
    margin: 0;
}

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

.msv-field-label .required {
    color: #e2401c;
}

.msv-optional {
    font-weight: 400;
    font-size: 12px;
    color: #888;
}

/* ─── Field hint (below input) ─────────────────────────────── */
.msv-field-hint {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: #888;
}

/* ─── Amount selection ─────────────────────────────────────── */
.msv-amount-input,
.msv-amount-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--msv-border);
    border-radius: var(--msv-radius);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s;
}

.msv-amount-input:focus,
.msv-amount-select:focus {
    outline: none;
    border-color: var(--msv-accent);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.msv-custom-amount-input {
    margin-top: 10px;
}

.msv-custom-amount-input input {
    width: 100%;
}

/* ─── Delivery type (vertical flex, visible radio) ─────────── */
.msv-delivery-options {
    display: flex;
    flex-direction: column;
}

.msv-delivery-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--msv-border);
    cursor: pointer;
    transition: background-color 0.2s;
}

.msv-delivery-option:first-child {
    border-radius: var(--msv-radius) var(--msv-radius) 0 0;
}

.msv-delivery-option:last-child {
    border-radius: 0 0 var(--msv-radius) var(--msv-radius);
    border-top: none;
}

.msv-delivery-option:only-child {
    border-radius: var(--msv-radius);
}

/* Custom styled radio circle */
.msv-delivery-option input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 50%;
    flex-shrink: 0;
    margin: 2px 0 0;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background-color 0.2s;
}

.msv-delivery-option input[type="radio"]:checked {
    border-color: var(--msv-accent);
    background-color: var(--msv-accent);
    box-shadow: inset 0 0 0 3px #fff;
}

.msv-delivery-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msv-delivery-content strong {
    display: block;
    font-size: 15px;
    color: var(--msv-text);
}

.msv-delivery-content span {
    display: block;
    font-size: 13px;
    color: var(--msv-muted);
    line-height: 1.5;
}

.msv-delivery-option:hover {
    background-color: #fafafa;
}

.msv-delivery-option:has(input:checked) {
    background-color: #fafafa;
}

/* ─── Text inputs & textarea ───────────────────────────────── */
.msv-text-input,
.msv-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--msv-border);
    border-radius: var(--msv-radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.msv-text-input:focus,
.msv-textarea:focus {
    outline: none;
    border-color: var(--msv-accent);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.msv-textarea {
    resize: vertical;
    min-height: 80px;
}

/* ─── Info box ─────────────────────────────────────────────── */
.msv-info-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    background: #f0f6ff;
    border: 1px solid #d0e0ff;
    border-radius: var(--msv-radius);
    font-size: 13px;
    color: #336;
}

.msv-info-icon {
    font-size: 18px;
    line-height: 1;
    color: #4a89dc;
    flex-shrink: 0;
}

/* ─── Type badge (single delivery type only) ───────────────── */
.msv-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.msv-type-digital {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.msv-type-physical {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

/* ─── Add-to-cart wrap (button full width) ──────────────────── */
.msv-add-to-cart-wrap {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

/* Button fills remaining space, quantity stays compact */
.msv-add-to-cart-wrap .single_add_to_cart_button {
    flex: 1 1 auto;
}

/* ─── Quantity stepper − | input | + ─────────────────────── */
.msv-qty-wrap {
    display: inline-flex !important;
    align-items: stretch !important;
    width: var(--msv-label-w, 160px);
    height: 44px;
    border: 1px solid #ccc !important;
    border-radius: var(--msv-radius, 6px) !important;
    overflow: hidden !important;
    flex-shrink: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
}

.msv-qty-btn {
    flex: 0 0 40px !important;
    width: 40px !important;
    background: #f0f0f0 !important;
    border: none !important;
    border-radius: 0 !important;
    font-size: 22px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    color: #333 !important;
    transition: background 0.15s !important;
    padding: 0 !important;
    margin: 0 !important;
    user-select: none !important;
    box-shadow: none !important;
    outline: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.msv-qty-btn:hover {
    background: #e0e0e0 !important;
    color: #111 !important;
}

.msv-qty-btn:active {
    background: #d0d0d0 !important;
}

.msv-qty-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

.msv-qty-wrap input.qty {
    flex: 1 1 auto !important;
    width: auto !important;
    height: auto !important;
    background: #fff !important;
    border: none !important;
    border-left: 1px solid #ccc !important;
    border-right: 1px solid #ccc !important;
    border-radius: 0 !important;
    text-align: center !important;
    font-size: 15px !important;
    padding: 0 4px !important;
    margin: 0 !important;
    min-width: 0 !important;
    box-shadow: none !important;
    -moz-appearance: textfield !important;
    color: inherit !important;
}

.msv-qty-wrap input.qty:focus {
    outline: none !important;
    box-shadow: none !important;
}

.msv-qty-wrap input.qty::-webkit-outer-spin-button,
.msv-qty-wrap input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* ─── Voucher download link (My Account) ───────────────────── */
.msv-voucher-info {
    padding: 8px 0;
}

.msv-voucher-info code {
    font-size: 14px;
    font-weight: bold;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 3px;
}

.msv-download-link {
    display: inline-block;
    margin-left: 8px;
    font-size: 13px;
    color: var(--msv-accent);
    text-decoration: underline;
}

.msv-download-link:hover {
    opacity: 0.8;
}

/* ─── Inline label layout ─────────────────────────────────── */
/*
 * When label_layout = 'inline', .msv-labels-inline is added to the form.
 * Each .msv-field-group becomes a flex row:
 *   .msv-field-label   — fixed width column (left)
 *   .msv-field-content — flexible column (right, holds all inputs)
 * All labels share the same width via --msv-label-w for visual alignment.
 * .msv-field-group--no-label groups stay full-width (block).
 */
.msv-labels-inline {
    --msv-label-w: 160px;
}

.msv-labels-inline .msv-field-group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-start !important;
    gap: 0 16px !important;
}

.msv-labels-inline .msv-field-group > .msv-field-label {
    flex: 0 0 var(--msv-label-w) !important;
    width: var(--msv-label-w) !important;
    max-width: var(--msv-label-w) !important;
    padding-top: 10px;
    margin-bottom: 0 !important;
    text-align: right;
    box-sizing: border-box;
}

.msv-labels-inline .msv-field-group > .msv-field-content {
    flex: 1 1 0% !important;
    min-width: 0 !important;
}

/* Groups without a label (info box, type badge) — full width block */
.msv-labels-inline .msv-field-group--no-label {
    display: block !important;
}

/* ─── Inline: field-content internal spacing ────────────────── */
.msv-field-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* When NOT inline, field-content is transparent (no extra spacing) */
.msv-labels-top .msv-field-content {
    gap: 0;
}

/* Revert to stacked layout on narrow screens */
@media (max-width: 640px) {
    .msv-labels-inline .msv-field-group {
        flex-direction: column !important;
    }

    .msv-labels-inline .msv-field-group > .msv-field-label {
        flex: none !important;
        width: auto !important;
        max-width: none !important;
        padding-top: 0;
        text-align: left;
        margin-bottom: 6px !important;
    }

    .msv-labels-inline .msv-field-group > .msv-field-content {
        flex: none !important;
        width: 100% !important;
    }
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
    .msv-voucher-form {
        max-width: 100%;
    }
}
