/* =========================================================
   CUSTOM CHECKOUT PAGE STYLES — v1.1
   File location: /wp-content/themes/YOUR-CHILD-THEME/assets/css/custom-checkout.css

   Mobile/Tablet  — Full page mobile-app style design
   Desktop/Laptop — Loads inside cart drawer (right side popup)
   ========================================================= */

body.woocommerce-checkout {
    background: #f0f2f5;
}
.woocommerce-checkout .woocommerce-breadcrumb { display: none; }
.woocommerce-checkout .woocommerce-checkout-review-order { display: none !important; }

/* ---------- WRAPPER (mobile defaults) ---------- */
.custom-checkout-wrapper {
    max-width: 480px;
    width: 100%;
    margin: 20px auto;
    padding: 14px 14px 100px;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #111;
    box-sizing: border-box;
    border-radius: 20px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.08);
    position: relative;
}
.custom-checkout-wrapper *,
.custom-checkout-wrapper *::before,
.custom-checkout-wrapper *::after { box-sizing: border-box; }

/* ============================================================
   HEADER (mobile only — desktop drawer hides Checkout title)
   ============================================================ */
.cco-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap !important;
    gap: 12px !important;
    padding: 0 0 16px !important;
    width: 100% !important;
    margin: 0 !important;
}

