/* =========================================================
   CUSTOM CHECKOUT STYLES — v2.0 UNIFIED DESIGN
   File location: /wp-content/themes/YOUR-CHILD-THEME/assets/css/custom-checkout.css

   ✅ SAME DESIGN EVERYWHERE:
   - Checkout in drawer (from cart)
   - Direct /checkout URL
   - New tab open
   - AJAX loaded
   
   ✅ Desktop: Always 480px drawer from right
   ✅ Mobile: Always full screen
   ========================================================= */

/* =========================================================
   BASE CHECKOUT WRAPPER
   ========================================================= */
.custom-checkout-wrapper {
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #111;
    box-sizing: border-box;
}

/* =========================================================
   HEADER (hidden in drawer mode via JS, shown on direct URL)
   ========================================================= */
.cco-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 0 16px !important;
    margin: 0 !important;
}

.cco-back-btn {
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    border: 1.5px solid #e5e7eb !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #111 !important;
    text-decoration: none !important;
    background: #fff !important;
    cursor: pointer;
}

.cco-back-btn:hover {
    background: #f3f4f6 !important;
}

.cco-title {
    flex: 1;
    font-size: 24px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #111 !important;
    text-align: center !important;
}

.cco-summary-toggle-btn {
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    border: 1.5px solid #e5e7eb !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #111 !important;
    background: #fff !important;
    cursor: pointer;
}

.cco-summary-toggle-btn:hover {
    background: #f3f4f6 !important;
}

/* =========================================================
   NOTICES
   ========================================================= */
.cco-notices {
    margin-bottom: 16px;
}

.cco-notices .woocommerce-error,
.cco-notices .woocommerce-message,
.cco-notices .woocommerce-info {
    padding: 12px 16px;
    margin: 0 0 10px;
    border-radius: 8px;
    font-size: 14px;
}

.cco-notices .woocommerce-error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

/* =========================================================
   CARD SECTIONS
   ========================================================= */
.cco-card {
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.cco-section-title {
    font-size: 13px !important;
    font-weight: 800 !important;
    color: #111 !important;
    margin: 0 0 14px !important;
    padding: 0 !important;
    letter-spacing: 0.8px !important;
    line-height: 1.2 !important;
    text-transform: uppercase;
}

/* =========================================================
   ADDRESS SECTION
   ========================================================= */
.cco-address-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.cco-address-option:hover {
    border-color: #0c4740;
    background: #f0fdf4;
}

.cco-address-option input[type="radio"] {
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: #0c4740;
}

.cco-address-content {
    flex: 1;
    min-width: 0;
}

.cco-address-name {
    font-size: 16px;
    font-weight: 700;
    color: #111;
    margin-bottom: 6px;
}

.cco-address-text {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 4px;
}

.cco-address-phone {
    font-size: 14px;
    color: #111;
    font-weight: 600;
}

.cco-add-address-btn {
    width: 100%;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 14px !important;
    background: #f9fafb !important;
    border: 1.5px dashed #d1d5db !important;
    border-radius: 12px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #111 !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    margin-top: 4px !important;
}

.cco-add-address-btn:hover {
    background: #f3f4f6 !important;
    border-color: #0c4740 !important;
}

.cco-plus-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* =========================================================
   ADDRESS FORM
   ========================================================= */
.cco-address-form {
    margin-top: 14px;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
}

.cco-address-form-hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.cco-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.cco-form-field {
    margin-bottom: 12px;
}

.cco-form-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.cco-form-field .required {
    color: #ef4444;
}

.cco-form-field input[type="text"],
.cco-form-field input[type="email"],
.cco-form-field input[type="tel"],
.cco-form-field select {
    width: 100% !important;
    padding: 11px 14px !important;
    border: 1.5px solid #e5e7eb !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    color: #111 !important;
    background: #fff !important;
    transition: border-color 0.2s !important;
    box-sizing: border-box !important;
}

.cco-form-field input:focus,
.cco-form-field select:focus {
    outline: none !important;
    border-color: #0c4740 !important;
}

/* =========================================================
   ORDER SUMMARY
   ========================================================= */
.cco-summary-header {
    width: 100%;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    margin-bottom: 14px !important;
}

.cco-chevron {
    transition: transform 0.3s;
}

.cco-summary-header[aria-expanded="false"] .cco-chevron {
    transform: rotate(180deg);
}

.cco-summary-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
}

.cco-summary-content.cco-summary-collapsed {
    max-height: 0;
    opacity: 0;
}

.cco-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 15px;
}

.cco-summary-label {
    color: #6b7280;
    font-weight: 500;
}

.cco-summary-value {
    color: #111;
    font-weight: 700;
}

.cco-discount {
    color: #16a34a;
}

