/* ============================================
   BH COD Order System - Main Styles
   ============================================ */

:root {
    --bhcod-btn-color: #28a745;
    --bhcod-btn-hover: #218838;
}

/* ---- Product Page Buttons ---- */
.bhcod-buttons-wrap {
    width: 100%;
    padding-top: 12px;
    margin-bottom: 10px;
    clear: both;
}

/* ============================================
   Inline COD Button with Add to Cart
   Activates when body has .bhcod-cod-inline class
   ============================================ */
body.bhcod-cod-inline form.cart,
body.bhcod-cod-inline .cart,
body.bhcod-cod-inline form.variations_form.cart {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 10px !important;
}

/* Unwrap .bhcod-buttons-wrap so its children become direct flex items of form.cart */
body.bhcod-cod-inline .bhcod-buttons-wrap {
    display: contents !important;
}

/* COD button: inline, auto-width, sits next to Add to Cart */
body.bhcod-cod-inline .bhcod-cod-btn {
    width: auto !important;
    display: inline-flex !important;
    padding: 11px 18px !important;
    white-space: nowrap;
    font-size: 15px !important;
    min-height: 44px;
    margin: 0 !important;
    flex: 0 0 auto !important;
    order: 3;
}

/* Contact buttons (WhatsApp/Messenger/Phone) wrap to new row below */
body.bhcod-cod-inline .bhcod-contact-btns {
    flex-basis: 100% !important;
    width: 100% !important;
    margin-top: 12px !important;
    order: 10;
    display: flex !important;
    gap: 10px;
}

/* Make sure Add to Cart button + quantity stay compact */
body.bhcod-cod-inline form.cart .quantity {
    margin-right: 0 !important;
    flex: 0 0 auto;
    order: 1;
}

body.bhcod-cod-inline form.cart .single_add_to_cart_button {
    flex: 0 0 auto !important;
    margin: 0 !important;
    order: 2;
    width: auto !important;
}

/* Mobile: stack on small screens */
@media (max-width: 480px) {
    body.bhcod-cod-inline form.cart {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    body.bhcod-cod-inline .bhcod-cod-btn,
    body.bhcod-cod-inline form.cart .single_add_to_cart_button {
        width: 100% !important;
    }
    body.bhcod-cod-inline .bhcod-cod-btn {
        justify-content: center !important;
    }
}

.bhcod-cod-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #fff !important;
    background: var(--bhcod-btn-color) !important;
    border: none !important;
    outline: none !important;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
    box-shadow: 0 3px 10px rgba(40, 167, 69, 0.25);
    letter-spacing: 0.3px;
    line-height: 1.4;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.bhcod-cod-btn:hover {
    background: var(--bhcod-btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(40, 167, 69, 0.35);
}

.bhcod-cod-btn:active {
    transform: translateY(0);
}

.bhcod-cod-btn svg {
    flex-shrink: 0;
}

/* Contact Buttons */
.bhcod-contact-btns {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.bhcod-wa-btn,
.bhcod-msg-btn,
.bhcod-phone-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 11px 15px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.bhcod-wa-btn {
    background: #25D366;
}

.bhcod-wa-btn:hover {
    background: #1fb855;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

.bhcod-msg-btn {
    background: #0084FF;
}

.bhcod-msg-btn:hover {
    background: #006fdb;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.35);
}

.bhcod-wa-btn svg,
.bhcod-msg-btn svg,
.bhcod-phone-btn svg {
    flex-shrink: 0;
}

.bhcod-phone-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: #199f4b;
    transition: all 0.2s ease;
}

.bhcod-phone-btn:hover {
    background: #148a3f;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(25, 159, 75, 0.35);
}


/* ============================================
   Popup Overlay & Modal
   ============================================ */
.bhcod-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999998;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bhcod-overlay.active {
    display: block;
    opacity: 1;
}

.bhcod-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    width: 94%;
    max-width: 540px;
    max-height: 90vh;
    background: #fff;
    border-radius: 14px;
    z-index: 999999;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0,0,0,0.04);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.bhcod-popup.active {
    display: block;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.bhcod-popup-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 300;
    color: #666;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    line-height: 1;
}

.bhcod-popup-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* ---- Popup Header ---- */
.bhcod-popup-header {
    padding: 24px 28px 16px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(180deg, #f8fdf9 0%, #fff 100%);
    border-radius: 14px 14px 0 0;
}

.bhcod-popup-header h2 {
    margin: 0 0 2px;
    font-size: 22px;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1.3;
}

.bhcod-popup-header p {
    margin: 0;
    font-size: 15px;
    color: #555;
    font-weight: 500;
}

/* ---- Popup Body ---- */
.bhcod-popup-body {
    padding: 20px 28px 28px;
}

/* Form Fields */
.bhcod-form-section {
    margin-bottom: 20px;
}

.bhcod-field {
    margin-bottom: 14px;
}

.bhcod-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 700;
    color: #333;
}

.bhcod-field label .required {
    color: #e53e3e;
}

.bhcod-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

.bhcod-input-wrap:focus-within {
    border-color: var(--bhcod-btn-color);
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.12);
}

.bhcod-input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    color: #888;
    background: #f9f9f9;
    border-right: 1px solid #eee;
}

