/* =============================================
   Smart TopBar v3.0 - Frontend Styles
   ============================================= */

:root {
    --stb-bg1: #0d0d2b;
    --stb-bg2: #1b1b4a;
    --stb-bg3: #2e1a6e;
    --stb-text: #ffffff;
    --stb-accent: #7c5cfc;
    --stb-link-hover: #a78bfa;
    --stb-font-size: 15px;
    --stb-bar-height: 56px;
    --stb-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
    --stb-logo-w: 32px;
    --stb-timer-duration: 4s;
}

/* ─── نوار اصلی ─── */
.stb-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--stb-bar-height);
    background: linear-gradient(135deg, var(--stb-bg1) 0%, var(--stb-bg2) 50%, var(--stb-bg3) 100%);
    z-index: 999999;
    overflow: hidden;
    will-change: transform;
    font-family: var(--stb-font-family);
}

.stb-topbar.stb-relative { position: relative; }

/* سایه */
.stb-topbar.stb-shadow {
    box-shadow: 0 4px 28px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* شیشه‌ای */
.stb-topbar.stb-glass::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    pointer-events: none;
    z-index: 1;
}

/* درخشش حاشیه پایین */
.stb-topbar.stb-glow::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--stb-accent) 20%, rgba(124, 92, 252, 0.6) 50%, var(--stb-accent) 80%, transparent 100%);
    z-index: 3;
    animation: stb-glow-pulse 3s ease-in-out infinite;
}

@keyframes stb-glow-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* درخشش متحرک */
.stb-shimmer-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.04) 45%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 55%, transparent 70%);
    background-size: 300% 100%;
    animation: stb-shimmer 6s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}

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

/* ─── کانتینر ─── */
.stb-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px;
    position: relative;
    z-index: 4;
    gap: 12px;
}

/* ─── لوگو ─── */
.stb-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.stb-logo img {
    width: var(--stb-logo-w);
    height: var(--stb-logo-w);
    object-fit: contain;
    border-radius: 6px;
    filter: drop-shadow(0 0 6px rgba(124, 92, 252, 0.3));
}

/* ─── ناحیه پیام ─── */
.stb-messages-wrapper {
    flex: 1;
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.stb-messages-slider {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── پیام ─── */
.stb-message {
    position: absolute;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--stb-text);
    font-size: var(--stb-font-size);
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 16px;
    opacity: 0;
    pointer-events: none;
    will-change: transform, opacity;
}

.stb-message.stb-active {
    opacity: 1;
    pointer-events: auto;
}

/* عکس کنار متن */
.stb-msg-img {
    width: calc(var(--stb-bar-height) - 16px);
    height: calc(var(--stb-bar-height) - 16px);
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

/* لینک */
.stb-link {
    color: var(--stb-text);
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    padding-bottom: 1px;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.stb-link:hover {
    color: var(--stb-link-hover);
    border-color: var(--stb-link-hover);
}

/* ═══ انیمیشن‌ها ═══ */

/* اسلاید نرم */
.stb-topbar[data-animation="smooth-slide"] .stb-message {
    transform: translateY(110%);
    transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
.stb-topbar[data-animation="smooth-slide"] .stb-message.stb-active { transform: translateY(0); opacity: 1; }
.stb-topbar[data-animation="smooth-slide"] .stb-message.stb-exit { transform: translateY(-110%); opacity: 0; }

/* محو لطیف */
.stb-topbar[data-animation="elegant-fade"] .stb-message {
    transform: scale(0.96);
    filter: blur(4px);
    transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), filter 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.stb-topbar[data-animation="elegant-fade"] .stb-message.stb-active { transform: scale(1); filter: blur(0); opacity: 1; }
.stb-topbar[data-animation="elegant-fade"] .stb-message.stb-exit { transform: scale(1.04); filter: blur(4px); opacity: 0; }

/* مورف */
.stb-topbar[data-animation="morph"] .stb-message {
    clip-path: inset(0 50% 0 50%);
    transform: scaleX(0.3);
    opacity: 0;
    transition: clip-path 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s ease;
}
.stb-topbar[data-animation="morph"] .stb-message.stb-active { clip-path: inset(0 0 0 0); transform: scaleX(1); opacity: 1; }
.stb-topbar[data-animation="morph"] .stb-message.stb-exit { clip-path: inset(0 50% 0 50%); transform: scaleX(0.3); opacity: 0; }

/* پرده‌ای */
.stb-topbar[data-animation="curtain"] .stb-message {
    clip-path: inset(50% 0 50% 0);
    opacity: 0;
    transition: clip-path 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.stb-topbar[data-animation="curtain"] .stb-message.stb-active { clip-path: inset(0 0 0 0); opacity: 1; }
.stb-topbar[data-animation="curtain"] .stb-message.stb-exit { clip-path: inset(50% 0 50% 0); opacity: 0; }

/* ─── نوار تایمر ─── */
.stb-timer-track {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    z-index: 5;
    overflow: hidden;
}

.stb-timer-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--stb-accent), rgba(124, 92, 252, 0.4));
    border-radius: 0 1px 1px 0;
}

.stb-timer-fill.stb-running {
    animation: stb-timer var(--stb-timer-duration) linear forwards;
}

@keyframes stb-timer {
    from { width: 0%; }
    to { width: 100%; }
}

/* ─── اسپیس‌ر ─── */
.stb-spacer { display: block; width: 100%; }

/* ─── ریسپانسیو ─── */
@media (max-width: 768px) {
    .stb-container { padding: 0 16px; gap: 8px; }
    .stb-logo { display: none; }
    .stb-msg-img { width: calc(var(--stb-bar-height) - 22px); height: calc(var(--stb-bar-height) - 22px); }
    .stb-message { font-size: calc(var(--stb-font-size) - 1px); }
}

@media (max-width: 480px) {
    .stb-msg-img { width: calc(var(--stb-bar-height) - 28px); height: calc(var(--stb-bar-height) - 28px); }
    .stb-message { font-size: calc(var(--stb-font-size) - 2px); }
}

@media (prefers-reduced-motion: reduce) {
    .stb-topbar, .stb-message, .stb-shimmer-overlay, .stb-timer-fill {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
