/* ========================================
   WooCommerce CartFlows Custom Checkout Widget
   Frontend CSS — v3.2.1
   Author: REAJUL ISLAM
   ======================================== */

:root {
    --primary-text: #333;
    --secondary-text: #666;
    --border-color: #ddd;
    --accent-color: #28a745;
    --accent-light: #f0f8f4;
    --bg-color: #fafafa;
    --card-bg: #fff;
    --error-color: #e74c3c;

    /* New, Elementor-editable design tokens */
    --header-bg-start: #667eea;
    --header-bg-end: #764ba2;
    --header-text-color: #ffffff;
    --price-color: var(--accent-color);
    --total-color: var(--accent-color);
    --button-hover-bg: var(--accent-color);
    --button-hover-color: #ffffff;
    --field-border-color: #c9ccd1;
    --field-border-width: 1px;
    --field-border-radius: 8px;
    --field-bg-color: #ffffff;
    --notice-bg: #f0f8f4;
    --notice-text: #333;
    --success-color: #1e7e34;
    --success-bg: #e9f9ee;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

/* Main Layout Wrapper */
#checkout-main-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--primary-text);
    background: #f5f5f5;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Overflow safety net — only applied to elements that actually tend to
   overflow narrow viewports (text/blocks), never to fixed-size elements
   like the product image or quantity buttons, so it can't squash layout. */
#checkout-main-wrapper img,
#checkout-main-wrapper .chk-layout-container,
#checkout-main-wrapper .chk-card,
#checkout-main-wrapper input,
#checkout-main-wrapper textarea,
#checkout-main-wrapper select {
    max-width: 100%;
}

/* Header */
.chk-header {
    text-align: center;
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--header-bg-start) 0%, var(--header-bg-end) 100%);
    color: var(--header-text-color);
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chk-header h2 {
    margin: 0 0 8px;
    font-size: 1.85rem;
    font-weight: 700;
}

.chk-header p {
    margin: 0;
    font-size: 1.05rem;
    opacity: 0.9;
}

/* Layout Container */
.chk-layout-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 12px 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* Card Styling */
.chk-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s ease;
}

.chk-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* ========================================
   Product Card — compact, premium layout
   Image (fixed square, left) | Name → Price + Qty (right, stacked)
   ======================================== */

.chk-product-card {
    margin-bottom: 0;
}

.chk-product-top-row {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

/* Fixed-size square image — never collapses, never leaves a grey gap
   beside it. object-fit:cover means any image (any aspect ratio) fills
   the box edge-to-edge with no empty space. */
.chk-img-wrapper {
    flex: 0 0 84px;
    width: 84px;
    height: 84px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-color);
    line-height: 0;
}

.chk-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Right side: name on top, price+qty row directly below — no wasted space */
.chk-product-info {
    flex: 1 1 auto;
    min-width: 0; /* allow text to wrap/truncate instead of overflowing */
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.chk-product-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.chk-price-qty-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}

.chk-current-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--price-color);
    white-space: nowrap;
}

/* Quantity Control */
.chk-quantity-control {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 3px;
    flex-shrink: 0;
}

.chk-qty-btn {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chk-qty-btn:hover {
    background: var(--accent-color);
    color: white;
}

.chk-qty-value {
    min-width: 20px;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
}

/* Divider */
.chk-divider {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 16px 0;
}

/* Input Wrapper */
.chk-input-wrapper {
    margin-bottom: 18px;
    position: relative;
}

.chk-input-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--secondary-text);
}

input[type="text"],
input[type="tel"],
textarea,
.chk-select-custom select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s ease;
}

/* Size & Delivery fields — Elementor-editable border so they're clearly
   visible (previously looked weak / hard to notice). */
#single-size-picker,
#chk-delivery-area {
    width: 100%;
    padding: 12px 14px;
    border: var(--field-border-width) solid var(--field-border-color);
    border-radius: var(--field-border-radius);
    background: var(--field-bg-color);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="tel"]:focus,
textarea:focus,
#single-size-picker:focus,
.chk-select-custom select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(40,167,69,0.1);
}

#chk-delivery-area:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(40,167,69,0.1);
}

textarea {
    resize: vertical;
    font-family: inherit;
}

