/* ========================================
   WooCommerce CartFlows Custom Checkout Widget
   Frontend Styles — v3.2.0
   Author: REAJUL ISLAM | WhatsApp: 01997165659
   ======================================== */

#checkout-main-wrapper {
    --bg-color: #F7F7F7;
    --card-bg: #FFFFFF;
    --primary-text: #111111;
    --secondary-text: #555555;
    --accent-color: #990012;
    --accent-light: #FDF2F3;
    --success-color: #10B981;
    --success-hover: #059669;
    --border-color: #E5E5E5;
    --radius: 18px;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.04);

    background-color: var(--bg-color);
    padding: 40px 16px;
    font-family: 'Hind Siliguri', 'Inter', sans-serif;
    color: var(--primary-text);
    max-width: 1100px;
    margin: 0 auto;
    box-sizing: border-box;
}

#checkout-main-wrapper *,
#checkout-main-wrapper *::before,
#checkout-main-wrapper *::after {
    box-sizing: border-box;
}

/* ========================================
   Header
   ======================================== */

.chk-header {
    text-align: center;
    margin-bottom: 35px;
}

.chk-header h2 {
    font-size: 1.85rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary-text);
}

.chk-header p {
    font-size: 1.05rem;
    color: var(--secondary-text);
    margin: 0;
}

/* ========================================
   Layout Container
   ======================================== */

.chk-layout-container {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 30px;
    align-items: start;
}

.chk-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-soft);
}

.chk-column-left  { order: 1; }
.chk-column-right { order: 2; }

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

/* ========================================
   Product Card
   Image one side; beside it: Name on top,
   Price + Quantity together on the next line.
   Same structure on desktop, tablet, and mobile.
   ======================================== */

.chk-product-card {
    margin-bottom: 14px;
}

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

.chk-img-wrapper {
    flex: 0 0 96px;
    width: 96px;
    height: 116px;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f5f5;
}

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

.chk-product-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.chk-product-info h3 {
    font-size: 1.08rem;
    font-weight: 700;
    margin: 0;
    color: var(--primary-text);
    line-height: 1.35;
    word-break: break-word;
}

/* Price + Quantity sit together on one line, beside each other.
   No wrap — they must never break onto separate lines on any screen size. */
.chk-price-qty-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: nowrap;
}

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

.chk-original-price {
    font-size: 1rem;
    color: var(--secondary-text);
    text-decoration: line-through;
}

.chk-discount-badge {
    background: var(--accent-color);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ========================================
   Quantity Control — sits beside the price
   ======================================== */

.chk-quantity-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    width: fit-content;
    flex-shrink: 0;
    margin: 0;
}

.chk-qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    font-size: 1.15rem;
    cursor: pointer;
    color: var(--accent-color);
    font-weight: 700;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.chk-qty-btn:hover { background: var(--accent-light); }
.chk-qty-btn:active { transform: scale(0.95); }

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

/* ========================================
   Dividers
   ======================================== */

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

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

/* ========================================
   Input Wrapper & Form Elements
   ======================================== */

.chk-input-wrapper {
    margin-bottom: 22px;
    position: relative;
}

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

#chk-name,
#chk-phone,
#chk-address,
#single-size-picker,
#chk-delivery-area {
    width: 100%;
    padding: 13px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.25s ease;
    color: var(--primary-text);
    background: var(--card-bg);
}

#chk-name:focus,
#chk-phone:focus,
#chk-address:focus,
#single-size-picker:focus,
#chk-delivery-area:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(153, 0, 18, 0.1);
}

#chk-address {
    resize: vertical;
    min-height: 90px;
}

/* ========================================
   Custom Select Styling
   ======================================== */

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

.chk-select-custom select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23990012' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* ========================================
   Error Messages
   ======================================== */

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

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

.chk-error-hidden {
    display: none !important;
}

.chk-input-wrapper.chk-error input,
.chk-input-wrapper.chk-error textarea,
.chk-input-wrapper.chk-error select {
    border-color: var(--accent-color) !important;
    background-color: var(--accent-light);
}

.chk-input-wrapper:not(.chk-error) input,
.chk-input-wrapper:not(.chk-error) textarea,
.chk-input-wrapper:not(.chk-error) select {
    border-color: var(--border-color);
    background-color: var(--card-bg);
}

