/**
 * WSU Tiered Discounts - Component Styles
 * 
 * Conversion-optimized styling for all 6 component types:
 * 1. Top Bar (sticky notification)
 * 2. Footer Bar (exit capture)
 * 3. Banners (educational hero sections)
 * 4. Progress Widgets (gamification)
 * 5. Floating Widget (persistent reminder)
 * 6. Floating Button (action-focused)
 * 7. Sidebar Panel (detailed breakdown)
 * 
 * Design System based on conversion psychology principles.
 * 
 * @package WSU_Tiered_Discounts
 * @version 2.0.0
 */

/* ============================================================================
   CSS CUSTOM PROPERTIES (DESIGN SYSTEM)
   ============================================================================ */

:root {
    /* Primary Brand Colors */
    --wsu-primary: #2271b1;
    --wsu-primary-dark: #135e96;
    --wsu-primary-light: #4f94d4;
    --wsu-secondary: #00a32a;
    --wsu-secondary-dark: #008a20;

    /* Tier Colors */
    --wsu-silver: #c0c0c0;
    --wsu-silver-accent: #a8a8a8;
    --wsu-silver-light: #e8e8e8;
    --wsu-gold: #ffd700;
    --wsu-gold-accent: #ffed4e;
    --wsu-gold-dark: #daa520;

    /* Semantic Colors */
    --wsu-success: #00a32a;
    --wsu-success-bg: #ecfdf5;
    --wsu-warning: #f0b429;
    --wsu-warning-bg: #fef3c7;
    --wsu-danger: #d63638;
    --wsu-danger-bg: #fee2e2;
    --wsu-info: #2271b1;
    --wsu-info-bg: #e0f2fe;

    /* Savings Highlight */
    --wsu-savings-green: #10b981;
    --wsu-savings-bg: #d1fae5;

    /* Neutral Palette */
    --wsu-gray-50: #f9fafb;
    --wsu-gray-100: #f3f4f6;
    --wsu-gray-200: #e5e7eb;
    --wsu-gray-300: #d1d5db;
    --wsu-gray-400: #9ca3af;
    --wsu-gray-500: #6b7280;
    --wsu-gray-600: #4b5563;
    --wsu-gray-700: #374151;
    --wsu-gray-800: #1f2937;
    --wsu-gray-900: #111827;

    /* Typography Scale */
    --wsu-font-h1: 32px;
    --wsu-font-h2: 24px;
    --wsu-font-h3: 20px;
    --wsu-font-h4: 18px;
    --wsu-font-body-large: 18px;
    --wsu-font-body: 16px;
    --wsu-font-body-small: 14px;
    --wsu-font-caption: 12px;
    --wsu-font-savings: 24px;

    /* Line Heights */
    --wsu-line-height-tight: 1.2;
    --wsu-line-height-normal: 1.5;
    --wsu-line-height-relaxed: 1.6;

    /* Spacing System (8px base) */
    --wsu-space-1: 8px;
    --wsu-space-2: 16px;
    --wsu-space-3: 24px;
    --wsu-space-4: 32px;
    --wsu-space-5: 40px;
    --wsu-space-6: 48px;

    /* Border Radius */
    --wsu-radius-sm: 4px;
    --wsu-radius-md: 8px;
    --wsu-radius-lg: 12px;
    --wsu-radius-xl: 16px;
    --wsu-radius-full: 50%;

    /* Shadows */
    --wsu-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --wsu-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --wsu-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --wsu-shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

    /* Transitions */
    --wsu-transition-fast: 150ms ease-out;
    --wsu-transition-normal: 250ms ease-out;
    --wsu-transition-slow: 400ms ease-out;

    /* Z-Index Scale */
    --wsu-z-top-bar: 9999;
    --wsu-z-footer-bar: 9998;
    --wsu-z-floating: 9997;
    --wsu-z-sidebar-overlay: 9996;
    --wsu-z-sidebar: 9997;
}

/* ============================================================================
   TOP BAR (STICKY NOTIFICATION)
   ============================================================================ */

.wsu-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--wsu-z-top-bar);
    background: linear-gradient(135deg, var(--wsu-primary) 0%, var(--wsu-primary-light) 100%);
    color: #fff;
    padding: var(--wsu-space-2) var(--wsu-space-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--wsu-space-2);
    box-shadow: var(--wsu-shadow-md);
    animation: slideDown var(--wsu-transition-slow) ease-out;
    min-height: 50px;
}

.wsu-top-bar__content {
    display: flex;
    align-items: center;
    gap: var(--wsu-space-2);
    flex: 1;
    flex-wrap: wrap;
}

.wsu-top-bar__icon {
    font-size: var(--wsu-font-h3);
    flex-shrink: 0;
}

