/**
 * Advify Stars — Desktop & Website overrides
 * Loaded after app.css + app-patch.css.
 * Provides: sidebar layout, wider content, desktop hover states.
 */

/* ── Font override (Inter for website) ───────────── */
:root {
    --af-font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--af-font);
}

/* ── Site wrapper: sidebar + content ─────────────── */
.site-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.site-content {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Sidebar (hidden on mobile) ──────────────────── */
.site-sidebar {
    display: none;
}

/* ── Override: allow wider than 480px on desktop ──── */
.app-shell {
    width: 100% !important;
    max-width: 600px;
}

.app-main {
    max-width: 600px;
    margin: 0 auto;
}

#bottom-dock-root {
    width: min(100%, 600px) !important;
}

.sheet-shell {
    width: min(100%, 600px) !important;
}

/* ── Intro overlay: full width on site ───────────── */
.intro-overlay {
    z-index: 50;
}

/* ── Remove zoom prevention for desktop ──────────── */
html {
    touch-action: auto;
}

/* ── Desktop hover states ────────────────────────── */
@media (hover: hover) {
    .af-quick-card:hover,
    .af-action-card:hover,
    .af-menu-row:hover,
    .af-pay-method:hover,
    .af-transaction-card:hover,
    .af-order-card:hover {
        transform: translateY(-1px);
        box-shadow: var(--af-shadow-md);
    }

    .af-primary-btn:hover {
        transform: translateY(-1px);
        filter: brightness(1.04);
    }

    .af-secondary-btn:hover,
    .af-ghost-btn:hover {
        background: var(--af-surface-2);
    }

    .site-sidebar__link:hover {
        background: var(--af-surface-2);
    }

    .af-balance-card:hover {
        transform: translateY(-1px);
    }
}

/* ── Cursor: pointer for interactive elements ────── */
.af-quick-card,
.af-action-card,
.af-menu-row,
.af-pay-method,
.af-transaction-card,
.af-primary-btn,
.af-secondary-btn,
.site-sidebar__link {
    cursor: pointer;
}


/* ══════════════════════════════════════════════════════
   DESKTOP LAYOUT (≥ 900px)
   ══════════════════════════════════════════════════════ */
@media (min-width: 900px) {

    /* ── Sidebar visible ─────────────────────────── */
    .site-sidebar {
        display: flex;
        flex-direction: column;
        width: 260px;
        min-width: 260px;
        height: 100vh;
        position: sticky;
        top: 0;
        background: var(--af-surface);
        border-right: 1px solid var(--af-line);
        padding: 24px 16px;
        z-index: 60;
        overflow-y: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .site-sidebar::-webkit-scrollbar {
        display: none;
    }

    :root[data-theme="dark"] .site-sidebar {
        background: #111111;
        border-right-color: rgba(255,255,255,0.06);
    }

    .site-sidebar__logo {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 8px 12px 24px;
    }

    .site-sidebar__logo-icon {
        width: 40px;
        height: 40px;
        display: grid;
        place-items: center;
        border-radius: 12px;
        background: linear-gradient(135deg, rgba(247, 212, 81, 0.22), rgba(247, 212, 81, 0.08));
        font-size: 20px;
    }

    .site-sidebar__logo strong {
        font-size: 18px;
        font-weight: 800;
        letter-spacing: -0.04em;
        color: var(--af-text);
    }

    .site-sidebar__nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
        flex: 1;
    }

    .site-sidebar__link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 14px;
        border: none;
        background: transparent;
        color: var(--af-muted);
        font-size: 15px;
        font-weight: 600;
        letter-spacing: -0.01em;
        text-align: left;
        transition: background 180ms ease, color 180ms ease;
    }

    .site-sidebar__link-icon {
        width: 22px;
        height: 22px;
        display: grid;
        place-items: center;
        flex-shrink: 0;
    }

    .site-sidebar__link-icon svg {
        width: 22px;
        height: 22px;
    }

    .site-sidebar__link.is-active {
        background: rgba(247, 212, 81, 0.12);
        color: var(--af-text);
    }

    :root[data-theme="dark"] .site-sidebar__link.is-active {
        background: rgba(247, 212, 81, 0.1);
        color: var(--af-accent);
    }

    .site-sidebar__footer {
        padding: 16px 14px 0;
        border-top: 1px solid var(--af-line);
        margin-top: auto;
    }

    .site-sidebar__footer span {
        font-size: 12px;
        color: var(--af-muted);
    }

    /* ── Content area wider ──────────────────────── */
    .app-shell {
        max-width: 720px;
    }

    .app-main {
        max-width: 720px;
        padding: 0 24px;
    }

    #bottom-dock-root {
        display: none !important;
    }

    .sheet-shell {
        width: min(100%, 560px) !important;
    }

    /* ── Grids adapt ─────────────────────────────── */
    .af-quick-grid,
    .af-action-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .af-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .service-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* ── Market grid: 3 columns ──────────────────── */
    .af-market-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    /* ── Profile layout wider ────────────────────── */
    .af-profile-shell {
        max-width: 700px;
        margin: 0 auto;
    }

    /* ── Better sheet centering on desktop ────────── */
    .sheet-root.active {
        display: flex;
        align-items: flex-end;
        justify-content: center;
    }

    .sheet-root.active .sheet-backdrop {
        backdrop-filter: blur(14px);
    }

    /* ── Loading overlay within content ───────────── */
    .loading-overlay {
        position: fixed;
    }

    /* ── Intro overlay within content ─────────────── */
    .intro-overlay {
        position: fixed;
    }
}


/* ══════════════════════════════════════════════════════
   LARGE DESKTOP (≥ 1200px)
   ══════════════════════════════════════════════════════ */
