/*
 * Dark Empires — Main shared stylesheet for all public pages.
 *
 * This file consolidates the old common stylesheets
 * (variables, base reset, header, navigation, telegram button)
 * into a single file so every public page looks consistent
 * and loads fewer CSS files.
 *
 * Pages should include this file first, then one page-specific stylesheet.
 */

/* ============================================================
   1. CSS Variables
   ============================================================ */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #10b981;
    --text: #1e293b;
    --subtext: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --bg-light: #f8fafc;
    --card-bg: #ffffff;
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.05);
    --shadow: 0 4px 12px -2px rgba(0,0,0,0.10);
    --shadow-hover: 0 6px 16px rgba(0,0,0,0.12);
    --gradient: linear-gradient(135deg, #e0e7ff, #bfdbfe);
    --success: #22c55e;
    --danger: #dc2626;
    --disabled: #d1d5db;
    --telegram: #0088cc;
    --youtube: #ff0000;
    --instagram: #c13584;
    --whatsapp: #25d366;
    --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --secondary: #34d399;
    --text: #f1f5f9;
    --subtext: #94a3b8;
    --border: #334155;
    --bg: #0f172a;
    --bg-light: #1e293b;
    --card-bg: #1e293b;
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px -2px rgba(0,0,0,0.4);
    --shadow-hover: 0 6px 16px rgba(0,0,0,0.5);
    --gradient: linear-gradient(135deg, #1e293b, #0f172a);
    --success: #4ade80;
    --danger: #f87171;
    --disabled: #475569;
}

/* ============================================================
   2. Base reset
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-overflow-scrolling: touch;
}

a  { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* ============================================================
   3. Site header
   ============================================================ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    transition: background 0.3s ease;
}
[data-theme="dark"] .site-header {
    background: rgba(30,41,59,0.98);
}

.header-back {
    font-size: 1.25rem;
    color: var(--text);
    padding: 0.25rem 0.5rem;
    transition: color 0.2s ease, transform 0.2s ease;
}
.header-back:hover { color: var(--primary); transform: translateX(-2px); }

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    transition: transform 0.25s ease;
}
.header-brand:hover { transform: scale(1.02); }

.header-logo {
    height: 42px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(99,102,241,0.25));
    transition: transform 0.3s ease;
}
.header-brand:hover .header-logo { transform: rotate(-4deg) scale(1.05); }

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    transition: transform 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Dark Mode Toggle Button */
.header-theme-toggle {
    font-size: 1.25rem;
    color: var(--text);
    padding: 0.5rem;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.header-theme-toggle:hover {
    background: rgba(0,0,0,0.05);
    transform: scale(1.1);
}
[data-theme="dark"] .header-theme-toggle:hover {
    background: rgba(255,255,255,0.1);
}
.header-theme-toggle:active { transform: scale(0.95); }

.header-cart {
    position: relative;
    font-size: 1.25rem;
    color: var(--text);
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s ease;
}
.header-cart:hover { background: rgba(0,0,0,0.05); }

/* Sign Up CTA for logged-out users */
.header-signup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(99,102,241,0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
}
.header-signup:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(99,102,241,0.35);
}

/* Wallet pill */
.header-wallet {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(22,163,74,0.12), rgba(34,197,94,0.18));
    border: 1px solid rgba(22,163,74,0.28);
    color: #15803d;
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 2px 8px rgba(22,163,74,0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    white-space: nowrap;
}
.header-wallet:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 6px 14px rgba(22,163,74,0.22);
    background: linear-gradient(135deg, rgba(22,163,74,0.18), rgba(34,197,94,0.24));
}
.header-wallet i { font-size: 0.85rem; opacity: 0.85; }
.header-wallet-amount { font-variant-numeric: tabular-nums; }
@media (max-width: 360px) {
    .header-wallet { padding: 0.35rem 0.6rem; font-size: 0.78rem; }
    .header-wallet i { display: none; }
}

.cart-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.70rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

@media (min-width: 480px) {
    .header-title { font-size: 1.75rem; }
    .header-logo  { height: 48px; }
}
@media (min-width: 768px) {
    .site-header  { padding: 1.25rem 2rem; }
    .header-title { font-size: 2rem; }
    .header-logo  { height: 52px; }
}
@media (max-width: 480px) {
    .header-logo  { height: 38px; }
    .header-brand { gap: 0.45rem; }
}
@media (max-width: 360px) {
    .site-header  { padding: 0.75rem 1rem; }
    .header-title { font-size: 1.1rem; }
    .header-logo  { height: 32px; }
}

