/**
 * EwShopPopup & EwShopDrawer Styles
 * Modern popup and drawer styles with animations
 */

/* CSS Variables */
:root {
    --ewshoppopup-overlay-bg: rgba(0, 0, 0, 0.5);
    --ewshoppopup-bg: #ffffff;
    --ewshoppopup-text-color: #333333;
    --ewshoppopup-border-radius: 12px;
    --ewshoppopup-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    --ewshoppopup-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   POPUP STYLES (Desktop)
   ============================================ */

/* Overlay */
.ewshoppopup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ewshoppopup-overlay-bg);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 9998;
}

.ewshoppopup-overlay--visible {
    opacity: 1;
}

/* Popup Container */
.ewshoppopup {
    position: fixed;
    background: var(--ewshoppopup-bg);
    border-radius: var(--ewshoppopup-border-radius);
    box-shadow: var(--ewshoppopup-shadow);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    opacity: 0;
    transform: scale(0.9);
    transition: var(--ewshoppopup-transition);
    z-index: 9999;
}

.ewshoppopup--visible {
    opacity: 1;
    transform: scale(1);
}

/* Popup Widths */
.ewshoppopup--small {
    width: 400px;
}

.ewshoppopup--medium {
    width: 600px;
}

.ewshoppopup--large {
    width: 800px;
}

.ewshoppopup--full {
    width: 90vw;
}

/* Popup Positions */
.ewshoppopup--center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
}

.ewshoppopup--center.ewshoppopup--visible {
    transform: translate(-50%, -50%) scale(1);
}

.ewshoppopup--top {
    top: 5%;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
}

.ewshoppopup--top.ewshoppopup--visible {
    transform: translateX(-50%) translateY(0);
}

.ewshoppopup--bottom {
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
}

.ewshoppopup--bottom.ewshoppopup--visible {
    transform: translateX(-50%) translateY(0);
}

.ewshoppopup--top-left {
    top: 5%;
    left: 5%;
    transform: translate(-20px, -20px);
}

.ewshoppopup--top-left.ewshoppopup--visible {
    transform: translate(0, 0);
}

.ewshoppopup--top-right {
    top: 5%;
    right: 5%;
    transform: translate(20px, -20px);
}

.ewshoppopup--top-right.ewshoppopup--visible {
    transform: translate(0, 0);
}

.ewshoppopup--bottom-left {
    bottom: 5%;
    left: 5%;
    transform: translate(-20px, 20px);
}

.ewshoppopup--bottom-left.ewshoppopup--visible {
    transform: translate(0, 0);
}

.ewshoppopup--bottom-right {
    bottom: 5%;
    right: 5%;
    transform: translate(20px, 20px);
}

.ewshoppopup--bottom-right.ewshoppopup--visible {
    transform: translate(0, 0);
}

/* Stacking gap */
.ewshoppopup--stacked {
    transition: var(--ewshoppopup-transition), top 0.3s ease, bottom 0.3s ease;
}

/* Animations */
.ewshoppopup--animation-fade {
    opacity: 0;
}

.ewshoppopup--animation-fade.ewshoppopup--visible {
    opacity: 1;
}

.ewshoppopup--animation-slide-up {
    transform: translateY(50px);
}

.ewshoppopup--animation-slide-up.ewshoppopup--visible {
    transform: translateY(0);
}

.ewshoppopup--animation-slide-down {
    transform: translateY(-50px);
}

.ewshoppopup--animation-slide-down.ewshoppopup--visible {
    transform: translateY(0);
}

.ewshoppopup--animation-zoom {
    transform: scale(0.5);
}

.ewshoppopup--animation-zoom.ewshoppopup--visible {
    transform: scale(1);
}

/* Close Button */
.ewshoppopup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.ewshoppopup-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #333;
    transform: rotate(90deg);
}

/* Content */
.ewshoppopup-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 30px;
}

.ewshoppopup-image {
    margin: -30px -30px 0;
    border-radius: var(--ewshoppopup-border-radius) var(--ewshoppopup-border-radius) 0 0;
    overflow: hidden;
}

