/* ============================================
   COD PREMIUM FORM STYLES
   Uses Theme Color Palette: var(--primary)
   ============================================ */

/* Main Form Wrapper - Shadow + Border with Theme Color */
.cod-saudi-form-wrapper {
    background: #ffffff !important;
    border: 1px solid var(--primary) !important;
    border-radius: 20px !important;
    padding: 0 !important;
    margin-top: 25px;
    font-family: inherit !important;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08) !important;
    overflow: hidden;
}

/* Form Title Header - Theme Color Gradient */
.cod-form-title {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1) 0%, rgba(var(--primary-rgb), 0.05) 100%) !important;
    color: var(--primary) !important;
    text-align: center;
    font-size: 0.9rem !important;
    font-weight: 800 !important;
    margin: 0 !important;
    padding: 16px 20px !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-bottom: none !important;
}

/* Icon in header styled via PHP */
.cod-form-title svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Form Content */
.cod-form-v2 {
    padding: 25px !important;
}

/* ============================================
   COLOR/VARIATION SELECTOR - Modern Style
   ============================================ */
.cod-std-variations-wrap {
    margin-bottom: 15px;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

.cod-std-var-row {
    margin-bottom: 12px;
}

.cod-std-var-row:last-child {
    margin-bottom: 0;
}

/* Label with Selected Value */
.std-var-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 10px;
}

.std-var-label .selected-value {
    font-weight: 600;
    color: var(--primary);
}

.std-var-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.std-var-option {
    cursor: pointer;
    position: relative;
}

.std-var-option input[type="radio"] {
    display: none;
}

/* Color Swatches - Clean Circle with Subtle Default Border */
.std-swatch-color {
    display: inline-block;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all 0.25s ease;
    cursor: pointer;
    position: relative;
}

/* Hover Effect */
.std-var-option:hover .std-swatch-color {
    transform: scale(1.08);
    border-color: rgba(0, 0, 0, 0.25);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* Selected - Double Ring Effect (Primary Color) */
.std-var-option input[type="radio"]:checked+.std-swatch-color {
    border: 2px solid var(--primary);
    box-shadow: inset 0 0 0 2px #fff, 0 2px 8px rgba(var(--primary-rgb), 0.25);
    transform: scale(1);
}

/* Text Swatches (Sizes) - Compact Pills */
.std-swatch-text {
    display: inline-block;
    padding: 8px 16px;
    background: #ffffff;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    transition: all 0.25s ease;
    min-width: 40px;
    text-align: center;
}

/* Hover Effect */
.std-var-option:hover .std-swatch-text {
    border-color: var(--primary);
    color: var(--primary);
}

/* Selected Effect */
.std-var-option input[type="radio"]:checked+.std-swatch-text {
    border-color: var(--primary);
    border-width: 2px;
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
}

/* ============================================
   QUANTITY SELECTOR
   ============================================ */
.cod-quantity-selector-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 12px 18px;
    background: #fdfdfd;
    border: 1px dashed #e0e0e0;
    border-radius: 12px;
}

.cod-quantity-selector-wrap .qty-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--secondary);
}

.qty-control {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid #e5e5e5;
    border-radius: 10px;
    overflow: hidden;
    height: 40px;
}

.qty-btn {
    width: 36px;
    height: 100%;
    border: none;
    background: #f8f8f8;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    background: #eeeeee;
    color: var(--primary);
}

.qty-btn svg {
    pointer-events: none;
}

.cod-quantity-input {
    width: 45px !important;
    height: 100% !important;
    border: none !important;
    border-left: 1.5px solid #e5e5e5 !important;
    border-right: 1.5px solid #e5e5e5 !important;
    text-align: center !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: var(--primary) !important;
    margin: 0 !important;
    padding: 0 !important;
    appearance: textfield;
    -moz-appearance: textfield;
}

.cod-quantity-input::-webkit-outer-spin-button,
.cod-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ============================================
   INPUT FIELDS - With Icon Background
   ============================================ */
.cod-inputs-group {
    display: flex;
    flex-direction: column;
    gap: 12px !important;
    margin-bottom: 20px;
}

/* Two Column Layout for Name Fields */
.cod-inputs-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 500px) {
    .cod-inputs-row {
        grid-template-columns: 1fr;
    }
}

/* Input Wrapper */
.cod-input-wrap {
    position: relative !important;
    width: 100% !important;
    display: block !important;
}

.cod-input-wrap input {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 14px 16px 14px 60px !important;
    border: 1px solid #e5e5e5 !important;
    border-radius: 12px !important;
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    transition: all 0.3s ease !important;
    background: #ffffff !important;
    color: var(--secondary) !important;
    height: 52px !important;
    min-height: 52px !important;
}