.chk-select-custom {
    position: relative;
}

.chk-select-custom::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%23666"><path d="M5 8l5 5 5-5z"/></svg>');
    background-size: 20px;
    pointer-events: none;
}

.chk-error-msg {
    display: none;
    color: var(--error-color);
    font-size: 0.88rem;
    margin-top: 6px;
    font-weight: 500;
}

.chk-input-wrapper.chk-error input,
.chk-input-wrapper.chk-error textarea,
.chk-input-wrapper.chk-error select {
    border-color: var(--error-color);
    background-color: #fef5f5;
}

.chk-input-wrapper.chk-error .chk-error-msg {
    display: block;
}

/* ========================================
   Smart Variant Box (Multiple Sizes) — NEW
   ======================================== */

#smart-variant-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 2px solid var(--border-color);
}

#smart-variant-box.smart-box-hidden { display: none; }

/* ── Top instruction / success message box (replaces old bottom warning) ── */
.chk-top-instruction {
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 16px;
    line-height: 1.5;
    font-weight: 500;
    transition: all 0.25s ease;
}

.chk-top-instruction.chk-instruction-default,
.chk-top-instruction:not(.chk-instruction-success) {
    background: var(--notice-bg);
    color: var(--notice-text);
    border-left: 4px solid var(--accent-color);
}

.chk-top-instruction.chk-instruction-success {
    background: var(--success-bg);
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

/* ========================================
   NEW: Size Selection Box
   ======================================== */

.size-selection-box {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

.size-box-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--field-bg-color);
    padding: 14px 16px;
    border-radius: var(--field-border-radius);
    border: var(--field-border-width) solid var(--field-border-color);
    transition: all 0.2s ease;
}

.size-box-item:hover {
    border-color: var(--accent-color);
    background: #fafbfc;
}

.size-box-label {
    flex: 1;
    display: flex;
    align-items: center;
}

.size-box-size {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--primary-text);
}

.size-box-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.size-qty-btn {
    background: white;
    border: 2px solid var(--border-color);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.size-qty-btn:hover:not(.disabled) {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.size-qty-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: #999;
    border-color: #ccc;
}

.size-qty-value {
    min-width: 28px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-text);
}

/* ========================================
   Order Summary
   ======================================== */

.chk-summary-box {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
}

.chk-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.95rem;
}

.chk-summary-row span:first-child {
    color: var(--secondary-text);
    font-weight: 500;
}

.chk-summary-row span:last-child {
    font-weight: 600;
    color: var(--primary-text);
}

.chk-grand-total {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--total-color);
}

.chk-summary-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 12px 0;
}

/* ========================================
   Form & Buttons
   ======================================== */

#premium-checkout-form {
    width: 100%;
}

.chk-btn-container-sticky {
    margin: 20px 0 16px;
}

.chk-confirm-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--accent-color), #20c997);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(40,167,69,0.25);
}

.chk-confirm-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(40,167,69,0.35);
    background: var(--button-hover-bg);
    color: var(--button-hover-color);
}

.chk-confirm-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chk-btn-text {
    display: block;
}

/* ========================================
   Mobile Help Section
   ======================================== */

.mobile-help-section {
    display: none;
    text-align: center;
    padding: 16px;
    background: #fff3cd;
    border-radius: 8px;
    margin-top: 12px;
}

.mobile-help-text {
    font-size: 0.9rem;
    color: #856404;
    margin: 0 0 10px;
}

.mobile-help-call-btn {
    display: inline-block;
    padding: 10px 16px;
    background: #ffc107;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.mobile-help-call-btn:hover {
    background: #ffb300;
    transform: scale(1.05);
}

/* ========================================
   Global Notice
   ======================================== */

.wcf-global-notice {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.wcf-notice-hidden { display: none; }

.wcf-notice-error {
    background: #fee;
    color: var(--error-color);
    border-left: 4px solid var(--error-color);
}

.wcf-notice-success {
    background: #efe;
    color: #28a745;
    border-left: 4px solid #28a745;
}

.wcf-notice-loading {
    background: #eef;
    color: #007bff;
    border-left: 4px solid #007bff;
}

/* ========================================
   Animations
   ======================================== */

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.5s ease-out;
}