.wsu-top-bar__text {
    flex: 1;
    min-width: 200px;
}

.wsu-top-bar__message {
    font-size: var(--wsu-font-body);
    font-weight: 600;
    line-height: var(--wsu-line-height-tight);
}

.wsu-top-bar__savings {
    font-size: var(--wsu-font-savings);
    font-weight: 700;
    color: var(--wsu-gold);
    margin: 0 var(--wsu-space-1);
}

.wsu-top-bar__progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--wsu-gold);
    transition: width var(--wsu-transition-slow);
    animation: fillProgress 1s ease-out;
}

.wsu-top-bar__cta {
    background: #fff;
    color: var(--wsu-primary);
    padding: var(--wsu-space-1) var(--wsu-space-3);
    border-radius: var(--wsu-radius-md);
    font-weight: 600;
    font-size: var(--wsu-font-body-small);
    text-decoration: none;
    transition: all var(--wsu-transition-fast);
    white-space: nowrap;
    border: none;
    cursor: pointer;
}

.wsu-top-bar__cta:hover {
    background: var(--wsu-gray-100);
    transform: translateY(-1px);
    box-shadow: var(--wsu-shadow-sm);
}

.wsu-top-bar__close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: var(--wsu-radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    transition: background var(--wsu-transition-fast);
    flex-shrink: 0;
}

.wsu-top-bar__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Top Bar States */
.wsu-top-bar--awareness {
    background: linear-gradient(135deg, var(--wsu-info) 0%, var(--wsu-primary-light) 100%);
}

.wsu-top-bar--motivation {
    background: linear-gradient(135deg, var(--wsu-warning) 0%, #fbbf24 100%);
}

.wsu-top-bar--celebration {
    background: linear-gradient(135deg, var(--wsu-success) 0%, var(--wsu-savings-green) 100%);
}

.wsu-top-bar--affirmation {
    background: linear-gradient(135deg, var(--wsu-gold-dark) 0%, var(--wsu-gold) 100%);
}

/* Top Bar - Mobile */
@media (max-width: 767px) {
    .wsu-top-bar {
        min-height: 44px;
        padding: var(--wsu-space-1) var(--wsu-space-2);
    }

    .wsu-top-bar__message {
        font-size: var(--wsu-font-body-small);
    }

    .wsu-top-bar__savings {
        font-size: var(--wsu-font-h4);
    }

    .wsu-top-bar__cta {
        font-size: var(--wsu-font-caption);
        padding: var(--wsu-space-1) var(--wsu-space-2);
    }
}

/* ============================================================================
   FOOTER BAR (STICKY BOTTOM CTA)
   ============================================================================ */

.wsu-footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--wsu-z-footer-bar);
    background: #fff;
    padding: var(--wsu-space-2) var(--wsu-space-3);
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
    animation: slideUp var(--wsu-transition-slow) ease-out;
    display: none;
    /* Shown via JS when appropriate */
}

.wsu-footer-bar--visible {
    display: block;
}

.wsu-footer-bar__content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--wsu-space-3);
}

.wsu-footer-bar__message {
    flex: 1;
}

.wsu-footer-bar__heading {
    font-size: var(--wsu-font-h4);
    font-weight: 700;
    color: var(--wsu-gray-900);
    margin: 0 0 var(--wsu-space-1);
}

.wsu-footer-bar__text {
    font-size: var(--wsu-font-body-small);
    color: var(--wsu-gray-600);
    margin: 0;
}

.wsu-footer-bar__savings {
    color: var(--wsu-savings-green);
    font-weight: 700;
}

.wsu-footer-bar__products {
    display: flex;
    gap: var(--wsu-space-2);
}

.wsu-footer-bar__product {
    width: 60px;
    height: 60px;
    border-radius: var(--wsu-radius-md);
    object-fit: cover;
    border: 2px solid var(--wsu-gray-200);
}

