/* ===================================================================
   BASE STYLES
=================================================================== */

/* Prevent horizontal scroll on pages with the form */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

*, *::before, *::after {
    box-sizing: border-box;
}

.quantity-discount-order-form {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px;
    border-style: dashed;
    border-color: #d3d3d3;
    overflow-x: hidden;
    width: 100%;
}

/* Desktop: a bit more padding and breathing room */
@media (min-width: 600px) {
    .quantity-discount-order-form {
        padding: 24px 28px;
    }
}

.original-price-display {
    margin-bottom: 12px;
    padding: 10px;
    text-align: center;
    overflow: hidden;
    word-break: break-word;
}

.price-label {
    font-weight: bold;
    margin-right: 10px;
}

.price-amount {
    font-size: 1.2em;
}

span.price-amount-number {
    font-size: clamp(2rem, 10vw, 4.5rem); /* safe responsive size, never overflows */
    font-family: Lato, sans-serif;
    font-weight: bold;
    text-decoration: none;
    line-height: 1.3;
    letter-spacing: 0px;
    text-shadow: 0px 0px 0px #000000;
    color: #333;
    display: block;     /* block so it respects parent width */
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* Currency symbol beside the number */
span.price-amount-currency {
    display: block;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
    margin-top: -4px;
}

.after-price-text {
    font-size: 14px;
    text-align: center;
    margin: 10px;
}

.before-price-text {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
}

.after-button-text {
    font-size: 14px;
    color: #f30000;
    text-align: center;
    margin: 10px;
}

/* ===================================================================
   QUANTITY OPTIONS
=================================================================== */
.quantity-options {
    margin-bottom: 20px;
}

.quantity-option {
    margin-bottom: 10px;
    font-size: 16px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.quantity-option input[type="radio"] {
    display: none;
}

.quantity-option label {
    display: block;
    padding: 10px 15px;
    border: 2px solid;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quantity-option input[type="radio"]:checked + label {
    font-weight: bold;
}

.discount-badge {
    display: inline-block;
    background-color: #FF9800;
    color: #000000;
    padding: 0 5px;
    border-radius: 3px;
    margin-left: 10px;
    font-size: 11px;
    float: left;
}

/* ===================================================================
   QUANTITY CARDS — responsive grid, full-bleed images
=================================================================== */
.quantity-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
    float: none;
}

.quantity-cards:has(.quantity-card:only-child) {
    grid-template-columns: 1fr;
}

.quantity-cards:has(.quantity-card:nth-child(3):last-child) {
    grid-template-columns: repeat(3, 1fr);
}

.quantity-card {
    width: 100%;
    float: none;
    margin: 0;
    position: relative;
    background: var(--card-bg, #f8f9fa);
    border: 2px solid var(--card-border, #e9ecef);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    /* Make card a flex column so image fills top, text sits below */
    display: flex;
    flex-direction: column;
}

.quantity-card:has(input[type="radio"]:checked) {
    background-color: var(--card-selected-bg, #e7f4ff);
    border-color: var(--card-selected-border, #007bff);
    box-shadow: 0 0 0 1px var(--card-selected-border, #007bff);
}

.quantity-card h4 {
    color: #333;
    margin: 0;
    font-size: 13px;
    text-align: center;
    line-height: 1.4;
    padding: 8px 6px 10px;
}

.quantity-card span.discount-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    right: auto;
    z-index: 2;
}

.quantity-card input[type="radio"] {
    display: none;
}

.quantity-card label {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    padding: 0;
    text-align: center;
    background: transparent;
    border: none;
    transition: background-color 0.2s ease;
    height: 100%;
    flex: 1;
}

/* ── FULL BLEED image area ── */
.quantity-card .card-image {
    width: 100%;
    aspect-ratio: 1 / 1;   /* perfect square crop */
    overflow: hidden;
    margin: 0;
    flex-shrink: 0;
    background: #ececec;
}

.quantity-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;      /* fills the box completely, crops excess */
    object-position: center;
    display: block;
    border-radius: 0;
    transition: transform .3s ease;
}

.quantity-card:hover .card-image img {
    transform: scale(1.04);
}

/* If no image uploaded — show placeholder */
.quantity-card .card-image:empty {
    display: none;
}

.quantity-card .card-content {
    text-align: center;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Mobile: stack to 1 column when < 360px */
@media (max-width: 360px) {
    .quantity-cards {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   ORDER FORM — MOBILE-FIRST
=================================================================== */
.cod-order-form {
    margin-top: 20px;
}

.form-row {
    margin-bottom: 15px;
}

.form-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 18px;
}

/* CRITICAL: font-size 16px prevents iOS Safari auto-zoom on focus.
   box-sizing: border-box ensures width:100% doesn't overflow.       */
.form-row input[type="text"],
.form-row input[type="tel"],
.form-row input[type="email"],
.form-row textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;        /* prevents iOS zoom */
    line-height: 1.5;
    box-sizing: border-box; /* prevents overflow */
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    color: #333;
    max-width: 100%;        /* never overflow parent */
    display: block;
}

.form-row input[type="text"]:focus,
.form-row input[type="tel"]:focus,
.form-row input[type="email"]:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
}

/* Textarea — roomy on mobile, resizable vertically */
.form-row textarea {
    min-height: 90px;
    resize: vertical;
}

.required {
    color: red;
}

/* ===================================================================
   ORDER SUMMARY
=================================================================== */
.order-summary {
    margin: 20px 0;
    padding: 15px;
    border-radius: 5px;
}

.order-summary h4 {
    margin-top: 0;
    margin-bottom: 10px;
}

/* ===================================================================
   SUBMIT BUTTON
=================================================================== */
.submit-order {
    width: 100%;
    padding: 14px;
    color: white;
    border: none;
    border-radius: 34px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation; /* faster tap on mobile */
}

.submit-order:hover {
    opacity: 0.9;
}

/* ===================================================================
   ERROR MESSAGES
=================================================================== */
.error-message {
    color: red;
    font-size: 0.9em;
    margin-top: 5px;
}

.global-error {
    background-color: #ffebee;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* ===================================================================
   SUCCESS MESSAGE
=================================================================== */
.order-success-message {
    background-color: #e8f5e9;
    padding: 20px;
    border-radius: 5px;
    margin-top: 20px;
    text-align: center;
}

/* ===================================================================
   LOADING SPINNER
=================================================================== */
.submit-order.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

/* ===================================================================
   SHIPPING INFO BADGES
=================================================================== */
.qd-shipping-info {
    text-align: center;
    margin: 6px 0 12px;
    font-size: 14px;
    font-weight: bold;
}

.qd-shipping-free {
    color: #2e7d32;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    padding: 5px 14px;
    border-radius: 20px;
    display: inline-block;
}

.qd-shipping-paid {
    color: #e65100;
    background: #fff3e0;
    border: 1px solid #ffcc80;
    padding: 5px 14px;
    border-radius: 20px;
    display: inline-block;
}

/* ===================================================================
   TABLE LABELS
=================================================================== */
.table-label {
    display: inline-block;
    border-radius: 4px;
    font-weight: 600;
    font-size: 16px;
}
.table-label.pending    { color: #f8b436; }
.table-label.processing { color: #2196f3; }
.table-label.on-hold    { color: #f44336; }
.table-label.completed  { color: #4caf50; }
.table-label.cancelled  { color: #f44336; }
.table-label.refunded   { color: #9e9e9e; }
.table-label.failed     { color: #f44336; }
.table-label.draft      { color: #9e9e9e; }

/* ===================================================================
   FLOATING ORDER BUTTON
   — uses padding-bottom on the form so it never covers the submit btn
=================================================================== */
.order-button-container {
    z-index: 9999;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 10px;
    text-align: center;
    background: linear-gradient(to top, rgba(255,255,255,0.95) 60%, transparent);
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s;
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* Hidden state — slides down off screen smoothly */
.order-button-container.qd-btn-hidden {
    opacity: 0;
    transform: translateY(100%);
    visibility: hidden;
    pointer-events: none;
}

/* Hide on mobile only (set from product editor) */
@media (max-width: 768px) {
    .order-button-container.qd-btn-hide-mobile {
        display: none !important;
    }
}

/* Hide on desktop only (set from product editor) */
@media (min-width: 769px) {
    .order-button-container.qd-btn-hide-desktop {
        display: none !important;
    }
}

/* When the floating button is shown, add bottom padding to the form
   so it doesn't hide behind the fixed button */
body.has-order-button .quantity-discount-order-form {
    padding-bottom: 80px;
}

@keyframes floatButton {
    0%   { transform: translateY(0) rotate(0deg);   box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
    25%  { transform: translateY(-4px) rotate(2deg); }
    50%  { transform: translateY(0) rotate(0deg);   box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
    75%  { transform: translateY(-2px) rotate(-2deg); }
    100% { transform: translateY(0) rotate(0deg);   box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
}

@keyframes glowButton {
    0%   { box-shadow: 0 0 5px var(--qd-btn-color, #007bff),  0 0 10px var(--qd-btn-color, #007bff),  0 0 15px var(--qd-btn-color, #007bff);  }
    50%  { box-shadow: 0 0 10px var(--qd-btn-color, #007bff), 0 0 20px var(--qd-btn-color, #007bff), 0 0 30px var(--qd-btn-color, #007bff); }
    100% { box-shadow: 0 0 5px var(--qd-btn-color, #007bff),  0 0 10px var(--qd-btn-color, #007bff),  0 0 15px var(--qd-btn-color, #007bff);  }
}

a.order-button {
    display: inline-block;
    padding: 10px 30px;
    background: var(--qd-btn-color, var(--primary-color, #007bff)) !important;
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    min-width: 300px;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s ease;
    animation: floatButton 3s ease-in-out infinite, glowButton 2s ease-in-out infinite;
    border: 2px solid rgba(255,255,255,0.3) !important;
    border-color: var(--qd-btn-color, var(--primary-color, #007bff)) !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

a.order-button:hover {
    color: #fff;
    transform: scale(1.05) translateY(-5px);
    animation-play-state: paused;
}

a.order-button:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    a.order-button {
        width: 90%;
        max-width: 300px;
        min-width: unset;
        padding: 12px 20px;
    }

    body.has-order-button .quantity-discount-order-form {
        padding-bottom: 90px;
    }
}

/* ===================================================================
   ORDERS SECTION (thank you / order lookup pages)
=================================================================== */
.list-unstyled { list-style: none; }
[dir] .list-unstyled { margin: 0; padding: 0; }
[dir] .app-heading { margin: 0 0 34px; text-align: center; }
.app-heading .heading-primary { font-size: 26px; line-height: 36px; }

@media (max-width: 768px) {
    [dir] .app-heading { margin: 0 0 17px; }
    .app-heading .heading-primary { font-size: 22px; line-height: 32px; }
}

.currency-value { align-items: center; display: inline-flex; }
.currency-value .currency,
.currency-value .value { font-size: inherit; }

@media (min-width: 768px) { [dir] .orders-section { padding: 60px 0; } }
@media (max-width: 768px) { [dir] .orders-section { padding: 30px 0; } }

.fr-view { word-wrap: break-word; }

[dir=rtl] .orders-section .app-heading { text-align: right; }
.orders-section .order-message { max-width: 700px; }
[dir] .orders-section .order-message { margin: 0 auto 30px; }
.orders-section .order-message .message-header { width: 90px; }
[dir] .orders-section .order-message .message-header { margin: 0 auto 20px; }
[dir] .orders-section .order-message .message-body .app-heading { margin: 0; text-align: center; }
[dir] .orders-section .order-message .message-body .fr-view { margin: 10px 0 0; text-align: center; }
[dir] .orders-section .order-message .message-body .actions { margin: 20px 0 0; text-align: center; }

.orders-section .single-order { max-width: 700px; }
[dir] .orders-section .single-order { background-color: #fafafa; border: 1px solid #f0f0f0; border-radius: 3px; margin: auto; padding: 15px; }
.orders-section .single-order .single-order-header { align-items: baseline; display: flex; justify-content: space-between; }
[dir] .orders-section .single-order .single-order-header { margin: 0 0 15px; }
.orders-section .single-order .single-order-header .order-item { flex: 1 auto; width: 33.3333333333%; }
[dir] .orders-section .single-order .single-order-header .order-item { background-color: #fff; border: 1px solid #f0f0f0; border-radius: 3px; padding: 12px; text-align: center; }
.orders-section .single-order .single-order-header .order-item h2 { color: #a7a7a7; font-size: 14px; font-weight: 500; }
[dir] .orders-section .single-order .single-order-header .order-item h2 { margin: 0 0 5px; }
.orders-section .single-order .single-order-header .order-item p { font-size: 13px; font-weight: 600; }
[dir] .orders-section .single-order .single-order-header .order-item p { margin: 0; }
[dir=rtl] .orders-section .single-order .single-order-header .order-item:not(:last-child) { margin: 0 0 0 10px; }

@media (max-width: 425px) {
    [dir] .orders-section .single-order .single-order-header .order-item:not(:last-child) { margin: 0 0 10px; }
    .orders-section .single-order .single-order-header .order-item { width: 100%; }
    .orders-section .single-order .single-order-header { flex-direction: column; }
}

.orders-section .single-order .single-order-body { overflow-x: auto; }
[dir] .orders-section .single-order .single-order-body { background-color: #fff; border: 1px solid #f0f0f0; border-radius: 3px; }
[dir] .orders-section .single-order .single-order-body .table td,
[dir] .orders-section .single-order .single-order-body .table th { padding: 15px; }
[dir] .orders-section .single-order .single-order-body .table thead tr { border-bottom: 1px solid #f0f0f0; }
.orders-section .single-order .single-order-body .table thead th { color: #a7a7a7; font-weight: 500; }
.orders-section .single-order .single-order-body .table .table-ref a { display: block; font-weight: 600; max-width: 280px; }
.orders-section .single-order .single-order-body .table .product-qty { display: block; font-size: 13px; font-weight: 500; height: 25px; line-height: 23px; width: 40px; }
[dir] .orders-section .single-order .single-order-body .table .product-qty { background-color: #fff; border: 1px solid #f0f0f0; border-radius: 3px; margin: auto; padding: 0 3px; }
.orders-section .single-order .single-order-body .table:not(.table-total) tbody tr { height: 50px; }
[dir] .orders-section .single-order .single-order-body .table:not(.table-total) tbody tr { background-color: #fefefe; border-bottom: 1px solid #f0f0f0; }
[dir] .orders-section .single-order .single-order-body .table:not(.table-total) tbody td { padding: 10px 15px; }
[dir] .orders-section .single-order .single-order-body .table.table-total tr td { padding: 0 20px 10px; }
.orders-section .single-order .single-order-body .table.table-total tr td:nth-child(3) { color: #a7a7a7; font-weight: 500; }
[dir] .orders-section .single-order .single-order-body .table.table-total tr:first-child td { padding: 15px 20px 10px; }
.orders-section .single-order .single-order-body .table.table-total tr:last-child td { color: #1a1a1a; }
[dir] .orders-section .single-order .single-order-body .table.table-total tr:last-child td { padding: 0 20px 15px; }
.orders-section .single-order .single-order-body .table.table-total tr:last-child td .currency-value { color: var(--primary-color); font-weight: 600; }

@media (max-width: 425px) {
    .orders-section .single-order .single-order-body .table { width: 600px; }
    .orders-section .single-order .single-order-body .table .mb-td { display: none; }
}

.orders-section .single-order .single-order-body::-webkit-scrollbar { height: 6px; width: 6px; }
[dir] .orders-section .single-order .single-order-body::-webkit-scrollbar-thumb { background-color: var(--primary-color); }
[dir] .orders-section .single-order .single-order-body::-webkit-scrollbar-track { background-color: #fafafa; }
.orders-section .paid { color: #00c853; }
[dir] .orders-section .text-center { text-align: center; }
.orders-section .table-variants li { color: #a7a7a7; display: flex; font-weight: 400; }
.orders-section .currency-value { font-weight: 500; }

.single-order-body { padding: 6px; }

.button {
    align-items: center;
    color: #fff;
    display: inline-flex;
    font-weight: 500;
    justify-content: center;
    line-height: inherit;
    outline: none;
    transition: all .25s;
}
[dir] .button { border: 1px solid transparent; border-radius: 3px; cursor: pointer; padding: 8px 24px 9px; }
[dir] .primary-button { background-color: var(--primary-color); border-color: var(--primary-color); }
.primary-button { color: var(--primary-color); }
[dir] .primary-button { background-color: transparent; }
[dir=rtl] .order-item h2 { font-weight: 600; }
[dir=rtl] .order-item p { direction: ltr; }