.cco-shipping-value strong {
    color: #16a34a;
}

.cco-summary-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 8px 0;
}

.cco-grand-total {
    padding: 10px 0 !important;
}

.cco-grand-total .cco-summary-label,
.cco-grand-total .cco-summary-value {
    font-size: 17px !important;
    font-weight: 700 !important;
}

/* =========================================================
   ITEMS DETAILS SECTION
   ========================================================= */
.cco-items-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.cco-items-toggle {
    width: 100%;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 0 !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
}

.cco-items-thumbs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.cco-thumb-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cco-thumb-img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.cco-thumb-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cco-thumb-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cco-items-chevron {
    flex-shrink: 0;
    transition: transform 0.3s;
}

.cco-items-toggle[aria-expanded="true"] .cco-items-chevron {
    transform: rotate(180deg);
}

.cco-items-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
}

.cco-items-details.cco-items-expanded {
    max-height: 2000px;
    opacity: 1;
    margin-top: 12px;
}

.cco-item-detail {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cco-item-detail:last-child {
    border-bottom: none;
}

.cco-item-detail-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.cco-item-detail-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cco-item-detail-info {
    flex: 1;
}

.cco-item-detail-name {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    margin: 0 0 4px;
}

.cco-item-detail-cat {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 6px;
}

.cco-detail-meta-row {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 3px;
}

.cco-detail-meta-row strong {
    color: #111;
}

.cco-item-detail-price {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    margin-top: 6px;
}

.cco-items-count {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 0;
    font-size: 14px;
    color: #6b7280;
}

.cco-items-count-num {
    font-weight: 600;
    color: #111;
}

/* =========================================================
   PAYMENT SECTION
   ========================================================= */
.cco-payment-section {
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.cco-payment-method {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.cco-payment-method:hover {
    border-color: #0c4740;
    background: #f0fdf4;
}

.cco-payment-method.cco-payment-cod {
    /* Optional: different style for COD */
}

.cco-payment-radio-visible {
    flex-shrink: 0;
    accent-color: #0c4740;
}

.cco-payment-num {
    flex-shrink: 0;
    font-weight: 700;
    color: #111;
    font-size: 16px;
}

.cco-payment-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: #111;
}

.cco-payment-or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}

.cco-or-line {
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.cco-or-text {
    font-size: 13px;
    color: #9ca3af;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.cco-no-payment {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* =========================================================
   ✅ WC ORDER REVIEW (Hidden but functional for gateways)
   ========================================================= */
#order_review {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

#order_review .shop_table {
    display: none !important;
}

#payment {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

#payment ul.payment_methods li {
    display: block !important;
}

#payment ul.payment_methods li input[type="radio"] {
    position: absolute !important;
    opacity: 0 !important;
}

#payment .payment_box {
    display: block !important;
}

#payment .woocommerce-terms-and-conditions-wrapper {
    display: none !important;
}

/* =========================================================
   PAY BUTTON
   ========================================================= */
.cco-pay-wrapper {
    margin-top: 0;
    padding: 0;
}

.cco-pay-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 16px !important;
    background: #0b4c44 !important;
    color: #ffffff !important;
    text-align: center !important;
    text-decoration: none !important;
    font-size: 17px !important;
    font-weight: 800 !important;
    letter-spacing: 0.5px !important;
    border-radius: 999px !important;
    box-shadow: 0 4px 14px rgba(11, 76, 68, 0.4) !important;
    transition: all 0.2s !important;
    border: none !important;
    cursor: pointer !important;
}

.cco-pay-btn:hover {
    background: #094037 !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(11, 76, 68, 0.5) !important;
}

.cco-pay-btn.loading {
    opacity: 0.7;
    cursor: wait;
}

/* =========================================================
   ✅ HIDE "View Available Coupons" Link
   ========================================================= */
.woocommerce-form-coupon-toggle,
.checkout_coupon,
a.showcoupon,
.woocommerce-info a.showcoupon {
    display: none !important;
}

/* Hide coupon notice if any */
.woocommerce-checkout .woocommerce-info {
    display: none !important;
}

/* =========================================================
   ✅ DESKTOP (≥992px) — UNIFIED DRAWER DESIGN
   Same design everywhere (popup, direct URL, new tab)
   ========================================================= */