/* RTL Support */
[dir="rtl"] .cod-input-wrap input {
    padding: 14px 60px 14px 16px !important;
    text-align: right !important;
}

.cod-input-wrap input::placeholder {
    color: #999999 !important;
    font-weight: 400 !important;
}

.cod-input-wrap input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1) !important;
    background: #fff !important;
    outline: none !important;
}

/* Input Icon - Full Height Background */
.cod-input-wrap .input-icon {
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 50px !important;
    height: 100% !important;
    background: rgba(var(--primary-rgb), 0.08) !important;
    border-radius: 12px 0 0 12px !important;
    color: var(--primary) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none !important;
    z-index: 10 !important;
    transform: none !important;
    border-right: 1px solid rgba(var(--primary-rgb, 19, 133, 133), 0.15) !important;
}

[dir="rtl"] .cod-input-wrap .input-icon {
    left: auto !important;
    right: 0 !important;
    border-radius: 0 12px 12px 0 !important;
    border-right: none !important;
    border-left: 1px solid rgba(var(--primary-rgb), 0.12) !important;
}

.cod-input-wrap .input-icon svg {
    width: 20px !important;
    height: 20px !important;
    stroke-width: 1.5 !important;
}

/* ============================================
   ORDER SUMMARY SECTION
   ============================================ */
.cod-order-summary {
    background: #f9f9f9 !important;
    border-radius: 14px !important;
    padding: 18px !important;
    margin-bottom: 15px !important;
    margin-top: 8px;
}

/* Shipping Badge - Pill Style */
.shipping-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid rgba(var(--primary-rgb), 0.1);
    border-radius: 25px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 15px;
}

.shipping-badge svg {
    width: 16px;
    height: 16px;
    color: #666666;
}

/* Summary Rows */
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.summary-row:last-child {
    margin-bottom: 0;
}

.summary-row .label {
    color: var(--secondary);
    font-weight: 700;
    font-size: 0.9rem;
}

.summary-row .value {
    font-weight: 700;
    color: var(--secondary);
}

.summary-row .value.success {
    color: #27ae60 !important;
}

/* Total Row - Highlighted */
.summary-row.total {
    border-top: none !important;
    padding-top: 8px;
    margin-top: 5px;
    margin-bottom: 0;
}

.summary-row.total .label {
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-row.total .value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary) !important;
}

/* Value Wrap for Total + Compare Price */
.summary-row.total .value-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Compare Price (Strikethrough) */
.summary-row.total .compare-price {
    font-size: 1rem;
    color: #bbbbbb;
    text-decoration: line-through;
    font-weight: 400;
}

/* ============================================
   SUBMIT BUTTON - Theme Color, Compact Padding
   ============================================ */
.cod-submit-btn {
    width: 100% !important;
    background: var(--primary) !important;
    color: white !important;
    border: none !important;
    padding: 14px 25px !important;
    font-size: 1rem !important;
    font-weight: 800 !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb, 19, 133, 133), 0.3) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.cod-submit-btn:hover {
    background: var(--primary-dark) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(var(--primary-rgb, 19, 133, 133), 0.4) !important;
}

.cod-submit-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 3px 12px rgba(var(--primary-rgb, 19, 133, 133), 0.25) !important;
}

/* ============================================
   OFFERS GRID
   ============================================ */
.cod-offers-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.cod-offer-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #eeeeee;
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    position: relative;
    overflow: hidden;
}

.cod-offer-card:hover {
    border-color: var(--primary);
}

.cod-offer-card.selected {
    border: 2px solid var(--primary);
    background: rgba(var(--primary-rgb), 0.06);
}

.cod-offer-card input[type="radio"] {
    display: none;
}

/* Card Header Layout */
.cod-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-direction: row-reverse;
}

.cod-card-price-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.cod-card-price-col .offer-price {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
}

.cod-card-price-col .offer-compare-price {
    font-size: 0.8rem;
    color: #999;
    text-decoration: line-through;
}

.cod-card-info-col {
    display: flex;
    align-items: center;
    gap: 12px;
}

.offer-img-wrap {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.offer-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.offer-text-wrap {
    text-align: right;
}

.offer-text-wrap .offer-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--secondary);
    margin: 0;
}

.badge-popular {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    margin-top: 5px;
    font-weight: 600;
}

/* ============================================
   BUNDLE VARIATIONS
   ============================================ */
.cod-offer-variations.bundle-style {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.cod-bundle-header {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    padding: 0 5px;
}

.bundle-head-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #888888;
}

