/* ============================================
   Costco Price Drop Alert - Popup Styles
   ============================================ */

#cpa-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cpaFadeIn 0.3s ease;
    padding: 16px;
}

#cpa-overlay.cpa-fade-out {
    animation: cpaFadeOut 0.3s ease forwards;
}

@keyframes cpaFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cpaFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

#cpa-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: cpaSlideUp 0.3s ease;
}

@keyframes cpaSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#cpa-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    z-index: 1;
}

#cpa-close:hover {
    color: #374151;
}

/* Header */
#cpa-header {
    text-align: center;
    padding: 28px 24px 0;
}

#cpa-logo {
    margin-bottom: 12px;
}

#cpa-title {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 6px;
    line-height: 1.3;
}

#cpa-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Step Dots */
#cpa-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 20px 24px 8px;
}

.cpa-step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.cpa-step-dot.active {
    background: #0060a9;
    color: #fff;
    transform: scale(1.1);
}

.cpa-step-dot.done {
    background: #16a34a;
    color: #fff;
}

.cpa-step-line {
    width: 32px;
    height: 2px;
    background: #e5e7eb;
}

/* Body */
#cpa-body {
    padding: 16px 24px;
}

.cpa-section {
    min-height: 180px;
}

.cpa-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.cpa-hint {
    font-size: 13px;
    color: #6b7280;
    margin: 0 0 12px;
}

/* Input */
.cpa-input-row {
    display: flex;
    gap: 8px;
}

.cpa-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.cpa-input:focus {
    border-color: #0060a9;
    box-shadow: 0 0 0 3px rgba(0, 96, 169, 0.1);
}

.cpa-input-full {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 12px;
}

.cpa-input-code {
    text-align: center;
    font-size: 24px;
    letter-spacing: 8px;
    font-weight: 600;
    max-width: 200px;
    margin: 16px auto;
    display: block;
}

/* Buttons */
.cpa-btn {
    padding: 10px 20px;
    background: #0060a9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.cpa-btn:hover {
    background: #004d87;
}

.cpa-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.cpa-btn-full {
    width: 100%;
    padding: 12px;
}

