/**
 * Euro IQ Trade - Interactive UX (Phase 3)
 * ==========================================
 * Skeleton loaders, keyboard navigation, and smooth transitions
 */

/* ===========================================
   SKELETON LOADERS
   =========================================== */

/* Base skeleton animation */
@keyframes skeleton-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes skeleton-shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Skeleton base styles */
.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.15),
            transparent);
    animation: skeleton-shimmer 1.5s infinite;
}

/* Skeleton text line */
.skeleton-text {
    height: 16px;
    width: 100%;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

/* Skeleton price row */
.skeleton-price-row {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

.skeleton-price-row .skeleton-label {
    height: 14px;
    width: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.skeleton-price-row .skeleton-value {
    height: 18px;
    width: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-left: auto;
}

/* Loading state for live data containers */
.tm-tab-content[data-loading="true"] .tm-price-row,
.tm-pricing-table-content-wrap[data-loading="true"] .tm-price-row {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ===========================================
   KEYBOARD NAVIGATION STYLES
   =========================================== */

/* Enhanced focus indicators */
.has-submenu>a:focus-visible,
.tm-tab-nav li:focus-visible,
.tm-question:focus-visible,
.accordion-head:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Dropdown keyboard navigation */
.tm-submenu>li>a:focus-visible {
    background-color: rgba(64, 220, 253, 0.15);
    outline: none;
    box-shadow: inset 3px 0 0 var(--color-accent);
}

/* Tab keyboard navigation */
.tm-tab-nav li[tabindex="0"]:focus-visible {
    color: var(--color-accent);
    text-shadow: 0 0 10px rgba(64, 220, 253, 0.5);
}

/* Accordion keyboard navigation */
.tm-question[role="button"]:focus-visible {
    background-color: rgba(64, 220, 253, 0.1);
    border-left-color: var(--color-accent);
}

/* ===========================================
   SMOOTH ACCORDION ANIMATIONS
   =========================================== */

/* Enhanced accordion with CSS transitions */
.tm-accordion .tm-answer {
    display: block !important;
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transition:
        max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.3s ease,
        opacity 0.3s ease;
}

.tm-accordion .tm-question.expanded+.tm-answer {
    max-height: 500px;
    padding-top: var(--space-lg);
    padding-bottom: var(--space-lg);
    opacity: 1;
}

/* Accordion icon rotation */
.tm-accordion .tm-question::after {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    transition:
        transform 0.3s ease,
        background 0.3s ease;
}

.tm-accordion .tm-question.expanded::after {
    background: rgba(64, 220, 253, 0.15);
    transform: translateY(-50%) rotate(180deg);
}

/* ===========================================
   LIVE DATA TRANSITIONS
   =========================================== */

/* Smooth price updates */
.tm-price-row label {
    transition:
        color 0.3s ease,
        text-shadow 0.3s ease;
}

/* Price change flash effect */
@keyframes price-flash-up {
    0% {
        background-color: rgba(193, 254, 133, 0.3);
    }

    100% {
        background-color: transparent;
    }
}

@keyframes price-flash-down {
    0% {
        background-color: rgba(254, 139, 133, 0.3);
    }

    100% {
        background-color: transparent;
    }
}

.tm-price-row.price-up {
    animation: price-flash-up 0.5s ease;
}

.tm-price-row.price-down {
    animation: price-flash-down 0.5s ease;
}

/* Buy/Sell button hover micro-interactions */
.btn-buy,
.btn-sell {
    position: relative;
    overflow: hidden;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-buy:hover,
.btn-sell:hover {
    transform: scale(1.05);
}

.btn-buy:active,
.btn-sell:active {
    transform: scale(0.98);
}

/* ===========================================
   TAB TRANSITION IMPROVEMENTS
   =========================================== */

/* Smooth tab content switching */
.tm-tab-content {
    opacity: 0;
    transform: translateY(10px);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
}

.tm-tab-content.active-content,
.tm-tab-content:not([hidden]) {
    opacity: 1;
    transform: translateY(0);
}

/* Tab indicator animation */
.tm-tab-nav li::after {
    transition:
        width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.3s ease;
}

/* ===========================================
   LOADING SPINNERS
   =========================================== */

/* Simple spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Centered loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 15, 26, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: inherit;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===========================================
   TOOLTIP STYLES
   =========================================== */

[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: var(--color-primary);
    color: var(--color-text-on-dark);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-dropdown);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0.2s ease;
    z-index: var(--z-tooltip);
}

[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-primary);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

[data-tooltip]:hover::before,
[data-tooltip]:focus::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
    opacity: 1;
    visibility: visible;
}