.cod-bundle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.cod-item-num {
    width: 26px;
    height: 26px;
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.cod-bundle-select-wrap {
    position: relative;
    flex: 1;
}

.cod-bundle-select {
    width: 100%;
    padding: 10px 14px;
    padding-right: 35px;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    appearance: none;
    background: white;
    cursor: pointer;
}

.cod-bundle-select:focus {
    border-color: var(--primary);
    outline: none;
}

.cod-bundle-select-wrap .custom-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #888888;
}

[dir="rtl"] .cod-bundle-select-wrap .custom-arrow {
    right: auto;
    left: 12px;
}

/* ============================================
   POPUP PRODUCT LIST
   ============================================ */
.popup-product-list {
    margin-bottom: 18px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.popup-product-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #fafafa;
    border-radius: 12px;
    margin-bottom: 10px;
    position: relative;
}

.popup-product-card:last-child {
    margin-bottom: 0;
}

.popup-item-remove-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff5252;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.8;
}

[dir="rtl"] .popup-item-remove-btn {
    left: auto;
    right: 8px;
}

.popup-item-remove-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.item-info {
    flex: 1;
    padding-right: 35px;
}

[dir="rtl"] .item-info {
    padding-right: 0;
    padding-left: 35px;
}

.item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 4px;
}

.item-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-current-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
}

.item-compare-price {
    font-size: 0.8rem;
    color: #999;
    text-decoration: line-through;
}

.item-image-wrap {
    position: relative;
    width: 55px;
    height: 55px;
    border-radius: 10px;
    overflow: visible;
    /* Changed from hidden to show badge outside */
}

.item-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    /* Applied radius here since overflow is visible */
}

.item-qty-badge {
    position: absolute;
    top: -8px;
    /* Moved to top */
    right: -8px;
    /* Moved to right */
    width: 22px;
    height: 22px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    z-index: 5;
}

/* ============================================
   ERROR MESSAGE
   ============================================ */
#cod-form-error {
    background: rgba(var(--primary-rgb), 0.1) !important;
    border: 1px solid var(--primary) !important;
    color: #cc3333 !important;
    padding: 12px 16px !important;
    border-radius: 10px !important;
    font-size: 0.9rem !important;
    text-align: center !important;
    margin-bottom: 12px !important;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .cod-saudi-form-wrapper {
        border-radius: 16px !important;
        margin-top: 20px;
    }

    .cod-form-v2 {
        padding: 20px !important;
    }

    .cod-form-title {
        font-size: 0.85rem !important;
        padding: 14px 16px !important;
    }

    .cod-input-wrap input {
        height: 48px !important;
        min-height: 48px !important;
        font-size: 0.9rem !important;
    }

    .cod-submit-btn {
        padding: 12px 20px !important;
        font-size: 0.95rem !important;
    }

    .cod-order-summary {
        padding: 12px !important;
    }

    .shipping-badge {
        padding: 6px 12px;
        font-size: 0.75rem;
        margin-bottom: 10px;
    }

    .summary-row.total .label {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .summary-row.total .value {
        font-size: 1.15rem !important;
    }
}

@media (max-width: 480px) {
    .cod-form-v2 {
        padding: 16px !important;
    }

    .cod-inputs-group {
        gap: 10px !important;
    }

    .cod-offer-card {
        padding: 12px;
    }

    .cod-card-price-col .offer-price {
        font-size: 1.05rem;
    }

    .offer-img-wrap {
        width: 45px;
        height: 45px;
    }

    .cod-submit-btn {
        padding: 12px 18px !important;
    }
}

/* ============================================
   LANDER MODE OVERRIDES
   ============================================ */
.codleade-lander-mode .cod-saudi-form-wrapper {
    margin-top: 0;
    border-radius: 16px !important;
}

/* ============================================
   POPUP FORM OVERRIDES
   ============================================ */
/* Remove border from popup form */
.cod-popup-overlay .cod-saudi-form-wrapper,
#cod-popup-content .cod-saudi-form-wrapper,
.cod-popup-content .cod-saudi-form-wrapper {
    border: none !important;
    box-shadow: none !important;
}

/* Remove header background in popup */
.cod-popup-overlay .cod-form-title,
#cod-popup-content .cod-form-title,
.cod-popup-content .cod-form-title {
    background: transparent !important;
    padding: 0 0 15px 0 !important;
    margin-bottom: 15px !important;
    border-bottom: 1px solid #f0f0f0 !important;
}

/* Move close/remove button to opposite side (right to left) */
.popup-item-remove-btn {
    left: auto !important;
    right: 8px !important;
}

[dir="rtl"] .popup-item-remove-btn {
    right: auto !important;
    left: 8px !important;
}

/* Adjust item-info padding accordingly */
.item-info {
    padding-left: 35px !important;
    padding-right: 0 !important;
}

[dir="rtl"] .item-info {
    padding-right: 35px !important;
    padding-left: 0 !important;
}