/* Shared login CTA button */
.btn-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.25rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(99,102,241,0.4);
}
.btn-login i { font-size: 0.85rem; }

/* Auth simple-center topbar (login/register) */
.auth-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 28rem;
    padding: 0 1rem;
    margin-bottom: 1rem;
}
.auth-back    { color: #4b5563; font-size: 1.25rem; }
.auth-spacer  { display: inline-block; width: 1.5rem; }
.auth-title   { font-size: 1.125rem; font-weight: 600; color: #1f2937; text-align: center; }
.auth-topbar .auth-title { flex: 1; }

.auth-theme-toggle {
    font-size: 1.25rem;
    color: #4b5563;
    padding: 0.5rem;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-theme-toggle:hover {
    background: rgba(0,0,0,0.05);
    transform: scale(1.1);
}
[data-theme="dark"] .auth-theme-toggle {
    color: #f1f5f9;
}
[data-theme="dark"] .auth-theme-toggle:hover {
    background: rgba(255,255,255,0.1);
}
.auth-theme-toggle:active { transform: scale(0.95); }
[data-theme="dark"] .auth-title { color: #f1f5f9; }

/* ============================================================
   4. Navigation (mobile bottom + PC dropdown)
   ============================================================ */
@keyframes nav-pop      { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes menu-item-in { 0% { opacity: 0; transform: translateY(-4px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes wallet-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.35); } 50% { box-shadow: 0 0 0 6px rgba(99,102,241,0); } }

/* Mobile Bottom Nav */
.mobile-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    background: rgba(255,255,255,0.88);
    border-top: 1px solid var(--border);
    display: none;
    grid-template-columns: repeat(5, 1fr);
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    box-shadow:
        0 -6px 24px rgba(15, 23, 42, 0.08),
        0 -1px 0 rgba(255,255,255,0.8) inset;
    z-index: 1000;
    will-change: transform;
    transition: transform 0.3s ease-in-out, background 0.3s ease;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
[data-theme="dark"] .mobile-nav {
    background: rgba(30, 41, 59, 0.88);
    border-top: 1px solid rgba(51, 65, 85, 0.5);
    box-shadow:
        0 -6px 24px rgba(0, 0, 0, 0.3),
        0 -1px 0 rgba(255,255,255,0.1) inset;
}

@media only screen and (max-device-width: 1024px) {
    .mobile-nav { display: grid; }
}

.mobile-nav.slide-left  { transform: translate3d(-100%, 0, 0); }
.mobile-nav.slide-right { transform: translate3d( 100%, 0, 0); }

.nav-item {
    color: var(--subtext);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: color 0.25s ease, background 0.25s ease, transform 0.2s ease;
    padding: 0.55rem 0.25rem 0.4rem;
    position: relative;
    flex: 1;
    text-align: center;
    touch-action: manipulation;
    border-radius: 12px;
    margin: 0 0.2rem;
    -webkit-tap-highlight-color: transparent;
}
/* Top indicator bar */
.nav-item::before {
    content: '';
    position: absolute;
    top: -8px;
    width: 28px; height: 3px;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 2px;
    opacity: 0;
    transform: scaleX(0);
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 2px 8px rgba(99,102,241,0.45);
}
.nav-item:hover { color: var(--primary); background: rgba(99,102,241,0.06); }
.nav-item:active { transform: scale(0.95); }
.nav-item.active { color: var(--primary); background: rgba(99,102,241,0.08); }
.nav-item.active::before { opacity: 1; transform: scaleX(1); }
.nav-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.nav-icon {
    position: relative;
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1);
    display: inline-block;
}
.nav-item:hover .nav-icon  { transform: translateY(-3px); }
.nav-item.active .nav-icon {
    transform: scale(1.15);
    animation: nav-pop 0.35s cubic-bezier(.34,1.56,.64,1);
}

/* PC Dropdown Menu */
.menu-container {
    display: none;
    position: relative;
}
@media only screen and (min-width: 1025px) {
    .menu-container { display: block; }
}

.menu-button {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
}
.menu-button:hover { transform: scale(1.05); }
.menu-button i {
    font-size: 1.3rem;
    color: var(--text);
    transition: var(--transition);
}

.menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--card-bg);
    border-radius: 0.85rem;
    box-shadow:
        0 20px 40px -12px rgba(15,23,42,0.18),
        0 8px 16px -8px rgba(15,23,42,0.10),
        0 0 0 1px rgba(15,23,42,0.04);
    width: 260px;
    padding: 0.5rem 0;
    border: 1px solid var(--border);
    z-index: 200;
    transform-origin: top right;
}
.menu-dropdown.show {
    display: block;
    animation: scaleIn 0.22s cubic-bezier(.2,.9,.3,1);
}
.menu-dropdown.show::before {
    content: '';
    position: absolute;
    top: -6px; right: 18px;
    width: 12px; height: 12px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    transform: rotate(45deg);
    z-index: -1;
}
/* Staggered item reveal */
.menu-dropdown.show > * { animation: menu-item-in 0.28s ease-out both; }
.menu-dropdown.show > *:nth-child(1) { animation-delay: 0.03s; }
.menu-dropdown.show > *:nth-child(2) { animation-delay: 0.06s; }
.menu-dropdown.show > *:nth-child(3) { animation-delay: 0.09s; }
.menu-dropdown.show > *:nth-child(4) { animation-delay: 0.12s; }
.menu-dropdown.show > *:nth-child(5) { animation-delay: 0.15s; }
.menu-dropdown.show > *:nth-child(n+6) { animation-delay: 0.18s; }

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.menu-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0;
    width: 3px; height: 100%;
    background: var(--primary);
    transform: scaleY(0);
    transition: var(--transition);
}
.menu-item:hover {
    background: linear-gradient(90deg, rgba(99,102,241,0.09), rgba(99,102,241,0.02));
    color: var(--primary);
    padding-left: 1.5rem;
}
.menu-item:hover::before { transform: scaleY(1); }
.menu-item.active {
    color: var(--primary);
    font-weight: 600;
    background: rgba(99,102,241,0.06);
}
.menu-item.active::before { transform: scaleY(1); }
.menu-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.menu-icon {
    font-size: 1.1rem;
    margin-right: 1rem;
    color: var(--subtext);
    transition: var(--transition);
    min-width: 20px;
    text-align: center;
}
.menu-item:hover .menu-icon {
    color: var(--primary);
    transform: scale(1.15);
}

.wallet-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--gradient);
    margin: 0.3rem 0.5rem;
    color: var(--text);
    border-radius: 0.5rem;
    animation: wallet-pulse 2.8s ease-in-out infinite;
    transition: background 0.25s ease, transform 0.2s ease;
}
.wallet-item:hover {
    background: linear-gradient(135deg, #d7e0ff, #b3d4fe);
    transform: translateY(-1px);
}
.wallet-content { display: flex; align-items: center; }

.whatsapp-link {
    color: var(--whatsapp);
    font-size: 1.2rem;
    transition: var(--transition);
    margin-right: 0.5rem;
}
.whatsapp-link:hover { transform: scale(1.15); color: #20b354; }

.menu-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0.5rem 0;
}

.logout-button {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--danger);
    transition: var(--transition);
}
.logout-button:hover {
    background: linear-gradient(90deg, rgba(220,38,38,0.08), rgba(220,38,38,0.02));
    padding-left: 1.5rem;
}
.logout-button i {
    font-size: 1.2rem;
    margin-right: 0.8rem;
    color: var(--danger);
    transition: transform 0.25s ease;
}
.logout-button:hover i { transform: translateX(-2px); }

