/**
 * WooCommerce Live Gold & Silver Rate Popup - Frontend Styles
 * Premium Glassmorphism Design
 *
 * @package Woo_Live_Rates
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --wlr-primary: #f97316;
    --wlr-secondary: #ea580c;
    --wlr-bg: rgba(255, 255, 255, 0.95);
    --wlr-glass-blur: 10px;
    --wlr-border-radius: 18px;
    --wlr-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --wlr-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --wlr-button: #f97316;
    --wlr-width: 350px;
    --wlr-height: auto;
    --wlr-text: #1f2937;
    --wlr-text-light: #6b7280;
    --wlr-positive: #10b981;
    --wlr-negative: #ef4444;
    --wlr-gold: linear-gradient(135deg, #f59e0b, #d97706);
    --wlr-silver: linear-gradient(135deg, #9ca3af, #6b7280);
}

/* ========================================
   Popup Container
   ======================================== */
.wlr-popup {
    position: fixed;
    z-index: 999999;
    font-family: var(--wlr-font);
    color: var(--wlr-text);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: var(--wlr-width);
    max-height: var(--wlr-height);
    overflow: hidden;
}

/* Position variants */
.wlr-popup.wlr-popup-bottom-right {
    bottom: 20px;
    right: -100%;
}

.wlr-popup.wlr-popup-bottom-left {
    bottom: 20px;
    left: -100%;
}

.wlr-popup.wlr-popup-top-right {
    top: 20px;
    right: -100%;
}

.wlr-popup.wlr-popup-top-left {
    top: 20px;
    left: -100%;
}

/* Show state */
.wlr-popup.wlr-show {
    opacity: 1;
    visibility: visible;
}

.wlr-popup.wlr-show.wlr-popup-bottom-right,
.wlr-popup.wlr-show.wlr-popup-top-right {
    right: 20px;
}

.wlr-popup.wlr-show.wlr-popup-bottom-left,
.wlr-popup.wlr-show.wlr-popup-top-left {
    left: 20px;
}

/* ========================================
   Mobile Positioning
   ======================================== */
@media (max-width: 768px) {
    .wlr-popup {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) translateY(100%);
        width: calc(100% - 40px);
        max-width: 400px;
        bottom: 20px !important;
        top: auto !important;
    }

    .wlr-popup.wlr-show {
        transform: translateX(-50%) translateY(0);
    }

    .wlr-toggle-btn {
        left: 50% !important;
        right: auto !important;
        bottom: 20px !important;
        top: auto !important;
        transform: translateX(-50%);
    }
}

/* ========================================
   Glassmorphism Effect
   ======================================== */
.wlr-popup {
    background: var(--wlr-bg);
    backdrop-filter: blur(var(--wlr-glass-blur));
    -webkit-backdrop-filter: blur(var(--wlr-glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--wlr-border-radius);
    box-shadow: var(--wlr-shadow);
}

/* ========================================
   Header
   ======================================== */
.wlr-popup-header {
    background: linear-gradient(135deg, var(--wlr-primary), var(--wlr-secondary));
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
}

.wlr-popup-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    pointer-events: none;
}

.wlr-header-content {
    position: relative;
    z-index: 1;
}

.wlr-header-title {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wlr-header-subtitle {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
}

/* ========================================
   Close Button
   ======================================== */
.wlr-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.wlr-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

.wlr-close-btn:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ========================================
   Body
   ======================================== */
.wlr-popup-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========================================
   Rate Card
   ======================================== */
.wlr-rate-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(249, 250, 251, 0.95));
    border-radius: 14px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wlr-rate-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

.wlr-card-gold::before {
    background: var(--wlr-gold);
}

.wlr-card-silver::before {
    background: var(--wlr-silver);
}

.wlr-rate-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

/* ========================================
   Card Icon
   ======================================== */
.wlr-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wlr-card-gold .wlr-card-icon {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #d97706;
}

.wlr-card-silver .wlr-card-icon {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    color: #6b7280;
}

/* ========================================
   Card Content
   ======================================== */
.wlr-card-content {
    flex: 1;
    min-width: 0;
}

.wlr-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.wlr-card-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--wlr-text);
}

.wlr-card-purity {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--wlr-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wlr-card-rate {
    display: flex;
    align-items: baseline;
    gap: 2px;
    margin-bottom: 4px;
}

.wlr-currency {
    font-size: 16px;
    font-weight: 600;
    color: var(--wlr-text);
}

.wlr-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--wlr-text);
    line-height: 1;
}

.wlr-unit {
    font-size: 12px;
    color: var(--wlr-text-light);
    margin-left: 4px;
}

/* ========================================
   Price Change
   ======================================== */
.wlr-card-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

.wlr-card-change.wlr-positive {
    background: rgba(16, 185, 129, 0.1);
    color: var(--wlr-positive);
}

.wlr-card-change.wlr-negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--wlr-negative);
}

.wlr-change-arrow {
    font-size: 10px;
}

.wlr-change-label {
    font-weight: 400;
    opacity: 0.8;
}

/* ========================================
   Footer
   ======================================== */
.wlr-popup-footer {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.02);
}