.variant-mismatch-error {
    display: none;
    color: var(--accent-color);
    font-size: 0.88rem;
    padding: 10px 14px;
    background: var(--accent-light);
    border-radius: 8px;
    margin-top: 10px;
    border-left: 4px solid var(--accent-color);
}

.variant-mismatch-error.show { display: block; }

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

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

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

.smart-box-notice {
    background: var(--accent-light);
    border-left: 4px solid var(--accent-color);
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--primary-text);
    margin-bottom: 16px;
    line-height: 1.5;
}

.smart-box-notice strong { display: block; margin-bottom: 4px; }
.smart-box-notice span { font-weight: 600; color: var(--accent-color); }

#variant-rows-container {
    margin-bottom: 14px;
    max-height: 420px;
    overflow-y: auto;
}

.variant-row {
    background: var(--bg-color);
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    margin-bottom: 8px;
    transition: border-color 0.2s ease;
}

.variant-row:hover { border-color: var(--accent-color); }

.variant-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.variant-row-header span {
    font-weight: 600;
    color: var(--secondary-text);
    font-size: 0.9rem;
}

.variant-row-close {
    background: var(--accent-light);
    color: var(--accent-color);
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.variant-row-close:hover { background: var(--accent-color); color: white; }

/* Size row = two-column: size selector grows on the left, quantity badge
   stays compact on the right — same on mobile and desktop. */
.variant-row-content {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: flex-end;
}

.variant-row-select {
    flex: 1 1 auto;
    min-width: 0;
}

.variant-row-select label {
    font-size: 0.85rem;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
    color: var(--secondary-text);
}

.variant-row-select select {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
}

/* Quantity column: right-aligned, compact, read-only (always "1") */
.variant-row-quantity {
    flex: 0 0 auto;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.variant-row-quantity-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-text);
    display: block;
    margin-bottom: 5px;
    white-space: nowrap;
}

.row-quantity-static {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 38px;
    padding: 0 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-text);
    background: var(--card-bg);
}

/* Add-size button */
.chk-add-row-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-light);
    border: 2px dashed var(--accent-color);
    color: var(--accent-color);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 10px;
}

.chk-add-row-btn:hover:not(:disabled) {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.chk-add-row-btn:disabled,
.chk-add-row-btn.btn-locked {
    opacity: 0.45;
    cursor: not-allowed;
    background: #eee;
    border-color: #ccc;
    color: #999;
}

/* ========================================
   Summary Box
   ======================================== */

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

.chk-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1rem;
    color: var(--primary-text);
}

.chk-summary-row span:first-child { font-weight: 500; }
.chk-summary-row span:last-child  { font-weight: 600; }

.chk-grand-total {
    font-size: 1.12rem;
    font-weight: 700;
    color: var(--accent-color);
    padding: 10px 0;
}

#dynamic-summary-manifest {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.manifest-item {
    font-size: 0.9rem;
    color: var(--secondary-text);
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.manifest-item span:first-child { color: var(--primary-text); }

/* ========================================
   Submit Button
   ======================================== */

.chk-btn-container-sticky { margin-top: 18px; }

.chk-confirm-btn {
    width: 100%;
    padding: 15px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(153, 0, 18, 0.28);
}

.chk-confirm-btn:hover:not(:disabled) {
    background: #7a000e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(153, 0, 18, 0.38);
}

.chk-confirm-btn:active:not(:disabled) { transform: translateY(0); }

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

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

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

.mobile-help-section {
    margin-top: 16px;
    padding: 14px 16px;
    background: #fff8f8;
    border-radius: 10px;
    border: 1.5px solid #f5c0c5;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mobile-help-text {
    margin: 0;
    font-size: 0.95rem;
    color: var(--secondary-text);
    line-height: 1.5;
}

.mobile-help-call-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: var(--accent-color);
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(153, 0, 18, 0.22);
}