.ewshoppopup-image img {
    width: 100%;
    height: auto;
    display: block;
}

.ewshoppopup-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ewshoppopup-title {
    margin: 0;
    font-size: 24px;
    font-weight: normal;
    color: var(--ewshoppopup-text-color);
    line-height: 1.3;
}

.ewshoppopup-text {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    color: #666;
}

/* Title sizes */
.ewshoppopup-title--sm { font-size: 14px; }
.ewshoppopup-title--base { font-size: 16px; }
.ewshoppopup-title--md { font-size: 15px; }
.ewshoppopup-title--lg { font-size: 18px; }
.ewshoppopup-title--xl { font-size: 20px; }
.ewshoppopup-title--2xl { font-size: 24px; }
.ewshoppopup-title--3xl { font-size: 30px; }

/* Text sizes */
.ewshoppopup-text--sm { font-size: 14px; }
.ewshoppopup-text--base { font-size: 16px; }
.ewshoppopup-text--md { font-size: 15px; }
.ewshoppopup-text--lg { font-size: 18px; }
.ewshoppopup-text--xl { font-size: 20px; }
.ewshoppopup-text--2xl { font-size: 24px; }
.ewshoppopup-text--3xl { font-size: 30px; }

.ewshoppopup-countdown {
    margin: 0;
}

.ewshoppopup-countdown-wrapper {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.ewshoppopup-countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    background: #f5f5f5;
    border-radius: 8px;
    min-width: 60px;
}

.ewshoppopup-countdown-item span:first-child {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}

.ewshoppopup-countdown-item span:last-child {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
}

.ewshoppopup-actions {
    margin: 0;
    text-align: left;
}

.ewshoppopup-button {
    display: inline-block;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, background-position 0.4s ease;
}

/* Button sizes */
.ewshoppopup-button--sm {
    padding: 6px 12px;
    font-size: 13px;
}

.ewshoppopup-button--base {
    padding: 8px 14px;
    font-size: 15px;
}

.ewshoppopup-button--lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* Button styles: solid (default) */
.ewshoppopup-button--solid {
    background: #007bff;
    color: #ffffff;
}

.ewshoppopup-button--solid:hover {
    background: #0056b3;
    color: #ffffff;
}

/* Button styles: dark */
.ewshoppopup-button--dark {
    background: #171717;
    color: #ffffff;
    border-color: #404040;
}

.ewshoppopup-button--dark:hover {
    background: #262626;
    color: #ffffff;
}

/* Button styles: outline */
.ewshoppopup-button--outline {
    background: transparent;
    color: #333333;
    border-color: #d1d5db;
}

.ewshoppopup-button--outline:hover {
    background: #f5f5f5;
    color: #333333;
}

/* Button styles: gradients */
.ewshoppopup-button--gradient-purple-blue,
.ewshoppopup-button--gradient-cyan-blue,
.ewshoppopup-button--gradient-pink-orange,
.ewshoppopup-button--gradient-purple-pink,
.ewshoppopup-button--gradient-green-blue {
    color: #ffffff;
    background-size: 200% auto;
    background-position: left center;
}

.ewshoppopup-button--gradient-purple-blue:hover,
.ewshoppopup-button--gradient-cyan-blue:hover,
.ewshoppopup-button--gradient-pink-orange:hover,
.ewshoppopup-button--gradient-purple-pink:hover,
.ewshoppopup-button--gradient-green-blue:hover {
    background-position: right center;
    color: #ffffff;
}

