/* ==========================================================================
   WP Print Configurator — Frontend Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS custom properties (defaults — overridden by WPC_Settings inline CSS)
   -------------------------------------------------------------------------- */
.wpc-configurator,
.wpc-pricebar {
    /* Chips / radio buttons */
    --wpc-btn-bg:            #ffffff;
    --wpc-btn-border:        #d1d5db;
    --wpc-btn-color:         #1a1a2e;
    --wpc-btn-bg-hover:      #f0f7ff;
    --wpc-btn-border-hover:  #1d6fa5;
    --wpc-btn-color-hover:   #155c8a;
    --wpc-btn-bg-active:     #1d6fa5;
    --wpc-btn-border-active: #155c8a;
    --wpc-btn-color-active:  #ffffff;
    --wpc-btn-radius:        30px;

    /* Section cards */
    --wpc-section-bg:        #ffffff;
    --wpc-section-border:    #d1d5db;
    --wpc-section-radius:    8px;

    /* Price bar */
    --wpc-bar-bg:            #ffffff;
    --wpc-bar-border:        #e5e7eb;
    --wpc-bar-price-color:   #155c8a;
    --wpc-bar-text-color:    #6b7280;

    /* Misc */
    --wpc-shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --wpc-transition:  0.18s ease;
    --wpc-input-border: #d1d5db;
    --wpc-text:        #1a1a2e;
    --wpc-text-muted:  #6b7280;
    --wpc-bg-alt:      #f9fafb;
    --wpc-primary:     #1d6fa5;      /* kept for area display & input focus */
    --wpc-primary-dark: #155c8a;
    --wpc-primary-light: #e8f3fb;
    --wpc-success:     #16a34a;
    --wpc-danger:      #dc2626;
}

/* --------------------------------------------------------------------------
   Configurator wrapper
   -------------------------------------------------------------------------- */
.wpc-configurator {
    font-family: inherit;
    font-size: 15px;
    color: var(--wpc-text);
    /* Bottom padding is set by JS equal to the pricebar height so content
       never hides behind the fixed bar */
}

/* --------------------------------------------------------------------------
   Sections (cards)
   -------------------------------------------------------------------------- */
.wpc-section {
    background: var(--wpc-section-bg);
    border: 1px solid var(--wpc-section-border);
    border-radius: var(--wpc-section-radius);
    padding: 18px 20px;
    margin-bottom: 14px;
    box-shadow: var(--wpc-shadow);
}

.wpc-section-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--wpc-text-muted);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   Size inputs grid
   -------------------------------------------------------------------------- */
.wpc-size-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.wpc-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 110px;
    max-width: 160px;
}

.wpc-input-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--wpc-text-muted);
    letter-spacing: 0.02em;
}

.wpc-input {
    padding: 9px 12px;
    border: 1.5px solid var(--wpc-input-border);
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    color: var(--wpc-text);
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    transition: border-color var(--wpc-transition), box-shadow var(--wpc-transition);
    -moz-appearance: textfield;
}

.wpc-input::-webkit-outer-spin-button,
.wpc-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.wpc-input:focus {
    border-color: var(--wpc-primary);
    box-shadow: 0 0 0 3px rgba(29,111,165,.15);
    outline: none;
}

/* Area display */
.wpc-area-display {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 14px;
    background: var(--wpc-primary-light);
    border: 1.5px solid rgba(29,111,165,.25);
    border-radius: 6px;
    flex: 1 1 110px;
    max-width: 180px;
}

.wpc-area-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--wpc-primary);
}

.wpc-area-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--wpc-primary-dark);
    line-height: 1.2;
}

/* --------------------------------------------------------------------------
   Radio option groups (chips/pills)
   -------------------------------------------------------------------------- */
.wpc-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wpc-radio-option {
    position: relative;
    cursor: pointer;
    user-select: none;
}

