/* ============================================
   LIVE PRICE REFRESH UI STYLES
   ============================================ */

/* Refresh Button */
.refresh-prices-btn {
    display: inline-flex;
    /* Visible for all users */
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    vertical-align: middle;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
    font-size: 13px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
}

/* Hide button in aside/sidebar sections */
.refresh-prices-btn[data-location="aside"] {
    display: none !important;
}

[dir="ltr"] .refresh-prices-btn {
    margin-left: 12px;
}

[dir="rtl"] .refresh-prices-btn {
    margin-right: 12px;
    font-family: 'Tajawal', sans-serif;
}

.refresh-prices-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    transform: translateY(-1px);
}

.refresh-prices-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}

.refresh-prices-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
}

.refresh-icon {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2.5;
    fill: none;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.refresh-btn-text {
    line-height: 1;
}

/* Checkmark icon - hidden by default */
.refresh-check-icon {
    width: 16px;
    height: 16px;
    stroke: white;
    stroke-width: 2.5;
    fill: none;
    flex-shrink: 0;
    display: none;
}

/* Success text - hidden by default */
.refresh-success-text {
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    display: none;
}

/* Loading state - rotating icon */
.refresh-prices-btn.loading .refresh-icon {
    animation: rotate 1s linear infinite;
}

/* Success state - defined later to take priority over cooldown if both are present */

@keyframes checkmark-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Cooldown state */
.refresh-prices-btn.cooldown {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
}

/* Success state - takes priority over cooldown */
.refresh-prices-btn.success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%) !important;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.refresh-prices-btn.success .refresh-icon,
.refresh-prices-btn.success .refresh-btn-text {
    display: none;
}

.refresh-prices-btn.success .refresh-check-icon,
.refresh-prices-btn.success .refresh-success-text {
    display: block;
}

.refresh-prices-btn.success .refresh-check-icon {
    animation: checkmark-pop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes cooldown-progress {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(100%);
    }
}

/* Tooltip */
.refresh-prices-btn[data-tooltip] {
    position: relative;
}

.refresh-prices-btn[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
}

.refresh-prices-btn[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%) scale(0);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 1000;
}

.refresh-prices-btn:hover[data-tooltip]::before,
.refresh-prices-btn:hover[data-tooltip]::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ============================================
   SKELETON OVERLAY
   ============================================ */

.price-skeleton-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.95) 0%,
            rgba(240, 240, 240, 0.95) 20%,
            rgba(255, 255, 255, 0.95) 40%,
            rgba(255, 255, 255, 0.95) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: inherit;
    z-index: 10;
    display: none;
    pointer-events: none;
}