.ewshoppopup-button--gradient-purple-blue {
    background-image: linear-gradient(to right, #9333ea, #3b82f6, #9333ea);
}

.ewshoppopup-button--gradient-cyan-blue {
    background-image: linear-gradient(to right, #06b6d4, #3b82f6, #06b6d4);
}

.ewshoppopup-button--gradient-pink-orange {
    background-image: linear-gradient(to right, #ec4899, #fb923c, #ec4899);
}

.ewshoppopup-button--gradient-purple-pink {
    background-image: linear-gradient(to right, #a855f7, #ec4899, #a855f7);
}

.ewshoppopup-button--gradient-green-blue {
    background-image: linear-gradient(to right, #4ade80, #2563eb, #4ade80);
}

/* Button full width */
.ewshoppopup-button--full {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

/* ============================================
   DRAWER STYLES (Mobile)
   ============================================ */

/* Drawer Overlay */
.ewshopdrawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ewshoppopup-overlay-bg);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 9998;
}

.ewshopdrawer-overlay--visible {
    opacity: 1;
}

/* Drawer Container */
.ewshopdrawer {
    position: fixed;
    background: var(--ewshoppopup-bg);
    box-shadow: var(--ewshoppopup-shadow);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    max-width: 100vw;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Drawer Positions */
.ewshopdrawer--bottom {
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--ewshoppopup-border-radius) var(--ewshoppopup-border-radius) 0 0;
    transform: translateY(100%);
}

.ewshopdrawer--bottom.ewshopdrawer--visible {
    transform: translateY(0);
}

.ewshopdrawer--top {
    top: 0;
    left: 0;
    right: 0;
    border-radius: 0 0 var(--ewshoppopup-border-radius) var(--ewshoppopup-border-radius);
    transform: translateY(-100%);
}

.ewshopdrawer--top.ewshopdrawer--visible {
    transform: translateY(0);
}

.ewshopdrawer--left {
    top: 0;
    left: 0;
    bottom: 0;
    width: 85vw;
    max-width: 400px;
    border-radius: 0 var(--ewshoppopup-border-radius) var(--ewshoppopup-border-radius) 0;
    transform: translateX(-100%);
}

.ewshopdrawer--left.ewshopdrawer--visible {
    transform: translateX(0);
}

.ewshopdrawer--right {
    top: 0;
    right: 0;
    bottom: 0;
    width: 85vw;
    max-width: 400px;
    border-radius: var(--ewshoppopup-border-radius) 0 0 var(--ewshoppopup-border-radius);
    transform: translateX(100%);
}

.ewshopdrawer--right.ewshopdrawer--visible {
    transform: translateX(0);
}

/* Drawer Heights */
.ewshopdrawer--auto {
    height: auto;
}

.ewshopdrawer--half {
    height: 50vh;
}

.ewshopdrawer--full {
    height: 100vh;
}

/* Drag Handle */
.ewshopdrawer-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0;
    cursor: grab;
    touch-action: none;
}

.ewshopdrawer-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
}

.ewshopdrawer--left .ewshopdrawer-handle,
.ewshopdrawer--right .ewshopdrawer-handle {
    display: none;
}

/* Close Button */
.ewshopdrawer-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.ewshopdrawer-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #333;
}

/* Content */
.ewshopdrawer-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
}

.ewshopdrawer-image {
    margin: -48px -20px 0;
    overflow: hidden;
}

.ewshopdrawer--bottom .ewshopdrawer-image,
.ewshopdrawer--top .ewshopdrawer-image {
    border-radius: var(--ewshoppopup-border-radius) var(--ewshoppopup-border-radius) 0 0;
}

.ewshopdrawer-image img {
    width: 100%;
    height: auto;
    display: block;
}

.ewshopdrawer-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ewshopdrawer-title {
    margin: 0;
    font-size: 20px;
    font-weight: normal;
    color: var(--ewshoppopup-text-color);
    line-height: 1.3;
}

.ewshopdrawer-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #666;
}

/* Drawer title sizes */
.ewshopdrawer-title--sm { font-size: 14px; }
.ewshopdrawer-title--base { font-size: 16px; }
.ewshopdrawer-title--md { font-size: 15px; }
.ewshopdrawer-title--lg { font-size: 18px; }
.ewshopdrawer-title--xl { font-size: 20px; }
.ewshopdrawer-title--2xl { font-size: 24px; }
.ewshopdrawer-title--3xl { font-size: 30px; }