.bhcod-input-wrap input {
    flex: 1;
    border: none;
    padding: 11px 14px;
    font-size: 15px;
    outline: none;
    background: transparent;
    color: #333;
    width: 100%;
    box-shadow: none;
}

.bhcod-input-wrap input::placeholder {
    color: #aaa;
}

.bhcod-input-wrap input:focus {
    outline: none;
    box-shadow: none;
}

/* Shipping Options */
.bhcod-shipping-section {
    margin-bottom: 20px;
}

.bhcod-shipping-section h3 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.bhcod-shipping-options {
    border: 1.5px solid #e8e8e8;
    border-radius: 8px;
    padding: 12px 16px;
    background: #fafafa;
}

.bhcod-radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    font-size: 14px;
    color: #444;
    cursor: pointer;
    transition: color 0.2s;
}

.bhcod-radio-label:hover {
    color: #222;
}

.bhcod-radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--bhcod-btn-color);
    cursor: pointer;
    margin: 0;
}

/* Summary Table */
.bhcod-summary-section {
    margin-bottom: 20px;
}

.bhcod-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 14px;
}

.bhcod-summary-table thead th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 700;
    color: #555;
    background: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bhcod-summary-table tbody td {
    padding: 10px;
    vertical-align: middle;
    border-bottom: 1px solid #eee;
    color: #333;
}

.bhcod-product-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bhcod-product-cell img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #eee;
}

.bhcod-product-cell span {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
}

.bhcod-qty-input,
input[type="number"].bhcod-qty-input {
    width: 64px !important;
    padding: 6px 6px !important;
    text-align: center !important;
    border: 1.5px solid #ddd !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #222 !important;
    background: #fff !important;
    outline: none !important;
    transition: border-color 0.2s;
    opacity: 1 !important;
    line-height: 1.4 !important;
    height: auto !important;
    min-height: 34px !important;
    box-shadow: none !important;
    -webkit-text-fill-color: #222 !important;
}

.bhcod-qty-input::-webkit-inner-spin-button,
.bhcod-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: inner-spin-button !important;
    opacity: 1 !important;
    margin: 0;
}

.bhcod-qty-input:focus {
    border-color: var(--bhcod-btn-color) !important;
    box-shadow: none !important;
    outline: none !important;
    color: #222 !important;
    background: #fff !important;
}

/* Totals */
.bhcod-totals {
    border: 1.5px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
}

.bhcod-total-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 14px;
    color: #555;
    border-bottom: 1px solid #eee;
}

.bhcod-total-row:last-child {
    border-bottom: none;
}

.bhcod-grand-total {
    background: #f0fdf4;
    font-weight: 800;
    font-size: 16px;
    color: #16a34a;
    padding: 12px 16px;
}

/* Submit Button */
.bhcod-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 20px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    background: var(--bhcod-btn-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 14px rgba(40, 167, 69, 0.3);
    letter-spacing: 0.3px;
}

