/**
 * ComputerArzt Popup Styles
 * Premium design matching the ComputerArzt brand system
 * Glassmorphism, Space Grotesk / Quicksand typography, brand gradients
 */

/* =============================================================================
   CSS Variables
   ============================================================================= */
:root {
    --popup-z-index: 99999;
    --popup-backdrop-color: rgba(15, 23, 42, 0.55);
    --popup-border-radius: 20px;
    --popup-shadow:
        0 4px 16px rgba(0, 0, 0, 0.08),
        0 16px 48px rgba(0, 0, 0, 0.16),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    --popup-transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================================================
   Common Popup Styles
   ============================================================================= */

/* --- Close Button: Glassmorphic pill --- */
.popup-close {
    position: absolute;
    background: rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: inherit;
    opacity: 0.6;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.popup-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.08) rotate(90deg);
}

.popup-close:focus-visible {
    outline: 2px solid var(--blue, #4A9BD9);
    outline-offset: 2px;
}

/* --- CTA Button: Pill-shaped, brand-matched --- */
.popup-cta {
    display: inline-block;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.01em;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.popup-cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    filter: brightness(1.08);
}

.popup-cta:active {
    transform: translateY(-1px);
    transition-duration: 0.1s;
}

.popup-cta:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* =============================================================================
   Modal Popup
   ============================================================================= */
.popup-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--popup-backdrop-color);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: var(--popup-z-index);
    opacity: 0;
    visibility: hidden;
    transition: var(--popup-transition);
}

.popup-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.popup-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    z-index: calc(var(--popup-z-index) + 1);
    max-width: 720px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    border-radius: var(--popup-border-radius);
    box-shadow: var(--popup-shadow);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Custom scrollbar */
.popup-modal::-webkit-scrollbar {
    width: 6px;
}

.popup-modal::-webkit-scrollbar-track {
    background: transparent;
}

.popup-modal::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
}