.cpa-btn-sm {
    padding: 6px 16px;
    background: #0060a9;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

.cpa-btn-sm:hover {
    background: #004d87;
}

.cpa-btn-success {
    background: #16a34a;
}

.cpa-btn-success:hover {
    background: #15803d;
}

/* List Items */
.cpa-list {
    margin-top: 12px;
    max-height: 280px;
    overflow-y: auto;
}

.cpa-loading {
    text-align: center;
    color: #6b7280;
    padding: 24px;
    font-size: 14px;
}

.cpa-empty {
    text-align: center;
    color: #9ca3af;
    padding: 24px;
    font-size: 14px;
}

.cpa-error {
    color: #dc2626;
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}

/* Warehouse Items */
.cpa-wh-item {
    padding: 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.cpa-wh-item:hover {
    border-color: #0060a9;
    background: #f0f7ff;
}

.cpa-wh-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cpa-wh-info strong {
    font-size: 15px;
    color: #1f2937;
}

.cpa-wh-dist {
    font-size: 13px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
}

.cpa-wh-addr {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

/* Product Items */
.cpa-prod-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.cpa-prod-item:hover {
    border-color: #0060a9;
    background: #f0f7ff;
}

/* Image carousel */
.cpa-prod-carousel {
    position: relative;
    flex-shrink: 0;
    width: 140px;
    height: 140px;
}

.cpa-prod-img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    border-radius: 8px;
    background: #f9fafb;
    cursor: zoom-in;
}

.cpa-prod-img-placeholder {
    width: 140px;
    height: 140px;
    background: #e5e7eb;
    border-radius: 8px;
}

.cpa-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    border: 1px solid #d1d5db;
    color: #374151;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.cpa-carousel-prev { left: 2px; }
.cpa-carousel-next { right: 2px; }

.cpa-carousel-btn:hover {
    background: #fff;
    border-color: #0060a9;
}

.cpa-carousel-dots {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #6b7280;
    background: rgba(255,255,255,0.85);
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
}

.cpa-prod-info {
    flex: 1;
    min-width: 0;
}

.cpa-prod-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cpa-prod-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cpa-prod-price-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.cpa-prod-price {
    font-size: 16px;
    font-weight: 700;
    color: #0060a9;
}

.cpa-price-na {
    font-size: 13px;
    color: #9ca3af;
    font-weight: 500;
    font-style: italic;
}

.cpa-prod-orig-price {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: line-through;
}

.cpa-prod-discount {
    font-size: 12px;
    color: #16a34a;
    font-weight: 500;
}

.cpa-prod-dept {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.cpa-prod-wh {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

/* Track button states */
.cpa-btn-sm {
    align-self: center;
}

.cpa-btn-added {
    background: #d1d5db;
    color: #6b7280;
    cursor: default;
}

.cpa-btn-added:hover {
    background: #d1d5db;
}

/* Track List (bottom of Step 2) */
.cpa-tracklist {
    margin-top: 16px;
    border-top: 1.5px solid #e5e7eb;
    padding-top: 12px;
}

.cpa-tracklist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cpa-tracklist-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.cpa-tracklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    margin-bottom: 6px;
}

.cpa-tracklist-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
}

.cpa-tracklist-info {
    flex: 1;
    min-width: 0;
}

.cpa-tracklist-name {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cpa-tracklist-price {
    font-size: 13px;
    color: #0060a9;
    font-weight: 600;
}

.cpa-tracklist-remove {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}

.cpa-tracklist-remove:hover {
    color: #dc2626;
}

.cpa-btn-continue {
    margin-top: 10px;
}

/* Confirm summary (Step 3) */
.cpa-confirm-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cpa-confirm-count {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}

.cpa-confirm-cards {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 4px;
}

/* Success items list */
.cpa-success-items {
    list-style: none;
    padding: 0;
    margin: 8px 0;
    text-align: left;
}

.cpa-success-items li {
    font-size: 13px;
    color: #4b5563;
    padding: 4px 0;
    border-bottom: 1px solid #f3f4f6;
}

.cpa-success-items li:last-child {
    border-bottom: none;
}

/* Selected warehouse tag */
.cpa-selected-wh {
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: #1e40af;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cpa-selected-icon {
    color: #16a34a;
}

.cpa-change {
    font-size: 13px;
    color: #0060a9;
    margin-left: auto;
    text-decoration: none;
}

.cpa-change:hover {
    text-decoration: underline;
}

/* Confirm Card (Step 3) */
.cpa-confirm-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 8px;
}

.cpa-confirm-img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    flex-shrink: 0;
}

.cpa-confirm-details .cpa-prod-name {
    font-size: 15px;
}

/* Email sent icon */
.cpa-email-sent-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

/* Success Screen */
.cpa-success {
    text-align: center;
    padding: 16px 0;
}

.cpa-success-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #dcfce7;
    color: #16a34a;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.cpa-success-title {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 12px;
}

.cpa-success-text {
    font-size: 14px;
    color: #4b5563;
    margin: 0 0 8px;
    line-height: 1.5;
}

.cpa-success-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0f7ff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: #1e40af;
    margin: 16px 0;
}

/* Footer */
#cpa-footer {
    text-align: center;
    padding: 0 24px 20px;
}

#cpa-skip {
    font-size: 13px;
    color: #9ca3af;
    cursor: pointer;
    text-decoration: underline;
}

#cpa-skip:hover {
    color: #6b7280;
}

/* Mobile */
@media (max-width: 480px) {
    #cpa-modal {
        max-height: 95vh;
        border-radius: 12px;
    }

    #cpa-title {
        font-size: 20px;
    }

    .cpa-confirm-card {
        flex-direction: column;
        text-align: center;
    }

    .cpa-prod-item {
        flex-wrap: wrap;
    }
}

/* Scrollbar styling */
.cpa-list::-webkit-scrollbar {
    width: 4px;
}

.cpa-list::-webkit-scrollbar-track {
    background: transparent;
}