.bhcod-submit-btn:hover {
    background: var(--bhcod-btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.bhcod-submit-btn:active {
    transform: translateY(0);
}

.bhcod-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading State */
.bhcod-loading {
    text-align: center;
    padding: 50px 20px;
}

.bhcod-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #e8e8e8;
    border-top-color: var(--bhcod-btn-color);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: bhcod-spin 0.8s linear infinite;
}

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

.bhcod-loading p {
    font-size: 15px;
    color: #666;
    font-weight: 500;
}

/* Success State */
.bhcod-success {
    text-align: center;
    padding: 40px 28px;
}

.bhcod-success-icon {
    margin-bottom: 16px;
    animation: bhcod-checkmark 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bhcod-checkmark {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.bhcod-success h3 {
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: 800;
    color: #28a745;
}

.bhcod-success-msg {
    font-size: 15px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 24px;
}

.bhcod-close-success-btn {
    padding: 12px 40px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: var(--bhcod-btn-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.bhcod-close-success-btn:hover {
    background: var(--bhcod-btn-hover);
}

/* Error state for inputs */
.bhcod-input-wrap.bhcod-error {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.12);
}

.bhcod-field-error {
    color: #e53e3e;
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
    .bhcod-popup {
        width: 96%;
        max-height: 92vh;
        border-radius: 12px;
    }

    .bhcod-popup-header {
        padding: 20px 18px 14px;
    }

    .bhcod-popup-header h2 {
        font-size: 19px;
    }

    .bhcod-popup-body {
        padding: 16px 18px 22px;
    }

    .bhcod-contact-btns {
        flex-direction: column;
    }

    .bhcod-summary-table {
        font-size: 12px;
    }

    .bhcod-product-cell img {
        width: 40px;
        height: 40px;
    }

    .bhcod-submit-btn {
        font-size: 15px;
        padding: 13px 16px;
    }

    .bhcod-cod-btn {
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* ---- Prevent body scroll when popup open ---- */
body.bhcod-popup-open {
    overflow: hidden;
}

/* Free shipping badge */
.bhcod-free-badge {
    display: inline-block;
    padding: 3px 10px;
    background: linear-gradient(135deg, #28a745 0%, #16a34a 100%);
    color: #fff !important;
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.25);
    text-transform: uppercase;
}

/* ============================================
   Checkout Page Override Styles
   ============================================ */
.bhcod-checkout-wrap {
    max-width: 680px;
    margin: 0 auto 40px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0,0,0,0.04);
    overflow: hidden;
}

.bhcod-checkout-header {
    padding: 28px 32px 20px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(180deg, #f8fdf9 0%, #fff 100%);
}

.bhcod-checkout-header h2 {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1.3;
}

.bhcod-checkout-header p {
    margin: 0;
    font-size: 15px;
    color: #555;
    font-weight: 500;
}

.bhcod-checkout-body {
    padding: 24px 32px 32px;
}

/* Reuse existing form/shipping/summary/button styles inside checkout wrap */
.bhcod-checkout-wrap .bhcod-form-section,
.bhcod-checkout-wrap .bhcod-shipping-section,
.bhcod-checkout-wrap .bhcod-summary-section,
.bhcod-checkout-wrap .bhcod-submit-btn,
.bhcod-checkout-wrap .bhcod-loading,
.bhcod-checkout-wrap .bhcod-success {
    /* Inherits all existing popup styles */
}

/* WooCommerce Notices on Checkout Page */
.woocommerce-notices-wrapper .woocommerce-message {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1.5px solid #86efac;
    border-left: 5px solid var(--bhcod-btn-color, #28a745);
    border-radius: 10px;
    padding: 16px 22px;
    font-size: 14px;
    font-weight: 600;
    color: #166534;
    box-shadow: 0 2px 12px rgba(40, 167, 69, 0.12);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.woocommerce-notices-wrapper .woocommerce-message::before {
    content: "\2713";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    height: 28px;
    background: var(--bhcod-btn-color, #28a745);
    color: #fff;
    border-radius: 50%;
    font-size: 15px;
    font-weight: 700;
    margin-right: 4px;
}

.woocommerce-notices-wrapper .woocommerce-message .button {
    background: var(--bhcod-btn-color, #28a745);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.15s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.woocommerce-notices-wrapper .woocommerce-message .button:hover {
    background: var(--bhcod-btn-hover, #218838);
    transform: translateY(-1px);
    color: #fff;
}

.woocommerce-notices-wrapper .woocommerce-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1.5px solid #fca5a5;
    border-left: 5px solid #ef4444;
    border-radius: 10px;
    padding: 16px 22px;
    font-size: 14px;
    font-weight: 600;
    color: #991b1b;
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.1);
    margin-bottom: 24px;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

.woocommerce-notices-wrapper .woocommerce-info {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1.5px solid #93c5fd;
    border-left: 5px solid #3b82f6;
    border-radius: 10px;
    padding: 16px 22px;
    font-size: 14px;
    font-weight: 600;
    color: #1e40af;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
    margin-bottom: 24px;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 600px) {
    .woocommerce-notices-wrapper .woocommerce-message {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
        font-size: 13px;
    }

    .woocommerce-notices-wrapper .woocommerce-message .button {
        align-self: flex-end;
    }
}

/* Checkout success - add order ID style */
.bhcod-checkout-order-id {
    font-size: 14px;
    color: #777;
    margin-top: 6px;
    font-weight: 600;
}

@media (max-width: 600px) {
    .bhcod-checkout-wrap {
        margin: 0 auto 20px;
        border-radius: 10px;
    }

    .bhcod-checkout-header {
        padding: 20px 18px 16px;
    }

    .bhcod-checkout-header h2 {
        font-size: 20px;
    }

    .bhcod-checkout-body {
        padding: 16px 18px 24px;
    }
}