.popup-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.popup-modal .popup-close {
    top: 1.1rem;
    right: 1.1rem;
    z-index: 10;
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.popup-modal .popup-close:hover {
    background: rgba(255, 255, 255, 0.95);
}

.popup-modal__image {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
    border-radius: var(--popup-border-radius) var(--popup-border-radius) 0 0;
}

.popup-modal__content {
    padding: 2rem 2.5rem 2.25rem;
}

.popup-modal__title {
    margin: 0 0 0.6rem 0;
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.25;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
}

.popup-modal__subtitle {
    margin: 0 0 1.25rem 0;
    font-size: 1.05rem;
    font-weight: 400;
    opacity: 0.65;
    line-height: 1.5;
    font-family: 'Quicksand', sans-serif;
}

.popup-modal__body {
    margin: 0 0 1.5rem 0;
    font-size: 1rem;
    line-height: 1.7;
    opacity: 0.85;
    font-family: 'Quicksand', sans-serif;
}

.popup-modal__body p {
    margin: 0 0 0.75rem 0;
}

.popup-modal__body p:last-child {
    margin-bottom: 0;
}

.popup-modal__body h3,
.popup-modal__body h4 {
    margin: 1rem 0 0.5rem 0;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

.popup-modal__body ul,
.popup-modal__body ol {
    margin: 0.5rem 0 1rem 0;
    padding-left: 1.5rem;
}

.popup-modal__body li {
    margin-bottom: 0.35rem;
    line-height: 1.5;
}

.popup-modal__body a {
    color: var(--blue, #4A9BD9);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(74, 155, 217, 0.3);
    transition: text-decoration-color 0.2s;
}

.popup-modal__body a:hover {
    text-decoration-color: var(--blue, #4A9BD9);
}

.popup-modal__body hr {
    border: none;
    border-top: 1px solid currentColor;
    opacity: 0.1;
    margin: 1.25rem 0;
}

.popup-modal__footer {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.popup-modal__footer .popup-cta-secondary {
    display: inline-block;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: 'Space Grotesk', sans-serif;
    border: 2px solid currentColor;
    opacity: 0.6;
    transition: all 0.25s ease;
    text-align: center;
}

.popup-modal__footer .popup-cta-secondary:hover {
    opacity: 1;
    transform: translateY(-2px);
}

/* =============================================================================
   Banner Popup (Top & Bottom)
   ============================================================================= */
.popup-banner {
    position: fixed;
    left: 0;
    right: 0;
    z-index: var(--popup-z-index);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: var(--popup-transition);
}

/* Brand gradient accent line */
.popup-banner::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #4A9BD9, #8E5A9B, #E74C3C);
    z-index: 1;
}

.popup-banner--top {
    top: 0;
}

.popup-banner--top::before {
    bottom: 0;
}

.popup-banner--bottom {
    bottom: 0;
    top: auto;
    transform: translateY(100%);
}

.popup-banner--bottom::before {
    top: 0;
}

.popup-banner.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.popup-banner__content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    text-align: center;
    padding: 0.95rem 1.5rem;
}

.popup-banner__text {
    font-size: 0.95rem;
    font-family: 'Quicksand', sans-serif;
}

.popup-banner__text strong {
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

.popup-banner__cta {
    padding: 0.5rem 1.25rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: 'Space Grotesk', sans-serif;
    white-space: nowrap;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-banner__cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    filter: brightness(1.08);
}

.popup-banner .popup-close {
    position: relative;
    top: auto;
    right: auto;
    flex-shrink: 0;
    font-size: 18px;
    width: 28px;
    height: 28px;
    margin-right: 0.5rem;
}

/* =============================================================================
   Slide-in Popup (Corner)
   ============================================================================= */
.popup-slidein {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: var(--popup-z-index);
    width: 400px;
    max-width: calc(100vw - 2rem);
    padding: 1.75rem;
    border-radius: var(--popup-border-radius);
    box-shadow: var(--popup-shadow);
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.popup-slidein.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.popup-slidein .popup-close {
    top: 0.85rem;
    right: 0.85rem;
    font-size: 18px;
    width: 32px;
    height: 32px;
}

.popup-slidein__title {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.01em;
    padding-right: 2.5rem;
}

.popup-slidein__body {
    margin: 0 0 1rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
    opacity: 0.85;
    font-family: 'Quicksand', sans-serif;
}

.popup-slidein__body ul,
.popup-slidein__body ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.popup-slidein__body li {
    margin-bottom: 0.25rem;
}

.popup-slidein .popup-cta {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
}

/* =============================================================================
   Notification Popup (Toast)
   ============================================================================= */
.popup-notification {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: var(--popup-z-index);
    width: 420px;
    max-width: calc(100vw - 2rem);
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.06),
        0 12px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    transform: translateX(calc(100% + 2rem));
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.popup-notification.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.popup-notification__icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.popup-notification__icon svg {
    width: 20px;
    height: 20px;
}

.popup-notification__content {
    flex: 1;
    min-width: 0;
}

.popup-notification__title {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    font-family: 'Space Grotesk', sans-serif;
    margin-bottom: 0.2rem;
}

.popup-notification__body {
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.75;
    margin: 0;
    font-family: 'Quicksand', sans-serif;
}

.popup-notification .popup-close {
    position: relative;
    top: auto;
    right: auto;
    font-size: 16px;
    width: 28px;
    height: 28px;
    opacity: 0.4;
    flex-shrink: 0;
}

/* =============================================================================
   Product Cards in Popups
   Premium glassmorphism cards with brand accent system
   ============================================================================= */

/* --- Grid Layout --- */
.popup-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 0.85rem;
    margin: 1.25rem 0 0.5rem;
    padding: 1.1rem;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(74, 155, 217, 0.04) 0%, transparent 70%),
        radial-gradient(ellipse at 80% 50%, rgba(231, 76, 60, 0.03) 0%, transparent 70%),
        rgba(248, 250, 252, 0.6);
    border-radius: 16px;
    border: 1px solid rgba(74, 155, 217, 0.06);
}

/* --- Product Card --- */
.popup-product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: #1e293b;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    opacity: 0;
    animation: popupProductFadeIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.popup-product-card:nth-child(1) { animation-delay: 0.06s; }
.popup-product-card:nth-child(2) { animation-delay: 0.12s; }
.popup-product-card:nth-child(3) { animation-delay: 0.18s; }
.popup-product-card:nth-child(4) { animation-delay: 0.24s; }
.popup-product-card:nth-child(5) { animation-delay: 0.30s; }
.popup-product-card:nth-child(6) { animation-delay: 0.36s; }

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

.popup-product-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 4px 12px rgba(74, 155, 217, 0.08),
        0 12px 32px rgba(0, 0, 0, 0.08);
    border-color: rgba(74, 155, 217, 0.15);
}

.popup-product-card:active {
    transform: translateY(-1px);
    transition-duration: 0.1s;
}

/* Top accent gradient on hover */
.popup-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #4A9BD9, #8E5A9B, #E74C3C);
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 2;
    border-radius: 14px 14px 0 0;
}

.popup-product-card:hover::before {
    opacity: 1;
}

/* --- Image Area --- */
.popup-product-img-wrap {
    position: relative;
    aspect-ratio: 4 / 3;
    background: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 100%);
    overflow: hidden;
}

.popup-product-img-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 65%, rgba(255, 255, 255, 0.5) 100%);
    pointer-events: none;
}

.popup-product-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 0.6rem;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-product-card:hover .popup-product-img {
    transform: scale(1.06);
}

.popup-product-img-placeholder {
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 30% 40%, rgba(74, 155, 217, 0.06) 0%, transparent 60%),
        radial-gradient(circle at 70% 60%, rgba(231, 76, 60, 0.04) 0%, transparent 60%),
        linear-gradient(160deg, #f8fafc 0%, #f1f5f9 100%);
}