/* Drawer text sizes */
.ewshopdrawer-text--sm { font-size: 14px; }
.ewshopdrawer-text--base { font-size: 16px; }
.ewshopdrawer-text--md { font-size: 15px; }
.ewshopdrawer-text--lg { font-size: 18px; }
.ewshopdrawer-text--xl { font-size: 20px; }
.ewshopdrawer-text--2xl { font-size: 24px; }
.ewshopdrawer-text--3xl { font-size: 30px; }

.ewshopdrawer-countdown {
    margin: 0;
}

.ewshopdrawer-countdown-wrapper {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.ewshopdrawer-countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    min-width: 50px;
}

.ewshopdrawer-countdown-item span:first-child {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.ewshopdrawer-countdown-item span:last-child {
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
}

.ewshopdrawer-actions {
    margin: 0;
    text-align: center;
}

.ewshopdrawer-button {
    display: inline-block;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, background-position 0.4s ease;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

/* Drawer button sizes */
.ewshopdrawer-button--sm {
    padding: 6px 12px;
    font-size: 13px;
}

.ewshopdrawer-button--base {
    padding: 8px 14px;
    font-size: 15px;
}

.ewshopdrawer-button--lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* Drawer button styles */
.ewshopdrawer-button--solid {
    background: #007bff;
    color: #ffffff;
}

.ewshopdrawer-button--solid:hover {
    background: #0056b3;
    color: #ffffff;
}

.ewshopdrawer-button--dark {
    background: #171717;
    color: #ffffff;
    border-color: #404040;
}

.ewshopdrawer-button--dark:hover {
    background: #262626;
    color: #ffffff;
}

.ewshopdrawer-button--outline {
    background: transparent;
    color: #333333;
    border-color: #d1d5db;
}

.ewshopdrawer-button--outline:hover {
    background: #f5f5f5;
    color: #333333;
}

.ewshopdrawer-button--gradient-purple-blue,
.ewshopdrawer-button--gradient-cyan-blue,
.ewshopdrawer-button--gradient-pink-orange,
.ewshopdrawer-button--gradient-purple-pink,
.ewshopdrawer-button--gradient-green-blue {
    color: #ffffff;
    background-size: 200% auto;
    background-position: left center;
}

.ewshopdrawer-button--gradient-purple-blue:hover,
.ewshopdrawer-button--gradient-cyan-blue:hover,
.ewshopdrawer-button--gradient-pink-orange:hover,
.ewshopdrawer-button--gradient-purple-pink:hover,
.ewshopdrawer-button--gradient-green-blue:hover {
    background-position: right center;
    color: #ffffff;
}

.ewshopdrawer-button--gradient-purple-blue {
    background-image: linear-gradient(to right, #9333ea, #3b82f6, #9333ea);
}

.ewshopdrawer-button--gradient-cyan-blue {
    background-image: linear-gradient(to right, #06b6d4, #3b82f6, #06b6d4);
}

.ewshopdrawer-button--gradient-pink-orange {
    background-image: linear-gradient(to right, #ec4899, #fb923c, #ec4899);
}

.ewshopdrawer-button--gradient-purple-pink {
    background-image: linear-gradient(to right, #a855f7, #ec4899, #a855f7);
}

.ewshopdrawer-button--gradient-green-blue {
    background-image: linear-gradient(to right, #4ade80, #2563eb, #4ade80);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .ewshoppopup {
        max-width: 95vw;
    }

    .ewshoppopup--small,
    .ewshoppopup--medium,
    .ewshoppopup--large {
        width: 90vw;
    }

    .ewshoppopup-content {
        padding: 20px;
        gap: 15px;
    }

    .ewshoppopup-image {
        margin: -20px -20px 0;
    }

    .ewshoppopup-title {
        font-size: 20px;
    }

    .ewshoppopup-text {
        font-size: 15px;
    }

    .ewshoppopup-countdown-item {
        min-width: 50px;
        padding: 8px 12px;
    }

    .ewshoppopup-countdown-item span:first-child {
        font-size: 20px;
    }

    .ewshoppopup-actions {
        text-align: center;
    }

    .ewshoppopup-button {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .ewshoppopup--full {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* Dark mode support */

/* 1. html[data-theme="dark"] / html[data-bs-theme="dark"] / html.dark */
html[data-theme="dark"],
html[data-bs-theme="dark"],
html.dark {
    --ewshoppopup-bg: #1f1f1f;
    --ewshoppopup-text-color: #ffffff;
    --ewshoppopup-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .ewshoppopup-text,
html[data-bs-theme="dark"] .ewshoppopup-text,
html.dark .ewshoppopup-text,
html[data-theme="dark"] .ewshopdrawer-text,
html[data-bs-theme="dark"] .ewshopdrawer-text,
html.dark .ewshopdrawer-text {
    color: #cccccc;
}

html[data-theme="dark"] .ewshoppopup-close,
html[data-bs-theme="dark"] .ewshoppopup-close,
html.dark .ewshoppopup-close,
html[data-theme="dark"] .ewshopdrawer-close,
html[data-bs-theme="dark"] .ewshopdrawer-close,
html.dark .ewshopdrawer-close {
    background: rgba(255, 255, 255, 0.15);
    color: #ccc;
}

html[data-theme="dark"] .ewshoppopup-close:hover,
html[data-bs-theme="dark"] .ewshoppopup-close:hover,
html.dark .ewshoppopup-close:hover,
html[data-theme="dark"] .ewshopdrawer-close:hover,
html[data-bs-theme="dark"] .ewshopdrawer-close:hover,
html.dark .ewshopdrawer-close:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

html[data-theme="dark"] .ewshoppopup-countdown-item,
html[data-bs-theme="dark"] .ewshoppopup-countdown-item,
html.dark .ewshoppopup-countdown-item,
html[data-theme="dark"] .ewshopdrawer-countdown-item,
html[data-bs-theme="dark"] .ewshopdrawer-countdown-item,
html.dark .ewshopdrawer-countdown-item {
    background: #2a2a2a;
}

html[data-theme="dark"] .ewshoppopup-countdown-item span:first-child,
html[data-bs-theme="dark"] .ewshoppopup-countdown-item span:first-child,
html.dark .ewshoppopup-countdown-item span:first-child,
html[data-theme="dark"] .ewshopdrawer-countdown-item span:first-child,
html[data-bs-theme="dark"] .ewshopdrawer-countdown-item span:first-child,
html.dark .ewshopdrawer-countdown-item span:first-child {
    color: #ffffff;
}

html[data-theme="dark"] .ewshopdrawer-handle::before,
html[data-bs-theme="dark"] .ewshopdrawer-handle::before,
html.dark .ewshopdrawer-handle::before {
    background: #555;
}

/* 2. OS-level dark mode fallback */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) {
        --ewshoppopup-bg: #1f1f1f;
        --ewshoppopup-text-color: #ffffff;
        --ewshoppopup-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }

    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshoppopup-text,
    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshopdrawer-text {
        color: #cccccc;
    }

    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshoppopup-close,
    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshopdrawer-close {
        background: rgba(255, 255, 255, 0.15);
        color: #ccc;
    }

    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshoppopup-close:hover,
    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshopdrawer-close:hover {
        background: rgba(255, 255, 255, 0.25);
        color: #fff;
    }

    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshoppopup-countdown-item,
    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshopdrawer-countdown-item {
        background: #2a2a2a;
    }

    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshoppopup-countdown-item span:first-child,
    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshopdrawer-countdown-item span:first-child {
        color: #ffffff;
    }

    html:not([data-theme]):not([data-bs-theme]):not(.light):not(.dark) .ewshopdrawer-handle::before {
        background: #555;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .ewshoppopup,
    .ewshoppopup-overlay,
    .ewshopdrawer,
    .ewshopdrawer-overlay {
        transition: none !important;
    }
}