/* Hide native radio */
.wpc-radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.wpc-radio-label {
    display: inline-block;
    padding: 8px 16px;
    border: 1.5px solid var(--wpc-btn-border);
    border-radius: var(--wpc-btn-radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--wpc-btn-color);
    background: var(--wpc-btn-bg);
    transition:
        background var(--wpc-transition),
        color var(--wpc-transition),
        border-color var(--wpc-transition),
        box-shadow var(--wpc-transition);
    white-space: nowrap;
    line-height: 1.4;
}

.wpc-radio-option:hover .wpc-radio-label {
    border-color: var(--wpc-btn-border-hover);
    background: var(--wpc-btn-bg-hover);
    color: var(--wpc-btn-color-hover);
}

.wpc-radio-option input:checked + .wpc-radio-label {
    background: var(--wpc-btn-bg-active);
    color: var(--wpc-btn-color-active);
    border-color: var(--wpc-btn-border-active);
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

/* --------------------------------------------------------------------------
   Upload section
   -------------------------------------------------------------------------- */

/* !! FIX: hide the native file input — only the styled dropzone is shown !! */
.wpc-file-input {
    display: none !important;
}

.wpc-badge-optional,
.wpc-badge-required {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    vertical-align: middle;
    text-transform: none;
    letter-spacing: 0;
}

.wpc-badge-optional {
    background: #f3f4f6;
    color: var(--wpc-text-muted);
}

.wpc-badge-required {
    background: #fef3c7;
    color: #92400e;
}

/* Upload inline validation error */
.wpc-upload-error {
    margin: 0 0 10px;
    padding: 10px 14px;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    color: var(--wpc-danger);
    font-size: 13.5px;
    font-weight: 500;
}

/* Drop zone */
.wpc-dropzone {
    border: 2px dashed var(--wpc-section-border);
    border-radius: var(--wpc-section-radius);
    padding: 28px 20px;
    text-align: center;
    background: var(--wpc-bg-alt);
    cursor: pointer;
    transition: border-color var(--wpc-transition), background var(--wpc-transition);
    position: relative;
}

.wpc-dropzone:hover,
.wpc-dropzone.wpc-dropzone-active {
    border-color: var(--wpc-primary);
    background: var(--wpc-primary-light);
}

.wpc-dropzone-inner {
    pointer-events: none;
}

.wpc-dropzone svg {
    color: var(--wpc-text-muted);
    margin-bottom: 10px;
}

.wpc-dropzone p {
    margin: 4px 0;
    font-size: 14px;
    color: var(--wpc-text-muted);
}

.wpc-dropzone.wpc-dropzone-active p {
    color: var(--wpc-primary-dark);
}

.wpc-browse-btn {
    background: none;
    border: none;
    color: var(--wpc-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    padding: 0;
    pointer-events: all;
}

.wpc-browse-btn:hover {
    color: var(--wpc-primary-dark);
}

.wpc-dropzone-hint {
    font-size: 12px !important;
    color: #9ca3af !important;
}

/* Uploaded files list */
.wpc-files-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wpc-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--wpc-section-border);
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
}

.wpc-file-uploading { background: #fffbeb; border-color: #fcd34d; }
.wpc-file-done      { background: #f0fdf4; border-color: #86efac; }
.wpc-file-error     { background: #fef2f2; border-color: #fca5a5; }

.wpc-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--wpc-text);
}

.wpc-file-err-name { color: var(--wpc-danger); }

.wpc-file-status {
    font-size: 12px;
    color: var(--wpc-text-muted);
    white-space: nowrap;
}

.wpc-file-ok  { color: var(--wpc-success); font-weight: 700; }
.wpc-file-err { color: var(--wpc-danger); }

.wpc-file-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--wpc-text-muted);
    font-size: 13px;
    padding: 2px 5px;
    border-radius: 3px;
    transition: color var(--wpc-transition), background var(--wpc-transition);
    line-height: 1;
}

.wpc-file-remove:hover {
    color: var(--wpc-danger);
    background: #fef2f2;
}