.wlr-last-updated {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wlr-update-label {
    font-size: 10px;
    color: var(--wlr-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wlr-update-time {
    font-size: 11px;
    font-weight: 500;
    color: var(--wlr-text);
}

/* ========================================
   Refresh Button
   ======================================== */
.wlr-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--wlr-button);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wlr-refresh-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.wlr-refresh-btn:focus {
    outline: 2px solid var(--wlr-button);
    outline-offset: 2px;
}

.wlr-refresh-btn svg {
    transition: transform 0.5s ease;
}

.wlr-refresh-btn:hover svg {
    transform: rotate(180deg);
}

.wlr-refresh-btn.loading svg {
    animation: wlr-spin 1s linear infinite;
}

/* ========================================
   Toggle Button
   ======================================== */
.wlr-toggle-btn {
    position: fixed;
    z-index: 999998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wlr-primary), var(--wlr-secondary));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4);
    transition: all 0.3s ease;
    animation: wlr-pulse 2s infinite;
}

.wlr-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(249, 115, 22, 0.5);
}

.wlr-toggle-btn:focus {
    outline: 2px solid var(--wlr-primary);
    outline-offset: 3px;
}

.wlr-toggle-btn.wlr-popup-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wlr-toggle-btn.wlr-popup-bottom-left {
    bottom: 20px;
    left: 20px;
}

.wlr-toggle-btn.wlr-popup-top-right {
    top: 20px;
    right: 20px;
}

.wlr-toggle-btn.wlr-popup-top-left {
    top: 20px;
    left: 20px;
}

/* ========================================
   Loading Spinner
   ======================================== */
.wlr-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
    border-radius: var(--wlr-border-radius);
}

.wlr-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(249, 115, 22, 0.2);
    border-top-color: var(--wlr-primary);
    border-radius: 50%;
    animation: wlr-spin 0.8s linear infinite;
}

@keyframes wlr-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes wlr-pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(249, 115, 22, 0.6);
    }
}

/* ========================================
   Error Message
   ======================================== */
.wlr-error-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 999999;
    animation: wlr-slideUp 0.3s ease;
}

@keyframes wlr-slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ========================================
   Shortcode Styles
   ======================================== */
.wlr-shortcode-wrapper {
    font-family: var(--wlr-font);
    background: var(--wlr-bg);
    backdrop-filter: blur(var(--wlr-glass-blur));
    -webkit-backdrop-filter: blur(var(--wlr-glass-blur));
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--wlr-border-radius);
    box-shadow: var(--wlr-shadow);
    padding: 20px;
}

.wlr-shortcode-title {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--wlr-text);
    text-align: center;
}

.wlr-shortcode-rates {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.wlr-shortcode-card {
    flex: 1;
    min-width: 200px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(249, 250, 251, 0.95));
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.wlr-shortcode-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--wlr-text-light);
}

/* ========================================
   Widget Styles
   ======================================== */
.wlr-widget-container {
    font-family: var(--wlr-font);
}

.wlr-widget-rates {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wlr-widget-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(249, 250, 251, 0.95));
    border-radius: 12px;
    padding: 14px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.wlr-widget-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.wlr-card-gold .wlr-widget-header {
    color: #d97706;
}

.wlr-card-silver .wlr-widget-header {
    color: #6b7280;
}

.wlr-widget-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--wlr-text);
}

.wlr-widget-body {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.wlr-widget-rate {
    font-size: 18px;
    font-weight: 700;
    color: var(--wlr-text);
}

.wlr-widget-unit {
    font-size: 11px;
    color: var(--wlr-text-light);
}

.wlr-widget-change {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
}

.wlr-widget-footer {
    margin-top: 12px;
    text-align: center;
}

.wlr-widget-footer .wlr-refresh-btn {
    width: 100%;
    justify-content: center;
}

/* ========================================
   Dark Mode Support
   ======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --wlr-text: #f3f4f6;
        --wlr-text-light: #9ca3af;
    }

    .wlr-popup {
        background: rgba(31, 41, 55, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .wlr-rate-card {
        background: linear-gradient(145deg, rgba(55, 65, 81, 0.9), rgba(75, 85, 99, 0.95));
        border-color: rgba(255, 255, 255, 0.05);
    }

    .wlr-card-gold .wlr-card-icon {
        background: linear-gradient(135deg, #78350f, #92400e);
        color: #fbbf24;
    }

    .wlr-card-silver .wlr-card-icon {
        background: linear-gradient(135deg, #374151, #4b5563);
        color: #d1d5db;
    }

    .wlr-popup-footer {
        border-color: rgba(255, 255, 255, 0.1);
        background: rgba(0, 0, 0, 0.1);
    }

    .wlr-card-purity {
        background: rgba(255, 255, 255, 0.1);
    }

    .wlr-card-change.wlr-positive {
        background: rgba(16, 185, 129, 0.2);
    }

    .wlr-card-change.wlr-negative {
        background: rgba(239, 68, 68, 0.2);
    }

    .wlr-loading {
        background: rgba(31, 41, 55, 0.9);
    }

    .wlr-shortcode-wrapper,
    .wlr-widget-container {
        background: rgba(31, 41, 55, 0.95);
    }

    .wlr-shortcode-card,
    .wlr-widget-card {
        background: linear-gradient(145deg, rgba(55, 65, 81, 0.9), rgba(75, 85, 99, 0.95));
    }
}

/* ========================================
   RTL Support
   ======================================== */
[dir="rtl"] .wlr-rate-card::before {
    left: auto;
    right: 0;
    border-radius: 0 4px 4px 0;
}

[dir="rtl"] .wlr-card-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .wlr-widget-change {
    margin-left: 0;
    margin-right: auto;
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .wlr-popup,
    .wlr-close-btn,
    .wlr-rate-card,
    .wlr-refresh-btn,
    .wlr-toggle-btn,
    .wlr-spinner {
        animation: none;
        transition: none;
    }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--wlr-primary);
    outline-offset: 2px;
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .wlr-popup,
    .wlr-toggle-btn,
    .wlr-error-message {
        display: none !important;
    }
}