.price-skeleton-overlay.active {
    display: block;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Make price cards position relative for overlay */
.country-card,
.detail-card,
.sidebar-card {
    position: relative;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================*/
/* Toast Container */
.toast-container {
    position: fixed;
    top: 30px;
    right: 20px;
    z-index: 1000000;
    /* High z-index to appear above header */
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

[dir="ltr"] .toast-container {
    top: 20px;
    right: 20px;
}

[dir="rtl"] .toast-container {
    top: 20px;
    left: 20px;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    animation: slideIn 0.3s ease;
    border-left: 4px solid #22c55e;
}

[dir="rtl"] .toast {
    animation: slideInRTL 0.3s ease;
    border-left: none;
    border-right: 4px solid #22c55e;
    font-family: 'Tajawal', sans-serif;
}

.toast.error {
    border-left-color: #ef4444;
}

[dir="rtl"] .toast.error {
    border-right-color: #ef4444;
}

.toast.success {
    border-left-color: #22c55e;
}

[dir="rtl"] .toast.success {
    border-right-color: #22c55e;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

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

@keyframes slideInRTL {
    from {
        transform: translateX(-400px);
        opacity: 0;
    }

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

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

[dir="rtl"] .toast.hiding {
    animation: slideOutRTL 0.3s ease forwards;
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes slideOutRTL {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(-400px);
        opacity: 0;
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-icon.success {
    color: #22c55e;
}

.toast-icon.error {
    color: #ef4444;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
}

.toast-close {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #1f2937;
}

/* ============================================
   PRICE UPDATE ANIMATIONS
   ============================================ */

.price-updating {
    animation: priceFlash 0.6s ease;
}

@keyframes priceFlash {

    0%,
    100% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(34, 197, 94, 0.2);
    }
}

.country-card-price,
.detail-card-price,
.sidebar-card-price {
    transition: all 0.3s ease;
}

/* ============================================
   ONBOARDING WALKTHROUGH TOOLTIP
   ============================================ */

.refresh-walkthrough {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    min-width: 280px;
    max-width: 320px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.refresh-walkthrough.show {
    opacity: 1;
    pointer-events: all;
    animation: walkthroughSlideIn 0.4s ease-out;
}

@keyframes walkthroughSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.refresh-walkthrough::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #1e293b;
}

.refresh-walkthrough-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.refresh-walkthrough-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-walkthrough-icon {
    width: 20px;
    height: 20px;
    color: #22c55e;
}

.refresh-walkthrough-text {
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    color: #cbd5e1;
}

.refresh-walkthrough-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.refresh-walkthrough-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-walkthrough-btn.primary {
    background: #22c55e;
    color: white;
}

.refresh-walkthrough-btn.primary:hover {
    background: #16a34a;
    transform: translateY(-1px);
}

.refresh-walkthrough-btn.secondary {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #334155;
}

.refresh-walkthrough-btn.secondary:hover {
    background: #1e293b;
    color: white;
}

/* RTL Support */
[dir="rtl"] .refresh-walkthrough {
    left: 0;
    right: auto;
    transform: none;
    font-family: 'Tajawal', sans-serif;
}

[dir="rtl"] .refresh-walkthrough.show {
    animation: walkthroughSlideInRTL 0.4s ease-out;
}

@keyframes walkthroughSlideInRTL {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

[dir="rtl"] .refresh-walkthrough::before {
    left: 32px;
    right: auto;
    transform: translateX(-50%);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .refresh-prices-btn {
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px;
    }

    .refresh-icon {
        width: 14px;
        height: 14px;
    }

    /* Mobile adjustments for walkthrough */
    .refresh-walkthrough {
        min-width: 260px;
        max-width: 280px;
        /* Fixed width to prevent overflow */
        width: 280px;
        padding: 14px 16px;
        /* Center on screen for mobile, overriding relative parent centering */
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin-top: 0;
        z-index: 100000;
        /* Super high z-index */
    }

    /* Hide the arrow on mobile since we are centering on screen (modal-like) */
    .refresh-walkthrough::before {
        display: none;
    }

    /* Add a backdrop maybe? Or just keep it simple as a modal-like popup */
    /* Let's keep it simple. User said "side somehow".
       If we want it to point to button, we need JS to calculate position.
       But simplified approach: fixed position bottom or center is safer on mobile.
       The user said "moved to the side somehow".
       Let's try to keep it anchored but shift it if near edge. 
       Actually, `left: auto; right: 0; transform: none;` might work for RTL/LTR edge cases.
    */

    /* Reverting to anchored but shifted logic */
    .refresh-walkthrough {
        position: absolute;
        width: 280px;
        max-width: 90vw;
        top: calc(100% + 15px);
        transform: none;
        /* Remove centering transform */
        margin-top: 0;
        z-index: 10001;
    }

    /* LTR: Button on right, align tooltip right edge with button */
    [dir="ltr"] .refresh-walkthrough {
        left: auto;
        right: 0;
        transform: none;
    }

    [dir="ltr"] .refresh-walkthrough::before {
        left: auto;
        right: 35px;
        transform: translateX(50%);
    }

    /* RTL: Button on left, align tooltip left edge with button */
    [dir="rtl"] .refresh-walkthrough {
        right: auto;
        left: 0;
        transform: none;
    }

    [dir="rtl"] .refresh-walkthrough::before {
        right: auto;
        left: 35px;
        transform: translateX(-50%);
    }

    /* Adjust arrow to point to button */
    .refresh-walkthrough::before {
        display: block;
        /* Default positions handled in direction blocks above */
    }

    /* On very small screens, just center it relative to button */
    @media (max-width: 360px) {
        .refresh-walkthrough {
            width: 250px;
        }
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    .price-skeleton-overlay {
        background: linear-gradient(90deg,
                rgba(30, 30, 30, 0.95) 0%,
                rgba(50, 50, 50, 0.95) 20%,
                rgba(30, 30, 30, 0.95) 40%,
                rgba(30, 30, 30, 0.95) 100%);
    }
}

/* ============================================
   PRICE DIFFERENCE INDICATOR
   ============================================ */
.price-difference {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8em;
    /* Slightly smaller than price */
    font-weight: 700;
    margin-inline-end: 10px;
    /* Space between difference and price */
    margin-inline-start: 0;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0;
    transform: translateY(10px);
    animation: slideUpFadeIn 0.5s ease forwards;
    vertical-align: middle;
    /* Ensure it floats properly or stays inline */
    position: relative;
    white-space: nowrap;
    direction: ltr;
    /* Force LTR for numbers to keep decimal on right side */
}

/* Position handling */
/* Assuming price container is relative or flexible */
/* We might need to adjust parent container styles via JS or here if known */
.country-card-price-value,
.detail-card-price-value,
.sidebar-card-price-value {
    position: relative;
    /* Ensure parent is relative for absolute positioning */
    display: inline-block;
}

/* Specific colors */
.price-difference.up {
    color: #22c55e;
    /* Green */
    background-color: rgba(34, 197, 94, 0.1);
}

.price-difference.down {
    color: #ef4444;
    /* Red */
    background-color: rgba(239, 68, 68, 0.1);
}

/* Animations */
@keyframes slideUpFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.price-difference.fade-out {
    animation: fadeOut 0.5s ease forwards;
    overflow: hidden;
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        max-width: 100px;
        margin-inline-end: 10px;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        max-width: 0;
        margin-inline-end: 0;
        padding: 2px 0;
        transform: scale(0.9);
    }
}

/* Pulse Animation for Attention */
@keyframes btnPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.refresh-prices-btn.pulse {
    animation: btnPulse 2s infinite;
}

.refresh-walkthrough-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

[dir="rtl"] .refresh-walkthrough-close {
    right: auto;
    left: 8px;
}

.refresh-walkthrough-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.refresh-walkthrough-actions {
    margin-top: 8px;
}

.country-card-price,
.detail-card-price,
.sidebar-card-price {
    display: inline-block;
    /* Ensure it behaves well with neighbor */
    vertical-align: middle;
}

/* ============================================
   PRICE IN WORDS STYLES
   ============================================ */

.price-in-words {
    font-size: 0.9rem;
    color: #4b5563;
    /* Slightly darker than muted for better visibility */
    margin-top: 8px;
    font-weight: 500;
    line-height: 1.4;
    font-family: 'Tajawal', sans-serif;
    min-height: 1.4em;
    /* Prevent layout shift */
}

/* Specific adjustments for Country Card to fit tighter space */
.country-card .price-in-words {
    font-size: 0.8rem;
    margin-top: 0;
    color: #6b7280;
    border-top: none;
    padding-top: 0;
    width: 100%;
}

/* Arabic specific font adjustment */
[dir="rtl"] .price-in-words {
    font-family: 'Tajawal', sans-serif;
}