.wsu-footer-bar__cta {
    background: linear-gradient(135deg, var(--wsu-warning) 0%, #f59e0b 100%);
    color: #fff;
    padding: var(--wsu-space-2) var(--wsu-space-4);
    border-radius: var(--wsu-radius-md);
    font-weight: 700;
    font-size: var(--wsu-font-body);
    text-decoration: none;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    transition: all var(--wsu-transition-fast);
    box-shadow: var(--wsu-shadow-md);
}

.wsu-footer-bar__cta:hover {
    transform: translateY(-2px);
    box-shadow: var(--wsu-shadow-lg);
}

/* Footer Bar - Mobile */
@media (max-width: 767px) {
    .wsu-footer-bar {
        padding: var(--wsu-space-2);
        padding-bottom: calc(var(--wsu-space-2) + env(safe-area-inset-bottom));
    }

    .wsu-footer-bar__content {
        flex-direction: column;
        align-items: stretch;
        gap: var(--wsu-space-2);
    }

    .wsu-footer-bar__products {
        justify-content: center;
    }

    .wsu-footer-bar__product {
        width: 50px;
        height: 50px;
    }

    .wsu-footer-bar__cta {
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================================================
   FLOATING BUTTON (ACTION-FOCUSED)
   ============================================================================ */

.wsu-floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--wsu-z-floating);
    width: 56px;
    height: 56px;
    border-radius: var(--wsu-radius-full);
    background: linear-gradient(135deg, var(--wsu-primary) 0%, var(--wsu-primary-light) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--wsu-shadow-lg);
    transition: all var(--wsu-transition-fast);
}

.wsu-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--wsu-shadow-xl);
}

.wsu-floating-btn__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--wsu-danger);
    color: #fff;
    min-width: 24px;
    height: 24px;
    border-radius: var(--wsu-radius-full);
    font-size: var(--wsu-font-caption);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: var(--wsu-shadow-md);
}

.wsu-floating-btn__tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: var(--wsu-gray-900);
    color: #fff;
    padding: var(--wsu-space-1) var(--wsu-space-2);
    border-radius: var(--wsu-radius-md);
    font-size: var(--wsu-font-body-small);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--wsu-transition-fast);
    pointer-events: none;
}

.wsu-floating-btn:hover .wsu-floating-btn__tooltip {
    opacity: 1;
    visibility: visible;
}

/* Floating Button States */
.wsu-floating-btn--motivational {
    background: linear-gradient(135deg, var(--wsu-info) 0%, var(--wsu-primary-light) 100%);
}

.wsu-floating-btn--progress {
    background: linear-gradient(135deg, var(--wsu-warning) 0%, #f59e0b 100%);
    animation: pulse 2s ease-in-out infinite;
}

.wsu-floating-btn--achievement {
    background: linear-gradient(135deg, var(--wsu-success) 0%, var(--wsu-savings-green) 100%);
}

/* Floating Button - Mobile */
@media (max-width: 767px) {
    .wsu-floating-btn {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* ============================================================================
   FLOATING WIDGET (PERSISTENT OVERLAY)
   ============================================================================ */

.wsu-floating-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--wsu-z-floating);
    background: #fff;
    border-radius: var(--wsu-radius-xl);
    box-shadow: var(--wsu-shadow-xl);
    transition: all var(--wsu-transition-normal);
    overflow: hidden;
}

/* Collapsed State (Badge) */
.wsu-floating-widget--collapsed {
    width: 60px;
    height: 60px;
    cursor: pointer;
}

.wsu-floating-widget--collapsed .wsu-floating-widget__header,
.wsu-floating-widget--collapsed .wsu-floating-widget__body,
.wsu-floating-widget--collapsed .wsu-floating-widget__footer {
    display: none;
}

.wsu-floating-widget--collapsed .wsu-floating-widget__badge {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--wsu-primary) 0%, var(--wsu-primary-light) 100%);
    color: #fff;
    font-size: var(--wsu-font-h3);
    font-weight: 700;
}

/* Mini State (Expanded Badge) */
.wsu-floating-widget--mini {
    width: 120px;
    height: 120px;
    cursor: pointer;
}

.wsu-floating-widget--mini .wsu-floating-widget__header,
.wsu-floating-widget--mini .wsu-floating-widget__footer {
    display: none;
}

.wsu-floating-widget--mini .wsu-floating-widget__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--wsu-space-2);
    text-align: center;
}

.wsu-floating-widget--mini .wsu-floating-widget__progress {
    font-size: var(--wsu-font-h2);
    font-weight: 700;
    color: var(--wsu-primary);
    margin-bottom: var(--wsu-space-1);
}

.wsu-floating-widget--mini .wsu-floating-widget__savings {
    font-size: var(--wsu-font-body);
    font-weight: 700;
    color: var(--wsu-savings-green);
}

/* Full Widget State */
.wsu-floating-widget--expanded {
    width: 320px;
    max-height: 400px;
    cursor: default;
}