.cpa-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

/* ============================================
   Lightbox (image zoom)
   ============================================ */

.cpa-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cpaFadeIn 0.2s ease;
    cursor: zoom-out;
}

.cpa-lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.cpa-lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
}

.cpa-lightbox-close {
    position: absolute;
    top: -36px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}

.cpa-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #374151;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpa-lightbox-prev { left: -56px; }
.cpa-lightbox-next { right: -56px; }

.cpa-lightbox-nav:hover {
    background: #fff;
}

.cpa-lightbox-counter {
    text-align: center;
    color: #fff;
    font-size: 14px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .cpa-lightbox-prev { left: 8px; }
    .cpa-lightbox-next { right: 8px; }
    .cpa-lightbox-nav {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
}

/* ============================================
   Management View (returning user)
   ============================================ */

.cpa-manage {
    min-height: auto;
}

.cpa-manage-header {
    text-align: center;
    margin-bottom: 16px;
}

.cpa-manage-icon {
    font-size: 36px;
    margin-bottom: 4px;
}

.cpa-manage-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 4px;
}

.cpa-manage-email {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.cpa-manage-list-header {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.cpa-manage-list {
    max-height: 300px;
    overflow-y: auto;
}

.cpa-manage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: border-color 0.2s;
}

.cpa-manage-item:hover {
    border-color: #d1d5db;
}

.cpa-manage-item-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    flex-shrink: 0;
}

.cpa-manage-item-info {
    flex: 1;
    min-width: 0;
}

.cpa-manage-item-name {
    font-size: 13px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cpa-manage-item-price {
    font-size: 14px;
    font-weight: 700;
    color: #0060a9;
}

.cpa-manage-item-remove {
    background: none;
    border: 1px solid #e5e7eb;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 6px;
    transition: all 0.2s;
}

.cpa-manage-item-remove:hover {
    color: #dc2626;
    border-color: #fca5a5;
    background: #fef2f2;
}

.cpa-manage-empty {
    text-align: center;
    padding: 32px 16px;
    background: #f9fafb;
    border: 1.5px dashed #d1d5db;
    border-radius: 10px;
    margin: 12px 0;
}

.cpa-manage-empty-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.cpa-manage-empty-text {
    font-size: 15px;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 4px;
}

.cpa-manage-reset {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: none;
}

.cpa-manage-reset:hover {
    color: #6b7280;
    text-decoration: underline;
}

/* Already tracking button (green) */
.cpa-btn-tracking {
    background: #dcfce7;
    color: #16a34a;
    cursor: default;
}

.cpa-btn-tracking:hover {
    background: #dcfce7;
}

/* ============================================
   Side Banners (Costco Price Checker CTA)
   ============================================ */

.cpa-side-banner {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99990;
    width: 52px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cpa-side-banner-left {
    left: 0;
}

.cpa-side-banner-right {
    right: 0;
}

.cpa-side-banner-inner {
    background: linear-gradient(135deg, #0060a9, #004d87);
    color: #fff;
    padding: 16px 8px;
    border-radius: 0 12px 12px 0;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    box-shadow: 2px 4px 12px rgba(0, 96, 169, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.cpa-side-banner-right .cpa-side-banner-inner {
    border-radius: 12px 0 0 12px;
    writing-mode: vertical-lr;
    transform: rotate(180deg);
}

.cpa-side-banner:hover .cpa-side-banner-inner {
    background: linear-gradient(135deg, #004d87, #003366);
    box-shadow: 2px 4px 20px rgba(0, 96, 169, 0.5);
}

.cpa-side-banner-icon {
    font-size: 22px;
}

.cpa-side-banner-pulse {
    animation: cpaBannerPulse 2s ease-in-out infinite;
}

@keyframes cpaBannerPulse {
    0%, 100% { box-shadow: 2px 4px 12px rgba(0, 96, 169, 0.3); }
    50% { box-shadow: 2px 4px 24px rgba(0, 96, 169, 0.6); }
}

@media (max-width: 1200px) {
    .cpa-side-banner {
        display: none;
    }
}
