/**
 * Promo Bar Frontend Styles
 * Uses CSS custom properties for dynamic theming
 * CSS media queries for device targeting
 */

/* Reset and base styles */
.promo-bar {
    display: none; /* Hidden by default, shown by media query rules */
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    z-index: 9999;
}

.promo-bar *,
.promo-bar *::before,
.promo-bar *::after {
    box-sizing: inherit;
}

/* Device targeting via media queries */
@media (min-width: 768px) {
    /* Desktop rules */
    body.has-promo-bar[data-promo-target="desktop"] .promo-bar,
    body.has-promo-bar[data-promo-target="both"] .promo-bar {
        display: flex !important;
    }

    .promo-text-mobile,
    .promo-button-label-mobile {
        display: none !important;
    }

    .promo-text-desktop,
    .promo-button-label-desktop {
        display: inline !important;
    }
}

@media (max-width: 767px) {
    /* Mobile rules */
    body.has-promo-bar[data-promo-target="mobile"] .promo-bar,
    body.has-promo-bar[data-promo-target="both"] .promo-bar {
        display: flex !important;
    }

    .promo-text-desktop,
    .promo-button-label-desktop {
        display: none !important;
    }

    .promo-text-mobile,
    .promo-button-label-mobile {
        display: inline !important;
    }

    /* Mobile top bar adjustments - keep single line */
    .promo-bar-top {
        height: var(--promo-bar-height, 50px);
        padding: 0 12px;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .promo-bar-container {
        gap: 8px;
        flex-wrap: nowrap;
        min-width: min-content;
    }

    .promo-bar-text {
        font-size: var(--promo-bar-font-size-mobile, 13px);
        line-height: var(--promo-bar-height, 50px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .promo-bar-button {
        padding: 8px 14px;
        font-size: var(--promo-button-font-size-mobile, 13px);
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Mobile bottom button adjustments */
    .promo-bar-bottom {
        bottom: 15px;
        padding: 10px 20px;
        font-size: var(--promo-button-font-size-mobile, 13px);
    }

    /* Mobile body padding - only when promo bar is visible on mobile */
    body.promo-layout-top_bar.has-promo-bar[data-promo-target="mobile"],
    body.promo-layout-top_bar.has-promo-bar[data-promo-target="both"] {
        padding-top: var(--promo-bar-height, 50px);
    }
}

/* Top Bar Layout */
.promo-bar-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: var(--promo-bar-height, 50px);
    background-color: var(--promo-bar-bg, #0073aa);
    color: var(--promo-bar-text, #ffffff);
    font-size: var(--promo-bar-font-size, 14px);
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.promo-bar-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    gap: 16px;
}

.promo-bar-text {
    flex: 0 1 auto;
    margin: 0;
}

/* Adjust body padding when top bar is active - only on devices where it's visible */
@media (min-width: 768px) {
    body.promo-layout-top_bar.has-promo-bar[data-promo-target="desktop"],
    body.promo-layout-top_bar.has-promo-bar[data-promo-target="both"] {
        padding-top: var(--promo-bar-height, 50px);
    }
}

/* Account for WordPress admin bar */
body.admin-bar.promo-layout-top_bar.has-promo-bar .promo-bar-top {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar.promo-layout-top_bar.has-promo-bar .promo-bar-top {
        top: 46px;
    }
}

/* Bottom Button Layout */
.promo-bar-bottom {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--promo-button-bg, #ff6b35);
    color: var(--promo-button-text, #ffffff);
    font-size: var(--promo-button-font-size, 14px);
    padding: 12px 24px;
    border-radius: 50px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
    max-width: calc(100vw - 40px);
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    align-items: center;
    justify-content: center;
}

.promo-bar-bottom:hover {
    background-color: var(--promo-button-hover-bg, var(--promo-button-bg, #ff6b35));
    color: var(--promo-button-hover-text, var(--promo-button-text, #ffffff));
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    text-decoration: none;
}

.promo-bar-bottom:active {
    transform: translateX(-50%) translateY(0);
}

/* Button styling (for top bar CTA) */
.promo-bar-button {
    background-color: var(--promo-button-bg, #ff6b35);
    color: var(--promo-button-text, #ffffff);
    font-size: var(--promo-button-font-size, 14px);
    padding: 5px 20px;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.promo-bar-button:hover {
    background-color: var(--promo-button-hover-bg, var(--promo-button-bg, #ff6b35));
    color: var(--promo-button-hover-text, var(--promo-button-text, #ffffff));
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    text-decoration: none;
}

.promo-bar-button:active {
    transform: translateY(0);
}

/* Responsive adjustments */
/* Animation Keyframes */

@keyframes promo-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes promo-shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* Shake animation for centered bottom button */
@keyframes promo-shake-centered {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    25% {
        transform: translateX(-50%) translateX(-5px);
    }
    75% {
        transform: translateX(-50%) translateX(5px);
    }
}

/* Rotate animation - rotates ±10 degrees */
@keyframes promo-rotate {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-8deg);
    }
    75% {
        transform: rotate(8deg);
    }
}

/* Rotate animation for centered bottom button */
@keyframes promo-rotate-centered {
    0%, 100% {
        transform: translateX(-50%) rotate(0deg);
    }
    25% {
        transform: translateX(-50%) rotate(-8deg);
    }
    75% {
        transform: translateX(-50%) rotate(8deg);
    }
}

@keyframes promo-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* Bounce animation for centered bottom button */
@keyframes promo-bounce-centered {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-8px);
    }
}

@keyframes promo-glow {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 4px 20px rgba(255, 107, 53, 0.5);
    }
}

/* Animation classes applied by JS */
.promo-animate-pulse {
    animation: promo-pulse var(--promo-animation-duration, 0.6s) ease-in-out;
}

.promo-animate-shake {
    animation: promo-shake var(--promo-animation-duration, 0.4s) ease-in-out;
}

.promo-animate-shake_diagonal {
    animation: promo-rotate var(--promo-animation-duration, 0.4s) ease-in-out;
}

.promo-animate-bounce {
    animation: promo-bounce var(--promo-animation-duration, 0.5s) ease-in-out;
}

.promo-animate-glow {
    animation: promo-glow var(--promo-animation-duration, 0.8s) ease-in-out;
}

/* Bottom button uses centered animations */
.promo-bar-bottom.promo-animate-shake {
    animation: promo-shake-centered var(--promo-animation-duration, 0.4s) ease-in-out;
}

.promo-bar-bottom.promo-animate-shake_diagonal {
    animation: promo-rotate-centered var(--promo-animation-duration, 0.4s) ease-in-out;
}

.promo-bar-bottom.promo-animate-bounce {
    animation: promo-bounce-centered var(--promo-animation-duration, 0.5s) ease-in-out;
}

/* Ensure animations don't interfere with hover states */
.promo-bar-bottom.promo-animate-pulse:hover,
.promo-bar-bottom.promo-animate-shake:hover,
.promo-bar-bottom.promo-animate-bounce:hover {
    animation: none;
}

/* Print styles - hide promo bar when printing */
@media print {
    .promo-bar {
        display: none !important;
    }

    body.promo-layout-top_bar.has-promo-bar {
        padding-top: 0 !important;
    }
}

/* Accessibility improvements */
.promo-bar:focus,
.promo-bar-button:focus,
.promo-bar-bottom:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .promo-bar,
    .promo-bar-button,
    .promo-bar-bottom {
        transition: none;
        animation: none !important;
    }
}