.cco-back-btn,
.cco-summary-toggle-btn,
.cco-close-btn {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    flex: 0 0 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;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    transition: all 0.2s;
}
.cco-back-btn:hover,
.cco-summary-toggle-btn:hover,
.cco-close-btn:hover { background: #f3f4f6 !important; }

.cco-title {
    flex: 1 1 auto !important;
    font-size: 26px !important;
    font-weight: 700 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #111 !important;
    letter-spacing: -0.5px !important;
    text-align: center !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* ---------- CARDS ---------- */
.cco-card {
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.cco-section-title {
    font-size: 14px !important;
    font-weight: 800 !important;
    color: #111 !important;
    margin: 0 0 12px !important;
    padding: 0 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase;
}

/* ---------- ADDRESS ---------- */
.cco-add-address-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 8px 0;
    cursor: pointer;
    text-align: left;
    transition: opacity 0.2s;
}
.cco-add-address-btn:hover { opacity: 0.85; }

.cco-plus-icon {
    width: 50px;
    height: 50px;
    border: 2px solid #111;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    flex-shrink: 0;
    background: #fff;
    transition: all 0.2s;
}
.cco-add-address-btn:hover .cco-plus-icon { background: #f3f4f6; }

.cco-add-text { font-size: 16px; font-weight: 600; color: #111; }

.cco-address-saved {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.2s;
}
.cco-address-saved:has(input:checked),
.cco-address-saved.cco-selected {
    border-color: #0c4740;
    background: #f0f9f7;
}
.cco-address-saved input[type="radio"] {
    margin-top: 4px;
    accent-color: #0c4740;
    flex-shrink: 0;
}
.cco-address-content { flex: 1; min-width: 0; }
.cco-address-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.cco-address-text { font-size: 13px; color: #4b5563; line-height: 1.4; margin-bottom: 4px; }
.cco-address-phone { font-size: 13px; color: #6b7280; }

/* Address form */
.cco-address-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s, padding 0.3s, margin-top 0.3s;
}
.cco-address-form-hidden {
    max-height: 0 !important;
    opacity: 0 !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
    border-top: none !important;
}

.cco-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
.cco-form-field { margin-bottom: 10px; }
.cco-form-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 5px;
}
.cco-form-field label .required { color: #ef4444; }

.cco-form-field input,
.cco-form-field select,
.custom-checkout-wrapper .cco-form-field input[type="text"],
.custom-checkout-wrapper .cco-form-field input[type="email"],
.custom-checkout-wrapper .cco-form-field input[type="tel"],
.custom-checkout-wrapper .cco-form-field select {
    width: 100% !important;
    padding: 11px 14px !important;
    border: 1.5px solid #e5e7eb !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    color: #111 !important;
    background: #fafafa !important;
    outline: none !important;
    transition: all 0.2s !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    line-height: 1.4 !important;
    height: auto !important;
    margin: 0 !important;
}
.cco-form-field input:focus,
.cco-form-field select:focus {
    border-color: #0c4740 !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(12, 71, 64, 0.1) !important;
}
.cco-form-field input[readonly] {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
}
.cco-form-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%23111' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 12px !important;
    padding-right: 36px !important;
}

/* ---------- ORDER SUMMARY ---------- */
.cco-summary-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 0 12px !important;
    cursor: pointer !important;
}
.cco-summary-header .cco-section-title { margin: 0 !important; }
.cco-chevron { transition: transform 0.3s; color: #111; }
.cco-summary-header[aria-expanded="false"] .cco-chevron { transform: rotate(180deg); }

.cco-summary-content {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s, padding 0.3s;
    max-height: 3000px;
    opacity: 1;
}
.cco-summary-collapsed {
    max-height: 0 !important;
    opacity: 0 !important;
    padding: 0 !important;
}

.cco-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 16px;
}
.cco-summary-label { color: #111; font-weight: 500; }
.cco-summary-value { color: #111; font-weight: 700; }
.cco-shipping-value strong { color: #0c4740; }
.cco-summary-divider { height: 1px; background: #e5e7eb; margin: 8px 0; }

.cco-grand-total .cco-summary-label,
.cco-grand-total .cco-summary-value {
    font-size: 16px !important;
    font-weight: 800 !important;
}

.cco-items-section {
    margin-top: 12px;
    background: #f5f5f7;
    border-radius: 12px;
    padding: 6px;
}
.cco-items-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    background: transparent !important;
    border: none !important;
    padding: 6px !important;
    cursor: pointer !important;
    gap: 8px !important;
}
.cco-items-thumbs {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.cco-thumb-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.cco-thumb-img {
    width: 36px;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
}
.cco-thumb-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}
.cco-thumb-name {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.cco-items-chevron { color: #111; 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;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s, padding 0.3s, margin-top 0.3s;
    padding: 0 6px;
    margin-top: 0;
}
.cco-items-details.cco-items-expanded {
    max-height: 2000px !important;
    opacity: 1 !important;
    padding: 8px 6px 6px !important;
    margin-top: 6px !important;
    border-top: 1px solid #e5e7eb;
}

.cco-item-detail {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}
.cco-item-detail:last-child { border-bottom: none; }
.cco-item-detail-img {
    width: 70px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
}
.cco-item-detail-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}
.cco-item-detail-info { flex: 1; min-width: 0; }
.cco-item-detail-name {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #111 !important;
    margin: 0 0 4px !important;
    line-height: 1.3 !important;
}
.cco-item-detail-cat {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}
.cco-detail-meta-row {
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 2px;
}
.cco-detail-meta-row strong { color: #111; font-weight: 700; }
.cco-item-detail-price { font-size: 14px; font-weight: 700; color: #111; margin-top: 4px; }

.cco-items-count {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 6px 0;
    font-size: 13px;
    color: #6b7280;
}
.cco-items-count-num { font-weight: 600; }

/* ---------- PAYMENT METHOD ---------- */
.cco-payment-section { margin: 18px 0 0; }
.cco-payment-section .cco-section-title { margin: 0 0 12px !important; }

.cco-payment-method {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 14px 4px !important;
    cursor: pointer !important;
    border: none !important;
    background: transparent !important;
    margin: 0 !important;
}
.cco-payment-method input[type="radio"] {
    width: 20px !important;
    height: 20px !important;
    accent-color: #0c4740 !important;
    margin: 0 !important;
    flex-shrink: 0;
    cursor: pointer;
}
.cco-payment-num { font-size: 15px; font-weight: 600; color: #111; }
.cco-payment-title {
    font-size: 15px;
    font-weight: 600;
    color: #111;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}
.cco-payment-title img { max-height: 22px; width: auto; vertical-align: middle; }

.cco-payment-or {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 30px;
}
.cco-or-line { flex: 1; height: 1px; background: #d1d5db; }
.cco-or-text { font-size: 13px; color: #6b7280; font-style: italic; }

.cco-no-payment {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    background: #f9fafb;
    border-radius: 12px;
}

/* ============================================================
   ✅ PAY BUTTON — Mobile: fixed sticky | Desktop: inline
   ============================================================ */
.cco-pay-wrapper {
    /* Mobile default — sticky bottom */
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    padding: 12px 16px 16px;
    background: linear-gradient(to top, #fff 70%, rgba(255,255,255,0));
    z-index: 100;
}
.cco-pay-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 18px !important;
    background: linear-gradient(135deg, #c4f97a 0%, #7ed957 50%, #4cae3a 100%) !important;
    color: #111 !important;
    text-align: center !important;
    text-decoration: none !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    letter-spacing: 1px !important;
    border-radius: 999px !important;
    box-shadow: 0 4px 14px rgba(76, 174, 58, 0.35) !important;
    transition: all 0.2s !important;
    border: none !important;
    cursor: pointer !important;
    text-transform: uppercase !important;
}
.cco-pay-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(76, 174, 58, 0.45) !important;
    color: #111 !important;
}
.cco-pay-btn:active { transform: translateY(0); }
.cco-pay-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.cco-pay-btn-icon {
    color: #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}
.cco-pay-btn.loading { opacity: 0.8; pointer-events: none; }
.cco-pay-btn.loading .cco-pay-btn-text::after {
    content: '...';
    animation: ccoDots 1s infinite;
}
@keyframes ccoDots {
    0%, 20% { content: '.'; }
    40%     { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ============================================================
   ✅ DESKTOP / LAPTOP — INLINE PAY BUTTON (no fixed)
   Pay button right after payment methods, no scroll needed
   ============================================================ */
@media (min-width: 992px) {
    body.woocommerce-checkout {
        background: #f0f2f5;
    }
    .custom-checkout-wrapper {
        max-width: 520px;
        margin: 30px auto;
        padding: 20px 20px 30px;             /* ← Bottom padding kam (no fixed btn) */
    }

    /* Pay button INLINE — sticks right after payment methods */
    .cco-pay-wrapper {
        position: static !important;          /* ← NOT fixed on desktop */
        transform: none !important;
        bottom: auto !important;
        left: auto !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 16px 0 0 !important;
        background: none !important;
        z-index: auto !important;
        margin-top: 8px;
    }
}

/* Small mobile screens */
@media (max-width: 380px) {
    .custom-checkout-wrapper { margin: 12px auto; padding: 12px 12px 100px; }
    .cco-title { font-size: 22px !important; }
    .cco-form-row { grid-template-columns: 1fr; gap: 0; }
}

/* Hide WooCommerce default elements */
.woocommerce-checkout #order_review,
.woocommerce-checkout #order_review_heading,
.woocommerce-checkout .woocommerce-additional-fields,
.woocommerce-checkout .woocommerce-billing-fields > h3,
.woocommerce-checkout .woocommerce-shipping-fields,
.woocommerce-checkout .woocommerce-NoticeGroup-checkout {
    display: none !important;
}

/* Notice/error styling */
.woocommerce-checkout .woocommerce-error,
.woocommerce-checkout .woocommerce-message,
.woocommerce-checkout .woocommerce-info,
.cco-notices .woocommerce-error,
.cco-notices .woocommerce-message,
.cco-notices .woocommerce-info {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    padding: 12px 16px;
    margin: 0 0 14px;
    border-radius: 8px;
    font-size: 14px;
    color: #991b1b;
    list-style: none;
}
.cco-notices .woocommerce-message {
    background: #f0fdf4;
    border-left-color: #0c4740;
    color: #166534;
}
.cco-notices .woocommerce-info {
    background: #eff6ff;
    border-left-color: #3b82f6;
    color: #1e40af;
}
.cco-notices ul,
.cco-notices ul li {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* =========================================================
   ✅ DRAWER MODE — Checkout inside cart drawer (desktop)
   When checkout opens via cart drawer on desktop/laptop
   ========================================================= */
@media (min-width: 992px) {

    /* When checkout is loaded inside the drawer */
    .cc-drawer-popup .custom-checkout-wrapper,
    #cc-cart-drawer .custom-checkout-wrapper,
    .custom-cart-wrapper .custom-checkout-wrapper {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* Hide "Checkout" title in drawer mode (drawer header already has its own) */
    .cc-drawer-popup .cco-header,
    #cc-cart-drawer .cco-header,
    .custom-cart-wrapper.cc-drawer-checkout-mode .cco-header {
        display: none !important;
    }

    /* Make sure pay button stays inline inside drawer */
    .cc-drawer-popup .cco-pay-wrapper,
    #cc-cart-drawer .cco-pay-wrapper,
    .custom-cart-wrapper.cc-drawer-checkout-mode .cco-pay-wrapper {
        position: static !important;
        transform: none !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 16px 0 0 !important;
        background: none !important;
        margin-top: 8px;
    }
}

/* Mobile drawer mode (when checkout loads inside mobile full-screen drawer) */
@media (max-width: 991px) {
    .cc-drawer-popup .custom-checkout-wrapper {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 0 100px !important;
        background: transparent !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    .cc-drawer-popup .cco-header {
        display: none !important;            /* Hide checkout's own header in drawer */
    }
}

/* Drawer mode header replacement — uses cart's existing header */
.custom-cart-wrapper.cc-drawer-checkout-mode .cc-title {
    /* Title can change to "Checkout" via JS */
}

/* Loading state when switching cart → checkout */
.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); }
}