.mobile-help-call-btn:hover {
    background: #7a000e;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

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

@keyframes animate-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes animate-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in  { animation: animate-fade-in  0.6s ease-out; }
.animate-slide-up { animation: animate-slide-up 0.6s ease-out; }

/* ========================================
   Mobile Responsive — 768px and below
   ======================================== */

@media (max-width: 768px) {
    #checkout-main-wrapper {
        padding: 20px 12px;
    }

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

    .chk-layout-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Mobile: product column first, form column second */
    .chk-column-left  { order: 1; }
    .chk-column-right { order: 2; }

    .chk-card { padding: 16px; }

    .sticky-sidebar { position: static; }

    /* Same layout as desktop (image beside name, price+qty together below) —
       just slightly smaller sizing so nothing crowds on a narrow screen. */
    .chk-img-wrapper {
        flex: 0 0 84px;
        width: 84px;
        height: 100px;
    }

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

    .chk-product-info h3 {
        font-size: 0.98rem;
        line-height: 1.3;
    }

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

    .chk-quantity-control { padding: 3px; }

    .chk-qty-btn {
        width: 27px;
        height: 27px;
        font-size: 1.05rem;
    }

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

    /* Size row: keep two-column on tablet */
    .variant-row-content {
        flex-direction: row;
        gap: 10px;
        align-items: flex-end;
    }

    .variant-row-quantity {
        text-align: right;
        align-items: flex-end;
    }
}

/* ========================================
   Mobile Responsive — 480px and below
   ======================================== */

@media (max-width: 480px) {
    #checkout-main-wrapper { padding: 14px 8px; }

    .chk-header { margin-bottom: 20px; }
    .chk-header h2 { font-size: 1.25rem; }
    .chk-header p  { font-size: 0.92rem; }

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

    /* Still the same layout — image beside name, price+qty together below —
       just a bit smaller so it fits comfortably on very narrow screens. */
    .chk-img-wrapper {
        flex: 0 0 72px;
        width: 72px;
        height: 88px;
    }

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

    .chk-product-info h3 {
        font-size: 0.9rem;
        line-height: 1.25;
    }

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

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

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

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

    .chk-qty-value {
        min-width: 22px;
        font-size: 0.88rem;
    }

    /* Prevent iOS zoom on inputs */
    #chk-name,
    #chk-phone,
    #chk-address,
    #single-size-picker,
    #chk-delivery-area {
        padding: 12px 13px;
        font-size: 16px;
    }

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

    /* ── FIX #1: Extra bottom padding so button isn't hidden by bottom nav ── */
    .chk-btn-container-sticky {
        padding-bottom: 4px;
    }

    /* Size row on small mobile: keep two columns but adjust spacing */
    .variant-row-content {
        flex-direction: row;
        gap: 8px;
        align-items: flex-end;
    }

    .variant-row-select select {
        font-size: 14px;
        padding: 8px 10px;
    }

    .variant-row-quantity {
        flex: 0 0 auto;
        align-items: flex-end;
    }

    /* Reduce vertical whitespace in variant rows */
    .variant-row {
        padding: 10px 12px;
    }

    .variant-row-header {
        margin-bottom: 6px;
    }
}

/* ========================================
   Utility / Misc
   ======================================== */

.wcf-no-product,
.wcf-product-error {
    text-align: center;
    padding: 30px;
    border-radius: var(--radius);
    background: #f0f0f0;
}

.wcf-product-error { background: #fee; }

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

.wcf-global-notice {
    padding: 13px 18px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 22px;
    text-align: center;
    transition: all 0.3s ease;
}

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

.wcf-notice-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1.5px solid #FECACA;
}

.wcf-notice-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1.5px solid #A7F3D0;
}

.wcf-notice-loading {
    background: #EFF6FF;
    color: #1E40AF;
    border: 1.5px solid #BFDBFE;
    animation: wcf-pulse 1.2s ease-in-out infinite;
}

@keyframes wcf-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

/* Variant row error */
.variant-row.row-error .row-size-selector {
    border-color: var(--accent-color) !important;
    background: #FFF5F5;
}

/* ========================================
   Desktop spacing cleanup — compact variant rows
   ======================================== */
@media (min-width: 769px) {
    .variant-row {
        padding: 10px 14px;
        margin-bottom: 8px;
    }

    .variant-row-content {
        gap: 14px;
    }

    .variant-row-quantity {
        min-width: 0;
        align-items: flex-end;
    }

    #variant-rows-container {
        margin-bottom: 10px;
    }

    .smart-box-notice {
        padding: 10px 14px;
        margin-bottom: 12px;
    }
}