@media (min-width: 1200px) {

    .site-sidebar {
        width: 280px;
        min-width: 280px;
        padding: 28px 20px;
    }

    .app-shell {
        max-width: 800px;
    }

    .app-main {
        max-width: 800px;
        padding: 0 32px;
    }

    .af-quick-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .af-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .af-action-card {
        min-height: 164px;
    }

    .af-quick-card {
        min-height: 160px;
    }

    /* ── Better typography for larger screens ─────── */
    .af-page-header__copy strong,
    .af-back-header strong {
        font-size: 28px;
    }

    .af-hero h1 {
        font-size: 26px;
    }

    .af-balance-card strong {
        font-size: 30px;
    }
}


/* ══════════════════════════════════════════════════════
   ULTRAWIDE (≥ 1600px)
   ══════════════════════════════════════════════════════ */
@media (min-width: 1600px) {

    .site-sidebar {
        width: 300px;
        min-width: 300px;
    }

    .app-shell {
        max-width: 880px;
    }

    .app-main {
        max-width: 880px;
    }
}


/* ══════════════════════════════════════════════════════
   TABLET (600px – 899px)
   ══════════════════════════════════════════════════════ */
@media (min-width: 600px) and (max-width: 899px) {

    .app-shell {
        max-width: 620px;
    }

    .app-main {
        max-width: 620px;
    }

    #bottom-dock-root {
        width: min(100%, 620px) !important;
    }

    .service-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .af-market-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}


/* ══════════════════════════════════════════════════════
   MOBILE (< 600px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 599px) {

    .site-sidebar {
        display: none !important;
    }

    .app-shell {
        max-width: 480px;
    }

    #bottom-dock-root {
        width: min(100%, 480px) !important;
    }
}


/* ══════════════════════════════════════════════════════
   TELEGRAM LOGIN SCREEN
   ══════════════════════════════════════════════════════ */

@keyframes site-login-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes site-login-card-rise {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes site-login-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

.site-login-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(247, 212, 81, 0.12), transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(247, 212, 81, 0.08), transparent 50%),
        var(--af-bg, #f5f1eb);
    animation: site-login-fade-in 400ms ease both;
    padding: 20px;
    overflow-y: auto;
}

:root[data-theme="dark"] .site-login-overlay {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(247, 212, 81, 0.06), transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(247, 212, 81, 0.04), transparent 50%),
        var(--af-bg, #080808);
}

.site-login-overlay.is-leaving {
    animation: site-login-fade-out 380ms ease forwards;
}

.site-login-card {
    width: min(100%, 420px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 48px 36px 40px;
    border-radius: 28px;
    background: var(--af-surface, #ffffff);
    border: 1px solid var(--af-line, rgba(33,29,24,0.09));
    box-shadow:
        0 24px 64px rgba(24, 18, 9, 0.08),
        0 0 0 1px rgba(247, 212, 81, 0.06);
    text-align: center;
    animation: site-login-card-rise 500ms cubic-bezier(0.22, 0.61, 0.36, 1) 100ms both;
}

:root[data-theme="dark"] .site-login-card {
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(247, 212, 81, 0.08);
}

.site-login-card__icon {
    width: 80px;
    height: 80px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(247, 212, 81, 0.2), rgba(247, 212, 81, 0.06));
    font-size: 36px;
    line-height: 1;
}

.site-login-card__title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--af-text);
}

.site-login-card__desc {
    margin: 0;
    max-width: 320px;
    font-size: 15px;
    line-height: 1.45;
    color: var(--af-muted, #7f776d);
}

.site-login-card__widget {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
}

.site-login-card__widget iframe {
    border-radius: 14px !important;
}

.site-login-card__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
}

.site-login-card__loading span {
    font-size: 14px;
    color: var(--af-muted);
}

.site-login-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid var(--af-line, rgba(33,29,24,0.09));
    border-top-color: var(--af-accent, #f7d451);
    animation: site-login-spin 700ms linear infinite;
}

.site-login-card__error {
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--af-danger-soft, rgba(255,59,48,0.14));
    color: var(--af-danger, #ff3b30);
    font-size: 14px;
    font-weight: 600;
}

.site-login-card__features {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    padding: 18px 0 4px;
    border-top: 1px solid var(--af-line, rgba(33,29,24,0.09));
}

.site-login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    text-align: left;
}

.site-login-feature__icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(247, 212, 81, 0.1);
    font-size: 16px;
    flex-shrink: 0;
}

.site-login-feature span:last-child {
    font-size: 14px;
    color: var(--af-text);
    font-weight: 500;
}

.site-login-card__footer {
    margin: 0;
    font-size: 12px;
    color: var(--af-muted, #7f776d);
    opacity: 0.7;
}

/* ── Sidebar logout button ───────────────────────── */
.site-sidebar__logout {
    margin-top: 8px;
    color: var(--af-danger, #ff3b30) !important;
    opacity: 0.7;
    transition: opacity 180ms ease;
}

.site-sidebar__logout:hover {
    opacity: 1;
    background: var(--af-danger-soft, rgba(255,59,48,0.14)) !important;
}

/* ── Login overlay hides sidebar on login screen ──── */
.site-login-overlay.is-visible ~ .site-sidebar {
    pointer-events: none;
}


/* ══════════════════════════════════════════════════════
   PRINT (hide sidebar, full width)
   ══════════════════════════════════════════════════════ */
@media print {
    .site-sidebar,
    #bottom-dock-root,
    .sheet-root,
    .toast-stack,
    .intro-overlay,
    .loading-overlay,
    .site-login-overlay {
        display: none !important;
    }

    .app-shell {
        max-width: 100%;
        padding: 0;
    }
}