/* --------------------------------------------------------------------------
   Price bar
   Desktop : sticky dentro da coluna do produto (não ocupa a largura toda)
   Mobile  : fixed na base do ecrã (largura total)
   -------------------------------------------------------------------------- */
.wpc-pricebar {
    /* Normal flow on desktop — JS switches to position:fixed when the bar
       would scroll out of view, keeping it inside the product column width.
       Mobile overrides this with position:fixed via the media query below. */
    background: var(--wpc-bar-bg);
    border: 1px solid var(--wpc-bar-border);
    border-radius: 12px;
    box-shadow: 0 6px 28px rgba(0,0,0,.11);

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    margin-top: 8px;
    box-sizing: border-box;
    /* smooth transition when becoming/un-becoming fixed */
    transition: box-shadow 0.2s ease;
}

.wpc-pricebar-info {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

.wpc-pricebar-area,
.wpc-pricebar-sep,
.wpc-pricebar-rate {
    font-size: 13px;
    color: var(--wpc-bar-text-color);
    white-space: nowrap;
}

.wpc-pricebar-sep {
    opacity: 0.35;
}

.wpc-pricebar-total {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 0;
    flex-shrink: 0;
    text-align: right;
}

.wpc-pricebar-label {
    font-size: 11px;
    color: var(--wpc-bar-text-color);
    font-weight: 500;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wpc-pricebar-price {
    font-size: 24px;
    font-weight: 800;
    color: var(--wpc-bar-price-color);
    white-space: nowrap;
    line-height: 1.1;
}

.wpc-pricebar-vat {
    font-size: 11px;
    color: var(--wpc-bar-text-color);
    opacity: 0.7;
    white-space: nowrap;
    margin-top: 1px;
}

/* Price update animation */
@keyframes wpc-price-flash {
    0%   { opacity: 1; }
    30%  { opacity: 0.45; }
    100% { opacity: 1; }
}

.wpc-price-updated {
    animation: wpc-price-flash 0.3s ease;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Tablet */
@media ( max-width: 768px ) {
    .wpc-section {
        padding: 14px 16px;
    }

    .wpc-input-group {
        flex: 1 1 90px;
        max-width: none;
    }

    .wpc-area-display {
        flex: 1 1 100%;
        max-width: none;
    }

    .wpc-radio-label {
        padding: 7px 13px;
        font-size: 13.5px;
    }

    /* ── Mobile / tablet: passa a fixed na base do ecrã ── */
    .wpc-pricebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9000;

        border-radius: 0;
        border: none;
        border-top: 1.5px solid var(--wpc-bar-border);
        box-shadow: 0 -4px 20px rgba(0,0,0,.10);

        padding: 10px 18px;
        padding-bottom: max( 10px, env(safe-area-inset-bottom, 10px) );

        /* reset margin from desktop */
        margin-top: 0;
    }

    /* No tablet mantém texto secundário visível */
    .wpc-pricebar-info {
        display: flex;
    }

    .wpc-pricebar-price {
        font-size: 22px;
    }
}

/* Mobile pequeno */
@media ( max-width: 480px ) {
    .wpc-section {
        padding: 12px 14px;
        margin-bottom: 10px;
    }

    .wpc-section-title {
        font-size: 12px;
    }

    .wpc-size-inputs {
        gap: 10px;
    }

    .wpc-radio-label {
        padding: 7px 12px;
        font-size: 13px;
    }

    .wpc-pricebar {
        gap: 8px;
        padding: 10px 14px;
        padding-bottom: max( 10px, env(safe-area-inset-bottom, 10px) );
    }

    /* Em ecrãs pequenos esconde a info de área/taxa: foca no total */
    .wpc-pricebar-info {
        display: none;
    }

    .wpc-pricebar-price {
        font-size: 22px;
    }
}

/* Extra small */
@media ( max-width: 360px ) {
    .wpc-pricebar-label {
        display: none;
    }
}

/* ─────────────────────────────────────────────────────────────────────────
   Linear pricing mode (DTF) — tiers table + quantity selector
   Scoped under .wpc-configurator--linear so the styles never collide with
   the admin meta box's tier editor (also a `.wpc-tiers-table`).
   ───────────────────────────────────────────────────────────────────────── */

.wpc-configurator--linear .wpc-tiers-table-wrap {
    border-radius: var(--wpc-section-radius, 8px);
    overflow: hidden;
    border: 1px solid var(--wpc-section-border, #e0e0e0);
}

.wpc-configurator--linear .wpc-tiers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #fff;
}

.wpc-configurator--linear .wpc-tiers-table thead tr {
    background: var(--wpc-section-bg, #f5f5f5);
}

.wpc-configurator--linear .wpc-tiers-table th {
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--wpc-bar-text-color, #333);
}

.wpc-configurator--linear .wpc-tiers-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--wpc-section-border, #e0e0e0);
}

.wpc-configurator--linear .wpc-tier-row {
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.wpc-configurator--linear .wpc-tier-row:hover {
    background: var(--wpc-section-bg, #f9f9f9);
}

/* Active row mimics the option chips: coloured rounded border, transparent
   bg. Borders go on the <td>s because <tr> doesn't accept border-radius
   reliably across browsers. */
.wpc-configurator--linear .wpc-tier-row.wpc-tier-active td {
    background: transparent;
    font-weight: 700;
}
.wpc-configurator--linear .wpc-tier-row.wpc-tier-active td:first-child {
    border-left:   3px solid var(--wpc-btn-border-active, #f0c040);
    border-top:    3px solid var(--wpc-btn-border-active, #f0c040);
    border-bottom: 3px solid var(--wpc-btn-border-active, #f0c040);
    border-radius: var(--wpc-btn-radius, 20px) 0 0 var(--wpc-btn-radius, 20px);
    padding-left:  13px;
}
.wpc-configurator--linear .wpc-tier-row.wpc-tier-active td:last-child {
    border-right:  3px solid var(--wpc-btn-border-active, #f0c040);
    border-top:    3px solid var(--wpc-btn-border-active, #f0c040);
    border-bottom: 3px solid var(--wpc-btn-border-active, #f0c040);
    border-radius: 0 var(--wpc-btn-radius, 20px) var(--wpc-btn-radius, 20px) 0;
    padding-right: 13px;
}

.wpc-configurator--linear .wpc-tier-row.wpc-tier-active .wpc-tier-price {
    font-weight: 700;
}

/* Strip trailing whitespace at the bottom of the tiers table */
.wpc-configurator--linear .wpc-tiers-table tbody tr:last-child td {
    border-bottom: none;
}
.wpc-configurator--linear .wpc-tiers-table-wrap {
    padding-bottom: 0;
}
.wpc-configurator--linear .wpc-tiers-table {
    margin-bottom: 0;
}

.wpc-configurator--linear .wpc-tier-price {
    text-align: right;
    white-space: nowrap;
}

.wpc-configurator--linear .wpc-tier-unit {
    margin-left: 2px;
    opacity: 0.6;
    font-size: 12px;
}

/* Quantity selector */
.wpc-configurator--linear .wpc-qty-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpc-configurator--linear .wpc-qty-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--wpc-btn-active, #f0c040);
    background: transparent;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--wpc-bar-text-color, #333);
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.wpc-configurator--linear .wpc-qty-btn:hover {
    background: var(--wpc-btn-bg-active, #f0c040);
    color:      var(--wpc-btn-text-active, #1a1a1a);
}

.wpc-configurator--linear .wpc-qty-input {
    width: 72px;
    text-align: center;
    border: 1px solid var(--wpc-section-border, #e0e0e0);
    border-radius: var(--wpc-btn-radius, 6px);
    padding: 6px 8px;
    font-size: 16px;
    -moz-appearance: textfield;
}

.wpc-configurator--linear .wpc-qty-input::-webkit-outer-spin-button,
.wpc-configurator--linear .wpc-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wpc-configurator--linear .wpc-qty-suffix {
    color: var(--wpc-bar-text-color, #555);
    font-size: 14px;
}