@media (min-width: 992px) {

    /* When checkout is in drawer (from cart) - header hidden */
    .cc-drawer-popup .cco-header {
        display: none !important;
    }

    /* ✅ Direct /checkout URL → drawer style */
    body.woocommerce-checkout .custom-checkout-wrapper {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        width: 480px !important;
        max-width: 90vw !important;
        height: 100vh !important;
        margin: 0 !important;
        padding: 20px 20px 110px !important;
        border-radius: 20px 0 0 20px !important;
        box-shadow: -10px 0 50px rgba(0, 0, 0, 0.25) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        overscroll-behavior: contain !important;
        z-index: 99999 !important;
        background: #ffffff !important;
    }

    body.woocommerce-checkout .custom-checkout-wrapper::-webkit-scrollbar {
        width: 6px;
    }

    body.woocommerce-checkout .custom-checkout-wrapper::-webkit-scrollbar-thumb {
        background: #d1d5db;
        border-radius: 999px;
    }

    /* Pay button fixed at bottom on desktop */
    body.woocommerce-checkout .cco-pay-wrapper,
    .cc-drawer-popup .cco-pay-wrapper {
        position: fixed;
        bottom: 0;
        left: auto;
        right: 0;
        width: 480px;
        max-width: 90vw;
        padding: 14px 20px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
        z-index: 100;
        margin: 0;
    }

    /* Tighter spacing on desktop */
    .custom-checkout-wrapper .cco-card {
        padding: 16px;
        margin-bottom: 10px;
    }

    .custom-checkout-wrapper .cco-section-title {
        font-size: 12px !important;
        margin-bottom: 12px !important;
    }

    .custom-checkout-wrapper .cco-summary-row {
        font-size: 14px;
    }
}

/* =========================================================
   ✅ MOBILE (< 992px) — FULL SCREEN
   ========================================================= */
@media (max-width: 991px) {

    body.woocommerce-checkout .custom-checkout-wrapper {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        margin: 0 !important;
        padding: 20px 20px 100px !important;
        background: #ffffff !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        z-index: 99999 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        overscroll-behavior: contain !important;
    }

    /* Pay button sticky at bottom on mobile */
    .cco-pay-wrapper {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 14px 20px 20px;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
        z-index: 100;
    }
}

/* =========================================================
   LOADING STATES
   ========================================================= */
.cc-drawer-checkout-loading {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

.cc-drawer-checkout-loading .cc-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #0c4740;
    border-radius: 50%;
    animation: ccSpin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes ccSpin {
    to { transform: rotate(360deg); }
}

/* =========================================================
   ✅ HIDE UNWANTED WOOCOMMERCE DEFAULT ELEMENTS
   Desktop checkout page cleanup
   ========================================================= */

/* Hide default WooCommerce checkout wrapper */
body.woocommerce-checkout .woocommerce {
    /* Keep our custom wrapper visible */
}

body.woocommerce-checkout .woocommerce > *:not(.custom-checkout-wrapper) {
    /* Hide everything except our custom checkout */
    display: none !important;
}

/* Hide default WooCommerce form if any */
body.woocommerce-checkout form.checkout:not(.cco-form) {
    display: none !important;
}

/* Hide breadcrumbs on checkout */
body.woocommerce-checkout .woocommerce-breadcrumb {
    display: none !important;
}

/* Hide any WooCommerce notices wrapper outside our custom area */
body.woocommerce-checkout .woocommerce-notices-wrapper:not(.cco-notices *) {
    display: none !important;
}

/* Ensure only our custom checkout is visible */
@media (min-width: 992px) {
    body.woocommerce-checkout #primary,
    body.woocommerce-checkout .site-main,
    body.woocommerce-checkout .ast-container {
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    body.woocommerce-checkout #primary > *:not(.custom-checkout-wrapper),
    body.woocommerce-checkout .site-main > *:not(.custom-checkout-wrapper),
    body.woocommerce-checkout .ast-container > *:not(.custom-checkout-wrapper) {
        display: none !important;
    }
}

/* =========================================================
   GST & ROUND OFF STYLING (Checkout)
   ========================================================= */
.cco-summary-row.cco-gst-row {
    padding: 4px 0;
    font-size: 14px;
}

.cco-summary-row.cco-gst-row .cco-summary-label {
    color: #6b7280;
    font-weight: 500;
}

.cco-summary-row.cco-gst-row .cco-summary-value {
    color: #374151;
    font-weight: 600;
}

.cco-summary-row.cco-roundoff-row {
    padding: 4px 0;
    font-size: 14px;
}

.cco-summary-row.cco-roundoff-row .cco-summary-label {
    color: #6b7280;
    font-weight: 500;
}

.cco-summary-row.cco-roundoff-row .cco-summary-value {
    font-weight: 600;
}

.cco-roundoff-positive {
    color: #16a34a !important;
}

.cco-roundoff-negative {
    color: #dc2626 !important;
}

/* Grand total emphasis */
.cco-summary-row.cco-grand-total {
    padding: 8px 0 0 !important;
    margin-top: 6px !important;
}

.cco-summary-row.cco-grand-total .cco-summary-label,
.cco-summary-row.cco-grand-total .cco-summary-value {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: #111 !important;
}