/* ========================================
   Sticky Sidebar
   ======================================== */

.sticky-sidebar {
    position: sticky;
    top: 20px;
}

/* ========================================
   Column Layout
   ======================================== */

.chk-column-left {
    flex: 1;
}

.chk-column-right {
    flex: 1;
}

/* ========================================
   Tablet Layout (768px and below)
   ======================================== */

@media (max-width: 768px) {
    .chk-layout-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .chk-header {
        padding: 18px 16px;
    }

    .chk-header h2 { font-size: 1.5rem; }
    .chk-header p { font-size: 0.9rem; }

    .chk-card {
        padding: 16px;
    }

    .chk-product-top-row {
        gap: 12px;
    }

    .chk-img-wrapper {
        flex: 0 0 72px;
        width: 72px;
        height: 72px;
    }

    .chk-current-price { font-size: 1.05rem; }

    .chk-product-info h3 {
        font-size: 1rem;
    }

    .chk-price-qty-row {
        gap: 10px;
    }

    .chk-input-label { font-size: 0.9rem; }

    input[type="text"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px;
    }

    .size-selection-box {
        gap: 8px;
    }

    .size-box-item {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
    }

    .size-box-label {
        width: 100%;
        margin-bottom: 8px;
    }

    .size-box-controls {
        width: 100%;
        justify-content: center;
        gap: 8px;
        margin-left: 0;
    }

    .sticky-sidebar {
        position: relative;
        top: auto;
    }

    .mobile-help-section {
        display: block;
    }
}

/* ========================================
   Mobile Layout (480px and below)
   ======================================== */

@media (max-width: 480px) {
    .chk-header {
        padding: 16px 12px;
    }

    .chk-header h2 { font-size: 1.25rem; }
    .chk-header p { font-size: 0.85rem; }

    .chk-layout-container {
        padding: 0 8px 16px;
        gap: 12px;
    }

    .chk-card {
        padding: 12px;
        border-radius: 10px;
    }

    .chk-product-top-row {
        gap: 10px;
    }

    .chk-img-wrapper {
        flex: 0 0 60px;
        width: 60px;
        height: 60px;
        border-radius: 10px;
    }

    .chk-product-info {
        gap: 4px;
    }

    .chk-product-info h3 {
        font-size: 0.95rem;
        margin-bottom: 0;
        -webkit-line-clamp: 2;
    }

    .chk-current-price {
        font-size: 0.95rem;
    }

    .chk-price-qty-row {
        gap: 8px;
    }

    .chk-quantity-control {
        gap: 4px;
        padding: 2px;
    }

    .chk-qty-btn {
        width: 26px;
        height: 26px;
        font-size: 0.95rem;
    }

    .chk-input-label { font-size: 0.85rem; }

    .chk-input-wrapper {
        margin-bottom: 14px;
    }

    input[type="text"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px;
        padding: 10px 12px;
    }

    .size-selection-box {
        gap: 6px;
        padding: 0;
    }

    .size-box-item {
        padding: 10px 12px;
        border-radius: 8px;
    }

    .size-box-size {
        font-size: 0.9rem;
    }

    .size-qty-btn {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .size-qty-value {
        min-width: 24px;
        font-size: 0.95rem;
    }

    .chk-summary-box {
        padding: 12px;
        margin-bottom: 12px;
    }

    .chk-summary-row {
        font-size: 0.9rem;
        padding: 6px 0;
    }

    .chk-divider {
        margin: 12px 0;
    }

    .chk-confirm-btn {
        padding: 12px 16px;
        font-size: 1rem;
    }

    .wcf-global-notice {
        padding: 12px 16px;
        font-size: 0.9rem;
        margin-bottom: 12px;
    }
}

/* ========================================
   Desktop Fine-tuning (1024px+)
   ======================================== */

@media (min-width: 1024px) {
    .chk-layout-container {
        max-width: 1200px;
        gap: 32px;
    }

    .chk-card {
        padding: 28px;
    }

    .chk-summary-box {
        position: sticky;
        top: 20px;
    }

    .size-selection-box {
        gap: 12px;
    }

    .size-box-item {
        flex-direction: row;
    }

    .size-box-controls {
        margin-left: auto;
    }
}