/* --- Discount Badge --- */
.popup-product-badge {
    position: absolute;
    top: 0.45rem;
    left: 0.45rem;
    background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    line-height: 1.3;
    letter-spacing: 0.01em;
    z-index: 3;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
}

/* --- Product Info --- */
.popup-product-info {
    padding: 0.6rem 0.7rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    position: relative;
}

.popup-product-brand {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
}

.popup-product-name {
    font-size: 0.78rem;
    font-weight: 600;
    font-family: 'Quicksand', sans-serif;
    line-height: 1.35;
    color: #1e293b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.01em;
}

/* --- Prices --- */
.popup-product-prices {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}

.popup-product-price-current {
    font-size: 0.9rem;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
    color: #1e293b;
}

.popup-product-price-old {
    font-size: 0.68rem;
    text-decoration: line-through;
    color: #94a3b8;
    font-weight: 500;
}

.popup-product-price-sale {
    font-size: 0.9rem;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.02em;
    color: var(--red, #E74C3C);
}

/* --- Wider modal when products are present --- */
.popup-modal--has-products {
    max-width: 780px;
}

.popup-modal--has-products .popup-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* --- Slide-in with products --- */
.popup-slidein--has-products {
    width: 440px;
}

.popup-slidein--has-products .popup-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
    padding: 0.75rem;
}

.popup-slidein--has-products .popup-product-card {
    border-radius: 10px;
}

.popup-slidein--has-products .popup-product-card::before {
    height: 2px;
}

.popup-slidein--has-products .popup-product-info {
    padding: 0.45rem 0.55rem 0.6rem;
}

.popup-slidein--has-products .popup-product-name {
    font-size: 0.72rem;
}

.popup-slidein--has-products .popup-product-price-current,
.popup-slidein--has-products .popup-product-price-sale {
    font-size: 0.8rem;
}

.popup-slidein--has-products .popup-product-badge {
    font-size: 0.58rem;
    padding: 0.15rem 0.35rem;
    border-radius: 5px;
}

/* =============================================================================
   Responsive Adjustments
   ============================================================================= */
@media (max-width: 640px) {
    .popup-modal {
        max-width: calc(100% - 1rem);
        margin: 0.5rem;
        border-radius: 16px;
    }

    .popup-modal__image {
        max-height: 200px;
        border-radius: 16px 16px 0 0;
    }

    .popup-modal__content {
        padding: 1.25rem 1.35rem;
    }

    .popup-modal__title {
        font-size: 1.3rem;
        padding-right: 2rem;
    }

    .popup-modal__body {
        font-size: 0.92rem;
    }

    .popup-modal__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .popup-modal .popup-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .popup-banner {
        flex-direction: column;
        gap: 0;
    }

    .popup-banner__content {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .popup-banner .popup-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }

    .popup-slidein {
        right: 0.75rem;
        bottom: 0.75rem;
        width: calc(100vw - 1.5rem);
        max-width: none;
        border-radius: 16px;
    }

    .popup-notification {
        right: 0.75rem;
        top: 0.75rem;
        width: calc(100vw - 1.5rem);
        max-width: none;
    }

    .popup-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        padding: 0.65rem;
        border-radius: 12px;
    }

    .popup-product-card {
        border-radius: 10px;
    }

    .popup-product-card::before {
        height: 2px;
    }

    .popup-product-img {
        padding: 0.4rem;
    }

    .popup-product-info {
        padding: 0.45rem 0.5rem 0.55rem;
    }

    .popup-product-name {
        font-size: 0.7rem;
    }

    .popup-product-price-current,
    .popup-product-price-sale {
        font-size: 0.8rem;
    }

    .popup-product-price-old {
        font-size: 0.6rem;
    }

    .popup-product-badge {
        font-size: 0.55rem;
        padding: 0.15rem 0.35rem;
    }

    .popup-slidein--has-products {
        width: calc(100vw - 1.5rem);
    }
}

/* =============================================================================
   Animations
   ============================================================================= */
@keyframes popup-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popup-scale-in {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes popup-slide-down {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popup-slide-up {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popup-slide-left {
    from {
        opacity: 0;
        transform: translateX(calc(100% + 2rem));
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =============================================================================
   Accessibility - Reduced Motion
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
    .popup-modal,
    .popup-modal-backdrop,
    .popup-banner,
    .popup-slidein,
    .popup-notification,
    .popup-close,
    .popup-cta,
    .popup-product-card,
    .popup-product-img,
    .popup-product-badge {
        transition: none;
        animation: none;
    }

    .popup-product-card {
        opacity: 1;
        transform: none;
    }

    .popup-modal.active {
        transform: translate(-50%, -50%);
    }

    .popup-banner.active,
    .popup-slidein.active,
    .popup-notification.active {
        transform: none;
    }
}

/* =============================================================================
   Print Styles
   ============================================================================= */
@media print {
    .popup-modal,
    .popup-modal-backdrop,
    .popup-banner,
    .popup-slidein,
    .popup-notification {
        display: none !important;
    }
}
