/**
 * Biorganica Email Popups - Frontend Styles
 * Uses CSS custom properties for easy theming
 */

:root {
    --bep-primary: #2d5016;
    --bep-primary-hover: #3a6b1c;
    --bep-accent: #7d5ba6;
    --bep-bg: #ffffff;
    --bep-text: #333333;
    --bep-text-muted: #666666;
    --bep-border: #e0e0e0;
    --bep-radius: 12px;
    --bep-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    --bep-overlay: rgba(0, 0, 0, 0.5);
    --bep-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ========================
   Overlay (modal only)
   ======================== */
.bep-overlay {
    position: fixed;
    inset: 0;
    background: var(--bep-overlay);
    z-index: 999998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.bep-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ========================
   Modal Popup
   ======================== */
.bep-popup--modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 999999;
    background: var(--bep-bg);
    border-radius: var(--bep-radius);
    box-shadow: var(--bep-shadow);
    max-width: 480px;
    width: calc(100% - 40px);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    font-family: var(--bep-font);
}

.bep-popup--modal.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

/* ========================
   Slide-in Popup
   ======================== */
.bep-popup--slide-in {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    background: var(--bep-bg);
    border-radius: var(--bep-radius);
    box-shadow: var(--bep-shadow);
    max-width: 380px;
    width: calc(100% - 40px);
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: var(--bep-font);
}

.bep-popup--slide-in.visible {
    transform: translateX(0);
}

/* ========================
   Top Bar Popup
   ======================== */
.bep-popup--top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    background: var(--bep-primary);
    color: white;
    transform: translateY(-100%);
    transition: transform 0.4s ease;
    font-family: var(--bep-font);
}

.bep-popup--top-bar.visible {
    transform: translateY(0);
}

.bep-popup--top-bar .bep-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 20px;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.bep-popup--top-bar .bep-heading {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: white;
}

.bep-popup--top-bar .bep-subheading {
    font-size: 12px;
    opacity: 0.9;
    color: white;
}

.bep-popup--top-bar .bep-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.bep-popup--top-bar .bep-input {
    padding: 8px 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 13px;
    min-width: 220px;
}

.bep-popup--top-bar .bep-input::placeholder {
    color: rgba(255,255,255,0.7);
}

.bep-popup--top-bar .bep-input:focus {
    outline: none;
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.2);
}

.bep-popup--top-bar .bep-submit {
    padding: 8px 20px;
    background: white;
    color: var(--bep-primary);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.bep-popup--top-bar .bep-submit:hover {
    opacity: 0.9;
}

.bep-popup--top-bar .bep-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.bep-popup--top-bar .bep-close:hover {
    color: white;
}

/* ========================
   Exit Intent (uses modal layout)
   ======================== */
.bep-popup--exit-intent {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 999999;
    background: var(--bep-bg);
    border-radius: var(--bep-radius);
    box-shadow: var(--bep-shadow);
    max-width: 500px;
    width: calc(100% - 40px);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    font-family: var(--bep-font);
}

.bep-popup--exit-intent.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

/* ========================
   Inline Popup (shortcode)
   ======================== */
.bep-popup--inline {
    background: var(--bep-bg);
    border: 1px solid var(--bep-border);
    border-radius: var(--bep-radius);
    font-family: var(--bep-font);
    overflow: hidden;
}

/* ========================
   Common Content Styles
   ======================== */
.bep-popup-inner {
    padding: 32px 28px;
    text-align: center;
    position: relative;
}

.bep-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--bep-text-muted);
    padding: 4px 8px;
    line-height: 1;
    z-index: 1;
    transition: color 0.15s;
}

.bep-close:hover {
    color: var(--bep-text);
}