@media (max-width: 480px) {
    .nav-item { margin: 0 0.1rem; padding: 0.5rem 0.15rem 0.35rem; }
    .nav-icon { font-size: 1.3rem; }
}
@media (max-width: 360px) {
    .nav-item    { font-size: 0.65rem; margin: 0; border-radius: 8px; }
    .nav-icon    { font-size: 1.2rem; }
    .nav-item::before { width: 22px; height: 2px; }
    .wallet-item  { font-size: 0.8rem; }
    .whatsapp-link{ font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-nav,
    .nav-item, .nav-icon,
    .menu-dropdown.show,
    .menu-dropdown.show > *,
    .menu-item, .menu-icon,
    .wallet-item, .whatsapp-link,
    .logout-button, .logout-button i {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================================
   5. Floating Telegram button
   ============================================================ */
#telegramButton {
    position: fixed;
    bottom: 45px;
    right: 1px;
    z-index: 9999;
    width: 90px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    margin-bottom: 10px;
}
#telegramButton:active { cursor: grabbing; }
#telegramButton img { width: 55px; height: 55px; }

/* ============================================================
   6. Common public-page layout
   ============================================================ */
.public-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}

.public-page > header,
.public-page > .site-header,
.public-page > .auth-topbar {
    flex-shrink: 0;
}

.public-page > main,
.public-page > section,
.public-page > #root,
.public-page > .content-wrapper,
.public-page > .container {
    flex: 1 0 auto;
    width: 100%;
    min-width: 0;
}

.public-page > #root > div {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
.public-page > #root > div > .whatsapp-section { margin-top: auto; }
