/* =========================================================
   HERSLE — DESIGN SYSTEM
   Modern dark theme with violet + gold accents
========================================================= */

:root {
    --bg: #0f0a1e;
    --bg-deep: #080515;
    --surface: #171233;
    --surface-2: #1e1845;
    --surface-3: #2a2359;

    --text: #f5f3ff;
    --text-muted: #a89dc9;
    --text-dim: #6d6491;

    --primary: #a855f7;
    --primary-bright: #c084fc;
    --primary-dark: #7c3aed;
    --primary-glow: rgba(168, 85, 247, 0.35);

    --gold: #fbbf24;
    --gold-bright: #fcd34d;
    --gold-glow: rgba(251, 191, 36, 0.3);

    --mint: #4ade80;
    --rose: #f43f5e;
    --sky: #38bdf8;

    --line: #2a2359;
    --line-soft: #211a4a;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 25px 70px rgba(0, 0, 0, 0.5);
}

/* =========================================================
   RESET
========================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    min-height: 100vh;
    background: var(--bg);
    background-image:
        radial-gradient(circle at 12% 8%, rgba(168, 85, 247, 0.18), transparent 42%),
        radial-gradient(circle at 88% 92%, rgba(251, 191, 36, 0.08), transparent 42%),
        radial-gradient(circle at 50% 50%, rgba(124, 58, 237, 0.05), transparent 65%);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* =========================================================
   HIDE THE MOBILE CHAT BUTTON ON DESKTOP — FORCED
========================================================= */