.wsu-floating-widget__header {
    background: var(--wsu-primary);
    color: #fff;
    padding: var(--wsu-space-2) var(--wsu-space-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wsu-floating-widget__title {
    font-size: var(--wsu-font-h4);
    font-weight: 700;
    margin: 0;
}

.wsu-floating-widget__close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: var(--wsu-radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: background var(--wsu-transition-fast);
}

.wsu-floating-widget__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wsu-floating-widget__body {
    padding: var(--wsu-space-3);
    max-height: 300px;
    overflow-y: auto;
}

.wsu-floating-widget__footer {
    padding: var(--wsu-space-2) var(--wsu-space-3);
    border-top: 1px solid var(--wsu-gray-200);
    display: flex;
    gap: var(--wsu-space-2);
}

.wsu-floating-widget__btn {
    flex: 1;
    padding: var(--wsu-space-2);
    border-radius: var(--wsu-radius-md);
    font-weight: 600;
    font-size: var(--wsu-font-body-small);
    text-align: center;
    text-decoration: none;
    transition: all var(--wsu-transition-fast);
    border: none;
    cursor: pointer;
}

.wsu-floating-widget__btn--primary {
    background: var(--wsu-primary);
    color: #fff;
}

.wsu-floating-widget__btn--primary:hover {
    background: var(--wsu-primary-dark);
}

.wsu-floating-widget__btn--secondary {
    background: var(--wsu-gray-100);
    color: var(--wsu-gray-700);
}

.wsu-floating-widget__btn--secondary:hover {
    background: var(--wsu-gray-200);
}

/* Floating Widget - Draggable */
.wsu-floating-widget--draggable {
    cursor: move;
}

/* Floating Widget - Mobile */
@media (max-width: 767px) {
    .wsu-floating-widget {
        bottom: calc(20px + env(safe-area-inset-bottom));
        right: 50%;
        transform: translateX(50%);
    }

    .wsu-floating-widget--expanded {
        width: calc(100vw - 40px);
        max-width: 320px;
    }
}

/* ============================================================================
   SIDEBAR PANEL (DETAILED BREAKDOWN)
   ============================================================================ */

.wsu-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--wsu-z-sidebar-overlay);
    opacity: 0;
    visibility: hidden;
    transition: all var(--wsu-transition-normal);
}

.wsu-sidebar-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.wsu-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    background: #fff;
    z-index: var(--wsu-z-sidebar);
    transform: translateX(100%);
    transition: transform var(--wsu-transition-normal) ease-out;
    display: flex;
    flex-direction: column;
    box-shadow: var(--wsu-shadow-xl);
}

.wsu-sidebar--open {
    transform: translateX(0);
}

.wsu-sidebar__header {
    background: var(--wsu-primary);
    color: #fff;
    padding: var(--wsu-space-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wsu-sidebar__title {
    font-size: var(--wsu-font-h3);
    font-weight: 700;
    margin: 0 0 var(--wsu-space-1);
}

.wsu-sidebar__subtitle {
    font-size: var(--wsu-font-body-small);
    opacity: 0.9;
    margin: 0;
}

.wsu-sidebar__close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: var(--wsu-radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    transition: background var(--wsu-transition-fast);
    flex-shrink: 0;
}

.wsu-sidebar__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wsu-sidebar__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--wsu-space-3);
}

.wsu-sidebar__section {
    margin-bottom: var(--wsu-space-4);
}

.wsu-sidebar__section-title {
    font-size: var(--wsu-font-h4);
    font-weight: 700;
    margin: 0 0 var(--wsu-space-2);
    color: var(--wsu-gray-900);
}

.wsu-sidebar__footer {
    padding: var(--wsu-space-3);
    border-top: 1px solid var(--wsu-gray-200);
    display: flex;
    gap: var(--wsu-space-2);
    flex-shrink: 0;
}

.wsu-sidebar__btn {
    flex: 1;
    padding: var(--wsu-space-2) var(--wsu-space-3);
    border-radius: var(--wsu-radius-md);
    font-weight: 700;
    font-size: var(--wsu-font-body);
    text-align: center;
    text-decoration: none;
    transition: all var(--wsu-transition-fast);
    border: none;
    cursor: pointer;
    min-height: 48px;
}

.wsu-sidebar__btn--primary {
    background: var(--wsu-primary);
    color: #fff;
}

.wsu-sidebar__btn--primary:hover {
    background: var(--wsu-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--wsu-shadow-md);
}

.wsu-sidebar__btn--secondary {
    background: var(--wsu-gray-100);
    color: var(--wsu-gray-700);
}

.wsu-sidebar__btn--secondary:hover {
    background: var(--wsu-gray-200);
}

/* Sidebar - Mobile */
@media (max-width: 767px) {
    .wsu-sidebar {
        width: 100vw;
        max-width: 100vw;
    }
}

/* ============================================================================
   ANIMATIONS & KEYFRAMES
   ============================================================================ */

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes fillProgress {
    from {
        width: 0%;
    }

    to {
        width: var(--progress-width, 50%);
    }
}

/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .wsu-floating-btn--progress {
        animation: none;
    }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.wsu-hidden {
    display: none !important;
}

.wsu-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}