.bep-heading {
    font-size: 22px;
    font-weight: 700;
    color: var(--bep-text);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.bep-subheading {
    font-size: 14px;
    color: var(--bep-text-muted);
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.bep-incentive-badge {
    display: inline-block;
    background: var(--bep-accent);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Form */
.bep-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bep-field-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
}

.bep-field-label {
    font-size: 12px;
    color: var(--bep-text-muted);
    font-weight: 500;
}

.bep-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--bep-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--bep-text);
    background: white;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.bep-input:focus {
    outline: none;
    border-color: var(--bep-primary);
}

.bep-input.error {
    border-color: #dc3545;
}

.bep-submit {
    width: 100%;
    padding: 12px 20px;
    background: var(--bep-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 4px;
}

.bep-submit:hover {
    background: var(--bep-primary-hover);
}

.bep-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.bep-error-msg {
    color: #dc3545;
    font-size: 12px;
    text-align: center;
}

.bep-privacy {
    font-size: 11px;
    color: var(--bep-text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

/* Success State */
.bep-success {
    text-align: center;
    padding: 24px 0;
}

.bep-success-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.bep-success-heading {
    font-size: 20px;
    font-weight: 700;
    color: var(--bep-text);
    margin: 0 0 8px 0;
}

.bep-success-message {
    font-size: 14px;
    color: var(--bep-text-muted);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.bep-discount-code {
    display: inline-block;
    background: #f0fdf4;
    border: 2px dashed #22c55e;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 18px;
    font-weight: 700;
    color: var(--bep-primary);
    letter-spacing: 2px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.bep-discount-code:hover {
    background: #dcfce7;
}

.bep-discount-code-hint {
    font-size: 11px;
    color: var(--bep-text-muted);
}

/* Image area */
.bep-image {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--bep-radius) var(--bep-radius) 0 0;
}

/* ========================
   Mobile Adjustments
   ======================== */
@media (max-width: 600px) {
    /* No full-screen modals on mobile (Google penalty) */
    .bep-popup--modal,
    .bep-popup--exit-intent {
        display: none !important;
    }

    .bep-overlay {
        display: none !important;
    }

    .bep-popup--slide-in {
        bottom: 0;
        right: 0;
        left: 0;
        max-width: 100%;
        border-radius: var(--bep-radius) var(--bep-radius) 0 0;
    }

    .bep-popup-inner {
        padding: 24px 20px;
    }

    .bep-heading {
        font-size: 18px;
    }

    /* Mobile top-bar: Stack vertically for better readability */
    .bep-popup--top-bar .bep-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px 40px 14px 16px;
        text-align: center;
    }

    .bep-popup--top-bar .bep-heading {
        font-size: 15px;
        font-weight: 700;
        margin: 0;
    }

    .bep-popup--top-bar .bep-subheading {
        display: none; /* Hide redundant subheading on mobile */
    }

    .bep-popup--top-bar .bep-form {
        flex-direction: row;
        gap: 8px;
        width: 100%;
    }

    .bep-popup--top-bar .bep-input {
        flex: 1;
        min-width: 0;
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 6px;
    }

    .bep-popup--top-bar .bep-submit {
        padding: 10px 16px;
        font-size: 14px;
        flex-shrink: 0;
        border-radius: 6px;
    }

    .bep-popup--top-bar .bep-close {
        right: 10px;
        top: 10px;
        transform: none;
        font-size: 20px;
        padding: 4px 8px;
        color: rgba(255,255,255,0.9);
    }
}

/* Extra small screens (iPhone SE): Make button full width */
@media (max-width: 380px) {
    .bep-popup--top-bar .bep-content {
        padding: 12px 36px 12px 12px;
    }

    .bep-popup--top-bar .bep-form {
        flex-direction: column;
        gap: 8px;
    }

    .bep-popup--top-bar .bep-input {
        width: 100%;
    }

    .bep-popup--top-bar .bep-submit {
        width: 100%;
    }
}

/* ========================
   Animations
   ======================== */
@keyframes bep-shake {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-50%, -50%) scale(1) translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translate(-50%, -50%) scale(1) translateX(4px); }
}

.bep-popup--modal.shake,
.bep-popup--exit-intent.shake {
    animation: bep-shake 0.5s ease;
}