.mobile-chat-top {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.mobile-chat-top svg {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    position: sticky;
    top: 0;
    z-index: 5000;
    height: 76px;
    background: rgba(15, 10, 30, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 1280px;
    height: 100%;
    margin: 0 auto;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    box-shadow: 0 8px 24px var(--primary-glow);
    transition: transform 0.3s ease;
}

.brand-mark:hover {
    transform: rotate(-8deg) scale(1.05);
}

.brand-mark svg {
    width: 26px;
    height: 26px;
}

.brand-text {
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    background: linear-gradient(90deg, #ffffff 0%, var(--primary-bright) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =========================================================
   DESKTOP MENU
========================================================= */

.desktop-menu {
    display: flex;
    align-items: center;
    gap: 6px;
}

.desktop-link {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.desktop-link:hover {
    color: var(--text);
    background: rgba(168, 85, 247, 0.1);
}

.social-link {
    color: var(--gold) !important;
}

.social-link:hover {
    background: rgba(251, 191, 36, 0.1) !important;
}

.desktop-button {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 700;
    box-shadow: 0 8px 24px var(--primary-glow);
    transition: all 0.2s ease;
}

.desktop-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 32px var(--primary-glow);
}

/* =========================================================
   MAIN LAYOUT
========================================================= */

.main-content {
    min-height: calc(100vh - 76px);
    padding: 0 0 60px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
}

/* =========================================================
   ALERTS
========================================================= */

.messages-container {
    padding-top: 20px;
}

.alert {
    position: relative;
    padding: 14px 48px 14px 18px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    color: var(--mint);
    font-size: 0.9rem;
}

.alert-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 20px;
    color: inherit;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* =========================================================
   BUTTONS
========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    box-shadow: 0 8px 24px var(--primary-glow);
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px var(--primary-glow);
}

.btn.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

.btn.secondary:hover {
    background: rgba(168, 85, 247, 0.08);
    border-color: var(--primary);
}

.btn.gold {
    background: linear-gradient(135deg, var(--gold) 0%, #d97706 100%);
    color: #1a0f00;
    box-shadow: 0 8px 24px var(--gold-glow);
}

.btn.gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px var(--gold-glow);
}

.btn.danger {
    background: rgba(244, 63, 94, 0.15);
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.4);
}

.btn.danger:hover {
    background: rgba(244, 63, 94, 0.25);
    color: #ff6b81;
}

.btn.full {
    width: 100%;
}

.btn[disabled],
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* =========================================================
   HERO
========================================================= */

.hero {
    min-height: 600px;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 60px;
    align-items: center;
    padding: 60px 0;
}

.eyebrow {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: var(--primary-bright);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.hero h1 {
    font-size: clamp(2.6rem, 5.5vw, 4.5rem);
    line-height: 1.02;
    letter-spacing: -0.02em;
    margin: 20px 0;
    font-weight: 900;
}

.hero h1 .gradient {
    background: linear-gradient(135deg, var(--primary-bright) 0%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-copy {
    max-width: 600px;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 32px;
}

.actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

/* =========================================================
   CARDS / STATS
========================================================= */

.card,
.stat,
.product {
    background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card {
    padding: 26px;
}

.stat {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--gold) 100%);
}

.stat span {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat strong {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

/* =========================================================
   GRIDS
========================================================= */

.grid {
    display: grid;
    gap: 20px;
}

.grid.two {
    grid-template-columns: repeat(2, 1fr);
}

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

.grid.four {
    grid-template-columns: repeat(4, 1fr);
}

/* =========================================================
   PAGE HEAD
========================================================= */

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 40px 0 28px;
    flex-wrap: wrap;
}

.page-head h1 {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin: 0;
}

.page-head h2 {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0;
}

.section {
    padding: 40px 0;
}

/* =========================================================
   PRODUCTS
========================================================= */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 22px;
}

.product {
    overflow: hidden;
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.product:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 20px 50px rgba(168, 85, 247, 0.15);
}

.product-image {
    position: relative;
    aspect-ratio: 1/1;
    background: var(--surface-2);
    overflow: hidden;
    display: grid;
    place-items: center;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.product:hover .product-image img {
    transform: scale(1.06);
}

.product-image .no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 4rem;
    font-weight: 900;
}

.product-image .no-image span {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.product-body {
    padding: 22px;
}

.product-body h3 {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 12px 0;
}

.product-body p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 14px;
}

/* =========================================================
   BADGES
========================================================= */

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    background: rgba(168, 85, 247, 0.15);
    color: var(--primary-bright);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.gold {
    background: rgba(251, 191, 36, 0.15);
    color: var(--gold-bright);
}

.badge.mint {
    background: rgba(74, 222, 128, 0.15);
    color: var(--mint);
}

.badge.rose {
    background: rgba(244, 63, 94, 0.15);
    color: var(--rose);
}

.badge.level-1 {
    background: rgba(168, 85, 247, 0.2);
    color: var(--primary-bright);
}

.badge.level-2 {
    background: rgba(56, 189, 248, 0.2);
    color: var(--sky);
}

.badge.level-3 {
    background: rgba(251, 191, 36, 0.2);
    color: var(--gold-bright);
}

/* =========================================================
   TABLES
========================================================= */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
}

th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(168, 85, 247, 0.05);
}

/* =========================================================
   AUTH FORMS
========================================================= */

.auth-card {
    max-width: 480px;
    margin: 60px auto;
    padding: 40px;
    background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.auth-card label {
    display: block;
    margin-bottom: 18px;
    font-weight: 600;
    font-size: 0.9rem;
}

.auth-card input,
.search input {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 14px 16px;
    background: var(--bg-deep);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.auth-card input:focus,
.search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
}

.auth-card small {
    color: var(--rose);
    font-size: 0.82rem;
    margin-top: 6px;
    display: block;
}

/* =========================================================
   REFERRAL LINK BOX
========================================================= */

.ref-link-box {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, rgba(251, 191, 36, 0.05) 100%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.ref-link-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.ref-link-row input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    background: var(--bg-deep);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.9rem;
    outline: none;
}

.ref-code-display {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ref-code-display span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.ref-code-display strong {
    color: var(--gold);
    font-size: 1rem;
    font-family: monospace;
    letter-spacing: 0.05em;
    background: rgba(251, 191, 36, 0.1);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

/* =========================================================
   TREE MEMBERS
========================================================= */

.tree-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.tree-card {
    background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
}

.tree-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--gold) 100%);
}

.tree-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tree-card-header strong {
    font-weight: 800;
    color: var(--text);
}

.tree-card-body {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.tree-card-body div {
    display: flex;
    justify-content: space-between;
}

.tree-card-body div span:last-child {
    color: var(--text);
    font-weight: 600;
}

/* =========================================================
   MOBILE NAV (HIDDEN BY DEFAULT)
========================================================= */

.mobile-bottom-nav {
    display: none;
}

/* =========================================================
   RESPONSIVE — TABLET
========================================================= */

@media (max-width: 960px) {
    .topbar-inner,
    .container {
        padding: 0 20px;
    }

    .desktop-link {
        padding: 8px 10px;
        font-size: 0.82rem;
    }

    .hero {
        grid-template-columns: 1fr;
        gap: 40px;
        padding: 40px 0;
    }

    .grid.three,
    .grid.four {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =========================================================
   RESPONSIVE — MOBILE
========================================================= */

@media (max-width: 767px) {

    /* =====================================================
       SHOW THE CHAT BUTTON WITH FIXED SIZE
    ===================================================== */

    .mobile-chat-top {
        display: flex !important;
        visibility: visible !important;
        position: fixed !important;
        top: 14px !important;
        right: 16px !important;
        z-index: 999999 !important;
        width: 32px !important;
        height: 32px !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 10px !important;
        background: rgba(251, 191, 36, 0.15) !important;
        border: 1px solid rgba(251, 191, 36, 0.4) !important;
        color: var(--gold-bright) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        transition: all 0.25s ease !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        line-height: 1 !important;
    }

    .mobile-chat-top:hover,
    .mobile-chat-top:active {
        background: rgba(251, 191, 36, 0.25) !important;
        border-color: var(--gold) !important;
        transform: translateY(-1px);
        box-shadow: 0 6px 18px rgba(251, 191, 36, 0.25);
    }

    .mobile-chat-top svg {
        display: block !important;
        width: 16px !important;
        height: 16px !important;
        stroke: currentColor !important;
        fill: none !important;
        stroke-width: 1.7 !important;
        overflow: visible !important;
        max-width: 16px !important;
        max-height: 16px !important;
    }

    body {
        padding-bottom: 72px;
    }

    .topbar {
        height: 62px;
    }

    .topbar-inner {
        height: 62px;
        padding: 0 16px;
        justify-content: flex-start;
    }

    .desktop-menu {
        display: none;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
    }

    .brand-text {
        font-size: 1rem;
    }

    .main-content {
        padding-bottom: 20px;
    }

    .container {
        padding: 0 16px;
    }

    .hero h1 {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .hero-copy {
        font-size: 1rem;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn {
        width: 100%;
    }

    .grid.three,
    .grid.two,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }

    .product-body {
        padding: 14px;
    }

    .product-body h3 {
        font-size: 1rem;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
        padding: 24px 0 18px;
    }

    .page-head h1 {
        font-size: 1.5rem;
    }

    .auth-card {
        margin: 20px auto;
        padding: 24px 20px;
    }

    .auth-card h1 {
        font-size: 1.5rem;
    }

    .stat strong {
        font-size: 1.4rem;
    }

    /* =====================================================
       MOBILE BOTTOM NAV — 5 ITEMS
    ===================================================== */

    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999999;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        height: 68px;
        background: rgba(15, 10, 30, 0.97);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border-top: 1px solid var(--line);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-nav-link {
        flex: 1 1 20%;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 4px;
        position: relative;
        color: var(--text-dim);
        transition: color 0.2s ease, background 0.2s ease;
    }

    .mobile-nav-link:hover,
    .mobile-nav-link:active {
        color: var(--primary-bright);
        background: rgba(168, 85, 247, 0.06);
    }

    .mobile-nav-link.active {
        color: var(--primary-bright);
    }

    .mobile-nav-link.active::before {
        content: "";
        position: absolute;
        top: 0;
        left: 25%;
        right: 25%;
        height: 2px;
        background: linear-gradient(90deg, var(--primary) 0%, var(--gold) 100%);
        border-radius: 0 0 4px 4px;
    }

    .mobile-icon {
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-icon svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .mobile-label {
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        text-align: center;
    }

    .mobile-auth-nav .mobile-nav-link {
        flex: 1 1 50%;
    }

    .mobile-auth-nav .mobile-label {
        font-size: 12px;
    }
}

/* =========================================================
   SMALL PHONES
========================================================= */

@media (max-width: 380px) {
    .mobile-label {
        font-size: 9px;
    }

    .mobile-icon svg {
        width: 18px;
        height: 18px;
    }

    .mobile-chat-top {
        width: 28px !important;
        height: 28px !important;
        top: 12px !important;
        right: 12px !important;
    }

    .mobile-chat-top svg {
        width: 14px !important;
        height: 14px !important;
    }
}

/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}