/* COD Manager - Pre-Checkout Overlay */

.codm-pco-overlay * { box-sizing: border-box; }
.codm-pco-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.55); z-index: 999999;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}

/* Container — true full-screen on mobile, fixed card on desktop */
.codm-pco-container {
    background: #f5f5f0; position: relative;
    display: flex; flex-direction: column; overflow: hidden;
    width: 100vw; height: 100vh; height: 100dvh;
    max-width: 100vw; max-height: 100vh; max-height: 100dvh;
    border-radius: 0;
}
@media (min-width: 600px) {
    .codm-pco-container {
        width: 440px; height: 680px;
        max-width: 440px; max-height: 680px;
        border-radius: 16px;
        box-shadow: 0 8px 40px rgba(0,0,0,0.25);
    }
}
@media (min-width: 900px) {
    .codm-pco-container {
        width: 460px; height: 700px;
        max-width: 460px; max-height: 700px;
    }
}

.codm-pco-content {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Header */
.codm-pco-header {
    display: flex; align-items: center; padding: 10px 12px;
    background: #fff; border-bottom: 1px solid #eee;
    flex-shrink: 0; gap: 6px; min-height: 46px;
}
.codm-pco-back { background: none; border: none; font-size: 20px; cursor: pointer; color: #333; padding: 2px 4px; flex-shrink: 0; line-height: 1; }
.codm-pco-store { font-size: 12px; font-weight: 600; padding: 3px 8px; border: 1px solid #ddd; border-radius: 5px; white-space: nowrap; flex-shrink: 0; }
.codm-pco-steps { display: flex; align-items: center; gap: 2px; font-size: 11px; color: #999; margin-left: auto; white-space: nowrap; overflow: hidden; }
.codm-step { transition: color 0.2s; }
.codm-step.active { color: #333; font-weight: 600; }
.codm-step.done { color: #4caf50; }
.codm-step-line { color: #ccc; font-size: 9px; margin: 0 1px; }
.codm-pco-close { background: none; border: none; font-size: 16px; cursor: pointer; color: #999; padding: 4px; flex-shrink: 0; }

/* Alert */
.codm-pco-alert { background: #e53935; color: #fff; text-align: center; padding: 7px 14px; font-size: 12px; font-weight: 500; flex-shrink: 0; }

/* Steps */
.codm-pco-step { padding: 14px; }

/* Step 0: Loading */
#codm-pco-step-0 {
    display: flex; align-items: center; justify-content: center;
    min-height: 100%; text-align: center; padding: 40px 20px;
    background: linear-gradient(135deg, #f0faf0 0%, #f5f5f0 50%, #f0f5fa 100%);
}
.codm-pco-loading h3 { margin: 14px 0 4px; font-size: 16px; color: #333; font-weight: 600; }
.codm-pco-loading p { margin: 0; font-size: 13px; color: #888; }
.codm-pco-loader-icon {
    width: 56px; height: 56px; margin: 0 auto;
    background: #fff; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    display: flex; align-items: center; justify-content: center;
}
.codm-pco-spinner { width: 24px; height: 24px; border: 3px solid #eee; border-top-color: #333; border-radius: 50%; animation: codm-spin 0.8s linear infinite; }
@keyframes codm-spin { to { transform: rotate(360deg); } }
.codm-pco-dots { margin-top: 14px; display: flex; gap: 5px; justify-content: center; }
.codm-pco-dots span { width: 7px; height: 7px; border-radius: 50%; background: #ccc; animation: codm-dot-pulse 1.2s ease-in-out infinite; }
.codm-pco-dots span:nth-child(2) { animation-delay: 0.2s; }
.codm-pco-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes codm-dot-pulse { 0%,100%{opacity:.4} 50%{opacity:1} }

/* Order Summary */
.codm-pco-summary-card { background: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.codm-pco-summary-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 6px; }
.codm-pco-summary-total { font-weight: 700; color: #222; font-size: 14px; }
.codm-pco-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px solid #f0f0f0; }
.codm-pco-item-img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; border: 1px solid #eee; flex-shrink: 0; }
.codm-pco-item-name { font-size: 12px; color: #555; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Phone Input ───────────────────────────────────────── */
.codm-pco-section { background: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.codm-pco-label { font-size: 12px; color: #666; margin-bottom: 8px; display: block; }
.codm-pco-phone-row {
    display: flex; align-items: stretch;
    border: 1px solid #ddd; border-radius: 8px; overflow: hidden; height: 48px;
}
.codm-pco-cc-wrap {
    flex: 0 0 90px; width: 90px; min-width: 90px; max-width: 90px;
    border-right: 1px solid #eee; background: #fafafa;
    display: flex; align-items: center; position: relative;
}
.codm-pco-cc-select {
    width: 100%; height: 100%; border: none; background: transparent;
    font-size: 15px; font-weight: 500; padding: 0 22px 0 12px; outline: none;
    cursor: pointer; color: #333;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center; background-size: 8px;
}
.codm-pco-phone-input {
    flex: 1; min-width: 0; border: none; padding: 0 14px;
    font-size: 16px; outline: none; background: #fff; height: 100%;
}
.codm-pco-phone-input::placeholder { color: #bbb; }

/* Action Button */
.codm-pco-action { background: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.codm-pco-btn {
    width: 100%; padding: 14px; background: #111; color: #fff;
    border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: background 0.2s;
}
.codm-pco-btn:hover { background: #333; }
.codm-pco-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Footer Text */
.codm-pco-footer-text { text-align: center; font-size: 10px; color: #aaa; padding: 6px 14px 14px; }
.codm-pco-footer-text a { color: #999; text-decoration: none; }

/* OTP */
.codm-pco-otp-section { background: #fff; border-radius: 14px; padding: 24px 16px; margin: 20px 0 12px; text-align: center; }
.codm-pco-otp-icon { font-size: 40px; margin-bottom: 6px; }
.codm-pco-otp-section h3 { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: #222; }
.codm-pco-otp-sub { color: #888; font-size: 12px; margin: 0 0 14px; }
.codm-pco-otp-sent { font-size: 12px; color: #555; margin-bottom: 16px; }
.codm-pco-otp-sent a { color: #1976d2; text-decoration: none; font-weight: 600; }
.codm-pco-otp-boxes { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.codm-pco-otp-digit {
    width: 46px; height: 52px; border: 2px solid #ddd; border-radius: 8px;
    text-align: center; font-size: 20px; font-weight: 700; outline: none;
    background: #fafafa; transition: border-color 0.2s;
}
.codm-pco-otp-digit:focus { border-color: #333; background: #fff; }
.codm-pco-otp-status { font-size: 12px; min-height: 18px; margin: 6px 0; }
.codm-pco-otp-status.success { color: #2e7d32; }
.codm-pco-otp-status.error { color: #c62828; }
.codm-pco-otp-status.verifying { color: #666; }
.codm-pco-otp-resend { font-size: 11px; color: #888; margin-top: 10px; }
.codm-pco-otp-resend a { color: #333; text-decoration: none; font-weight: 600; border: 1px solid #ddd; padding: 5px 12px; border-radius: 5px; display: inline-block; }

/* Address */
.codm-pco-address-form { background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.codm-pco-address-form h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; color: #222; }
.codm-pco-field { margin-bottom: 12px; }
.codm-pco-field label { display: block; font-size: 12px; color: #555; margin-bottom: 4px; }
.codm-pco-field .req { color: #e53935; }
.codm-pco-field .codm-optional { color: #aaa; font-size: 11px; }
.codm-pco-field input, .codm-pco-field select {
    width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 7px;
    font-size: 14px; outline: none; background: #fff; transition: border-color 0.2s;
}
.codm-pco-field input:focus, .codm-pco-field select:focus { border-color: #333; }
.codm-pco-divider { border: none; border-top: 1px solid #eee; margin: 16px 0; }

/* Logged-in footer */
.codm-pco-logged-in {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; background: #fff; border-top: 1px solid #eee; font-size: 11px; color: #888;
}
.codm-pco-logged-in strong { font-size: 13px; color: #222; }
.codm-pco-logged-in a { color: #333; text-decoration: none; font-size: 12px; border: 1px solid #ddd; padding: 5px 12px; border-radius: 5px; }

/* Delivery */
.codm-pco-delivery { background: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.codm-pco-delivery-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; }
.codm-pco-delivery-header a { color: #1976d2; text-decoration: none; font-weight: 600; font-size: 12px; }
.codm-pco-del-name { font-size: 13px; margin-bottom: 2px; }
.codm-pco-del-addr { font-size: 12px; color: #666; margin-bottom: 2px; word-break: break-word; }
.codm-pco-del-contact { font-size: 11px; color: #999; }
.codm-pco-tag { display: inline-block; background: #e8f5e9; color: #2e7d32; font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; margin-left: 4px; }

/* Timer */
.codm-pco-timer { text-align: center; font-size: 12px; color: #e65100; padding: 6px; margin-bottom: 10px; background: #fff3e0; border-radius: 7px; }

/* Payment Options */
.codm-pco-payment-options { background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.codm-pco-payment-options h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; color: #222; }
.codm-pco-option { border: 2px solid #e0e0e0; border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.codm-pco-option:hover { border-color: #bbb; }
.codm-pco-option.selected { border-color: #4caf50; background: #f8fdf8; }
.codm-pco-option-inner { display: flex; align-items: center; gap: 10px; padding: 12px; }
.codm-pco-option-icon { font-size: 20px; flex-shrink: 0; }
.codm-pco-option-info { flex: 1; min-width: 0; }
.codm-pco-option-title { font-size: 14px; font-weight: 700; color: #222; display: inline; }
.codm-pco-option-badge { display: inline-block; background: #e8f5e9; color: #2e7d32; font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; margin-left: 4px; }
.codm-pco-option-desc { font-size: 11px; color: #777; display: block; margin-top: 2px; }
.codm-pco-option-price { font-size: 16px; font-weight: 700; color: #222; white-space: nowrap; flex-shrink: 0; }
.codm-pco-option-radio { flex-shrink: 0; }
.codm-pco-option-radio input { width: 18px; height: 18px; accent-color: #4caf50; cursor: pointer; }
.codm-pco-tax-note { font-size: 10px; color: #aaa; text-align: right; margin: 4px 0 0; }
.codm-pco-cod-fee-note { font-size: 10px; color: #e65100; display: block; margin-top: 2px; }

/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — all phones (≤599px)
   Desktop styles above this line are NOT touched.
   ══════════════════════════════════════════════════════════ */

@media (max-width: 599px) {
    /* Overlay: pin to top to prevent header cutoff */
    .codm-pco-overlay {
        align-items: flex-start;
        justify-content: flex-start;
    }

    /* Container: true full screen with safe areas */
    .codm-pco-container {
        width: 100vw; height: 100vh; height: 100dvh;
        max-width: 100vw; max-height: 100vh; max-height: 100dvh;
        border-radius: 0; margin: 0;
    }

    /* Header: safe area for notch phones */
    .codm-pco-header {
        padding: 8px 12px;
        padding-top: max(8px, env(safe-area-inset-top, 8px));
        min-height: 44px; gap: 5px;
    }
    .codm-pco-back { font-size: 18px; padding: 2px; }
    .codm-pco-store { font-size: 12px; padding: 3px 8px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
    .codm-pco-steps { font-size: 11px; gap: 2px; }
    .codm-step-line { margin: 0 1px; font-size: 8px; }
    .codm-pco-close { font-size: 16px; padding: 4px; }

    /* Alert */
    .codm-pco-alert { font-size: 12px; padding: 6px 12px; }

    /* Steps padding */
    .codm-pco-step { padding: 12px; }

    /* Loading screen */
    #codm-pco-step-0 { padding: 30px 16px; }
    .codm-pco-loading h3 { font-size: 15px; }
    .codm-pco-loading p { font-size: 12px; }

    /* Order summary */
    .codm-pco-summary-card { padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; }
    .codm-pco-summary-header { font-size: 13px; }
    .codm-pco-summary-total { font-size: 14px; }
    .codm-pco-item { gap: 8px; padding: 4px 0; }
    .codm-pco-item-img { width: 34px; height: 34px; border-radius: 5px; }
    .codm-pco-item-name { font-size: 12px; }

    /* Phone input section */
    .codm-pco-section { padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; }
    .codm-pco-label { font-size: 12px; margin-bottom: 6px; }
    .codm-pco-phone-row { height: 48px; border-radius: 8px; }
    .codm-pco-cc-wrap {
        flex: 0 0 88px; width: 88px; min-width: 88px; max-width: 88px;
    }
    .codm-pco-cc-select {
        font-size: 15px; padding: 0 20px 0 10px;
    }
    .codm-pco-phone-input { font-size: 16px; padding: 0 10px; }

    /* Action button */
    .codm-pco-action { padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; }
    .codm-pco-btn { padding: 13px; font-size: 15px; border-radius: 8px; }

    /* Footer text */
    .codm-pco-footer-text { font-size: 10px; padding: 4px 12px 12px; }

    /* OTP section */
    .codm-pco-otp-section { padding: 20px 14px; margin: 14px 0 10px; border-radius: 12px; }
    .codm-pco-otp-icon { font-size: 36px; margin-bottom: 4px; }
    .codm-pco-otp-section h3 { font-size: 17px; }
    .codm-pco-otp-sub { font-size: 12px; margin-bottom: 12px; }
    .codm-pco-otp-sent { font-size: 12px; margin-bottom: 14px; }
    .codm-pco-otp-boxes { gap: 8px; margin-bottom: 12px; }
    .codm-pco-otp-digit { width: 44px; height: 50px; font-size: 20px; border-radius: 8px; }
    .codm-pco-otp-resend { font-size: 11px; }

    /* Address form */
    .codm-pco-address-form { padding: 12px; margin-bottom: 10px; border-radius: 8px; }
    .codm-pco-address-form h3 { font-size: 15px; margin-bottom: 10px; }
    .codm-pco-field { margin-bottom: 10px; }
    .codm-pco-field label { font-size: 12px; margin-bottom: 3px; }
    .codm-pco-field input, .codm-pco-field select {
        padding: 10px 10px; font-size: 14px; border-radius: 6px;
    }
    .codm-pco-divider { margin: 14px 0; }

    /* Logged-in footer */
    .codm-pco-logged-in { padding: 8px 12px; font-size: 11px;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
    }
    .codm-pco-logged-in strong { font-size: 12px; }
    .codm-pco-logged-in a { font-size: 11px; padding: 4px 10px; }

    /* Delivery details */
    .codm-pco-delivery { padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; }
    .codm-pco-delivery-header { font-size: 13px; }
    .codm-pco-del-name { font-size: 13px; }
    .codm-pco-del-addr { font-size: 11px; }
    .codm-pco-del-contact { font-size: 10px; }

    /* Timer */
    .codm-pco-timer { font-size: 12px; padding: 5px; border-radius: 6px; }

    /* Payment options */
    .codm-pco-payment-options { padding: 12px; margin-bottom: 10px; border-radius: 8px; }
    .codm-pco-payment-options h3 { font-size: 14px; margin-bottom: 10px; }
    .codm-pco-option { border-radius: 8px; margin-bottom: 8px; }
    .codm-pco-option-inner { padding: 10px; gap: 8px; }
    .codm-pco-option-icon { font-size: 18px; }
    .codm-pco-option-title { font-size: 13px; }
    .codm-pco-option-badge { font-size: 9px; padding: 1px 5px; }
    .codm-pco-option-desc { font-size: 11px; }
    .codm-pco-option-price { font-size: 15px; }
    .codm-pco-option-radio input { width: 18px; height: 18px; }
    .codm-pco-tax-note { font-size: 9px; }
}

/* ── Medium phones 360-414px (iPhone SE, Galaxy S series, Pixel) ── */
@media (max-width: 414px) {
    .codm-pco-step { padding: 10px; }
    .codm-pco-store { font-size: 11px; padding: 2px 6px; max-width: 100px; }
    .codm-pco-steps { font-size: 10px; }
    .codm-pco-cc-wrap {
        flex: 0 0 82px; width: 82px; min-width: 82px; max-width: 82px;
    }
    .codm-pco-cc-select { font-size: 14px; padding: 0 18px 0 8px; }
    .codm-pco-phone-input { font-size: 15px; padding: 0 8px; }
    .codm-pco-option-inner { padding: 10px 8px; gap: 6px; }
    .codm-pco-option-title { font-size: 13px; }
    .codm-pco-option-price { font-size: 14px; }
    .codm-pco-otp-digit { width: 42px; height: 48px; font-size: 19px; }
    .codm-pco-otp-boxes { gap: 7px; }
    .codm-pco-summary-card { padding: 8px 10px; }
}

/* ── Small phones ≤360px (iPhone SE 1st gen, Galaxy A series, older phones) ── */
@media (max-width: 360px) {
    .codm-pco-header { padding: 6px 8px; gap: 3px; min-height: 40px;
        padding-top: max(6px, env(safe-area-inset-top, 6px));
    }
    .codm-pco-back { font-size: 16px; }
    .codm-pco-store { font-size: 10px; padding: 2px 5px; max-width: 85px; }
    .codm-pco-steps { font-size: 9px; gap: 1px; }
    .codm-step-line { display: none; }
    .codm-pco-close { font-size: 14px; }
    .codm-pco-step { padding: 8px; }
    .codm-pco-section { padding: 8px 10px; }
    .codm-pco-cc-wrap {
        flex: 0 0 76px; width: 76px; min-width: 76px; max-width: 76px;
    }
    .codm-pco-cc-select { font-size: 13px; padding: 0 16px 0 6px; }
    .codm-pco-phone-input { font-size: 14px; padding: 0 6px; }
    .codm-pco-phone-row { height: 44px; }
    .codm-pco-btn { padding: 11px; font-size: 14px; }
    .codm-pco-otp-section { padding: 16px 10px; }
    .codm-pco-otp-section h3 { font-size: 16px; }
    .codm-pco-otp-digit { width: 36px; height: 42px; font-size: 17px; border-radius: 6px; }
    .codm-pco-otp-boxes { gap: 5px; }
    .codm-pco-option-inner { padding: 8px 6px; gap: 5px; }
    .codm-pco-option-icon { font-size: 16px; }
    .codm-pco-option-title { font-size: 12px; }
    .codm-pco-option-badge { font-size: 8px; padding: 1px 4px; }
    .codm-pco-option-desc { font-size: 10px; }
    .codm-pco-option-price { font-size: 13px; }
    .codm-pco-option-radio input { width: 16px; height: 16px; }
    .codm-pco-address-form { padding: 10px 8px; }
    .codm-pco-address-form h3 { font-size: 14px; }
    .codm-pco-field input, .codm-pco-field select { padding: 8px; font-size: 13px; }
    .codm-pco-delivery { padding: 8px 10px; }
    .codm-pco-payment-options { padding: 10px 8px; }
    .codm-pco-payment-options h3 { font-size: 13px; }
    .codm-pco-logged-in { padding: 6px 8px; }
    .codm-pco-logged-in strong { font-size: 11px; }
    .codm-pco-logged-in a { font-size: 10px; padding: 3px 8px; }
    .codm-pco-summary-card { padding: 8px; }
    .codm-pco-summary-header { font-size: 12px; }
    .codm-pco-summary-total { font-size: 13px; }
    .codm-pco-item-img { width: 30px; height: 30px; }
    .codm-pco-item-name { font-size: 11px; }
    .codm-pco-loading h3 { font-size: 14px; }
    .codm-pco-loading p { font-size: 11px; }
}

/* ── Very small phones ≤320px (iPhone 5/SE 1st gen, old Androids) ── */
@media (max-width: 320px) {
    .codm-pco-header { padding: 5px 6px; gap: 2px; }
    .codm-pco-store { font-size: 9px; padding: 1px 4px; max-width: 70px; }
    .codm-pco-steps { font-size: 8px; }
    .codm-pco-step { padding: 6px; }
    .codm-pco-cc-wrap {
        flex: 0 0 68px; width: 68px; min-width: 68px; max-width: 68px;
    }
    .codm-pco-cc-select { font-size: 12px; padding: 0 14px 0 4px; }
    .codm-pco-phone-input { font-size: 13px; padding: 0 4px; }
    .codm-pco-phone-row { height: 42px; }
    .codm-pco-btn { padding: 10px; font-size: 13px; }
    .codm-pco-otp-digit { width: 32px; height: 38px; font-size: 15px; }
    .codm-pco-otp-boxes { gap: 4px; }
    .codm-pco-otp-section h3 { font-size: 15px; }
    .codm-pco-option-inner { padding: 7px 5px; }
    .codm-pco-option-title { font-size: 11px; }
    .codm-pco-option-price { font-size: 12px; }
    .codm-pco-field input, .codm-pco-field select { padding: 7px 6px; font-size: 12px; }
    .codm-pco-address-form h3 { font-size: 13px; }
}

/* ── Landscape phones ─────────────────────────────────── */
@media (max-width: 599px) and (max-height: 500px) {
    #codm-pco-step-0 { min-height: auto; padding: 20px 16px; }
    .codm-pco-otp-section { padding: 14px 12px; margin: 8px 0; }
    .codm-pco-otp-icon { font-size: 28px; margin-bottom: 2px; }
    .codm-pco-otp-section h3 { font-size: 15px; }
    .codm-pco-otp-sub { margin-bottom: 8px; }
    .codm-pco-otp-digit { width: 36px; height: 40px; font-size: 16px; }
    .codm-pco-logged-in { padding: 6px 10px; }
}
