/* ============================================================
   RESET & BASE
   ============================================================ */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --warning-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --dark-gradient: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    --card-gradient: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;

    /* ── centralised nav heights & sidebar ── */
    --navbar-h: 64px;
    --sidebar-w: 250px;
    --bottom-nav-h: 72px;
    /* the center-btn floats 25 px above the nav box;
       body padding must clear that top edge, not the nav box edge */
    --bottom-safe: calc(var(--bottom-nav-h) + 30px);
}

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

/* ── FIX 1: html + body fill viewport, body always clears bottom nav ── */
html,
body {
    min-height: 100%;
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f7fafc;
    color: var(--text-primary);

    /* clears the floating .center-btn, not just the nav bar box */
    padding-bottom: var(--bottom-safe);
}

/* ============================================================
   LAYOUT CONTAINER  ──  Twig wrapper clearance
   ============================================================ */
/*
   Your layout wraps page content in:
       <div class="container mt-4"> … </div>
   Bootstrap's .container has zero bottom margin, so the very
   last card / button inside it has nothing between it and the
   body padding edge.  This rule adds a consistent bottom gap
   that works whether Bootstrap is loaded or not.
*/
.container.mt-4 {
    padding-bottom: 20px;
}

@media (max-width: 768px) {
    .container.mt-4 {
        /* extra gap on mobile because the floating center-btn
           visually eats into the top of the nav area */
        padding-bottom: 30px;
    }
}
.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    margin-bottom: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.card-gradient {
    background: var(--card-gradient);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

/* ── Balance card ── */
.balance-card {
    background: var(--primary-gradient);
    color: white;
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 25px;
}

.balance-card h6 {
    opacity: 0.9;
    font-size: 14px;
}

.balance-card h2 {
    font-size: 36px;
    font-weight: 700;
    margin: 10px 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-gradient-primary {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-gradient-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-gradient-success {
    background: var(--success-gradient);
    border: none;
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    font-weight: 600;
}

.btn-gradient-success:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
    color: white;
}

.btn-gradient-warning {
    background: var(--warning-gradient);
    border: none;
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    font-weight: 600;
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
/* FIX 2: use the CSS var for height so calc() elsewhere stays in sync */
.top-navbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 15px 0;
    height: var(--navbar-h);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-weight: 700;
    font-size: 24px;
}

/* ============================================================
   DESKTOP LAYOUT  ──  sidebar + main content columns
   ============================================================ */

/* push navbar to the right of the fixed sidebar */
@media (min-width: 769px) {
    .top-navbar {
        margin-left: var(--sidebar-w);
    }
}

/* .main-content is the page-body wrapper used in every interior page */
.main-content {
    padding: 20px;
}

@media (min-width: 769px) {
    .main-content {
        margin-left: var(--sidebar-w);   /* clear the fixed sidebar */
        padding-top: 20px;
    }
}

/* on mobile the sidebar is a drawer → no left margin needed */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
}

/* ============================================================
   STATS CARDS
   ============================================================ */
.stat-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 24px;
    color: white;
}

.stat-icon.primary  { background: var(--primary-gradient); }
.stat-icon.success  { background: var(--success-gradient); }
.stat-icon.warning  { background: var(--warning-gradient); }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 10px 0 5px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   PLAN CARDS
   ============================================================ */
.plan-card {
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.plan-card.featured {
    border: 2px solid #667eea;
}

.plan-header {
    background: var(--primary-gradient);
    color: white;
    padding: 25px;
    text-align: center;
}

.plan-header h3 {
    font-size: 24px;
    margin-bottom: 10px;
}

.plan-price {
    font-size: 36px;
    font-weight: 700;
}

.plan-body {
    padding: 30px;
}

.plan-feature {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plan-feature:last-child {
    border-bottom: none;
}

.plan-feature i {
    color: #48bb78;
    margin-right: 10px;
}

/* ============================================================
   TRANSACTION LIST
   ============================================================ */

/* last transaction item or "View All" button should never be
   the very last thing before the nav — give it room */
.transaction-item:last-child {
    margin-bottom: 0;
}

.transaction-item {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.transaction-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateX(5px);
}

.transaction-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
}

.transaction-icon.credit {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
}

.transaction-icon.debit {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    color: white;
}

.transaction-info h6 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.transaction-info small {
    color: var(--text-secondary);
    font-size: 12px;
}

.transaction-amount {
    text-align: right;
}

.transaction-amount .amount {
    font-size: 16px;
    font-weight: 700;
}

.transaction-amount.credit .amount { color: #48bb78; }
.transaction-amount.debit  .amount { color: #f56565; }

/* ============================================================
   BADGES
   ============================================================ */
.badge-gradient-success {
    background: var(--success-gradient);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: 600;
}

.badge-gradient-warning {
    background: var(--warning-gradient);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: 600;
}

.badge-gradient-danger {
    background: var(--secondary-gradient);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: 600;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-control {
    border-radius: 10px;
    border: 2px solid var(--border-color);
    padding: 12px 15px;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15);
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* ============================================================
   WALLET ADDRESS
   ============================================================ */
.wallet-address {
    background: var(--card-gradient);
    border: 2px dashed #667eea;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
}

.wallet-address code {
    background: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 14px;
    word-break: break-all;
}

.copy-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    transform: scale(1.05);
}

/* ============================================================
   QR CODE BOX
   ============================================================ */
.qr-box {
    text-align: center;
    padding: 25px;
    background: white;
    border-radius: 15px;
    margin: 20px 0;
}

.qr-box img {
    max-width: 250px;
    border: 3px solid #667eea;
    border-radius: 12px;
    padding: 10px;
    background: white;
}

/* ============================================================
   PROFILE AVATAR
   ============================================================ */
.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 48px;
    color: white;
    font-weight: 700;
    border: 5px solid white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   REFERRAL CARD
   ============================================================ */
.referral-card {
    background: var(--primary-gradient);
    color: white;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
}

.referral-link {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    margin: 20px 0;
}

.referral-link input {
    background: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    width: 100%;
    margin-bottom: 10px;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
    height: 8px;
    border-radius: 10px;
    background: var(--border-color);
}

.progress-bar {
    background: var(--primary-gradient);
    border-radius: 10px;
}

/* ============================================================
   BOTTOM NAVIGATION  ──  the main fix area
   ============================================================ */

/*
   FIX 3: removed "display: none" default.
   The nav is now always rendered in the DOM with its layout box.
   We hide it visually on desktop with visibility + pointer-events
   instead of display:none, which collapses the element and can
   cause reflow issues when Twig includes render asynchronously
   or when the browser paints the footer partial before the
   media-query stylesheet chunk is applied.

   On mobile (≤ 768 px) we switch back to fully visible + interactive.
*/
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 10px 0 5px;
    height: var(--bottom-nav-h);

    /* desktop-hidden state (no layout collapse) */
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bottom-nav .nav-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: relative;
    height: 100%;
}

.bottom-nav .nav-item {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.bottom-nav .nav-item.center {
    flex: 0;
    margin: 0 20px;
}

.bottom-nav .nav-item i {
    font-size: 22px;
    display: block;
    margin-bottom: 4px;
}

.bottom-nav .nav-item span {
    font-size: 11px;
    display: block;
    font-weight: 500;
}

.bottom-nav .nav-item.active { color: #667eea; }
.bottom-nav .nav-item:hover  { color: #667eea; }

/* ── floating center button ── */
.bottom-nav .center-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    position: absolute;
    top: -25px;          /* FIX 4: tighter offset so it doesn't clip */
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid white;
    transition: all 0.3s ease;
    text-decoration: none;
}

.bottom-nav .center-btn:hover {
    transform: translateX(-50%) scale(1.1);
}

/* ============================================================
   SIDEBAR
   ============================================================ */

/* ── shared base ── */
.sidebar {
    background: white;
    position: fixed;          /* pinned to left edge on desktop */
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    overflow-y: auto;
    padding: 20px 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    z-index: 1001;            /* above navbar (1000) so it stays on top */
}

/* ── header block (logo + title) ── */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px 22px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 18px;
    margin: 0;
}

/* ── menu links (works for both .nav-link and .menu-item) ── */
.sidebar .nav-link,
.sidebar .menu-item {
    display: flex;
    align-items: center;
    padding: 13px 24px;
    color: var(--text-secondary);
    border-left: 3px solid transparent;
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    gap: 12px;
}

.sidebar .nav-link i,
.sidebar .menu-item i {
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-link:hover,
.sidebar .menu-item:hover,
.sidebar .nav-link.active,
.sidebar .menu-item.active {
    color: #667eea;
    background: var(--card-gradient);
    border-left-color: #667eea;
}

/* ── sidebar footer (logout btn) ── */
.sidebar-footer {
    padding: 16px 24px 24px;
}

/* ── toggle button (hidden on desktop) ── */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-toggle:hover {
    background: var(--card-gradient);
    color: #667eea;
}

/* ── full-screen overlay (hidden by default) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ── close button inside sidebar (hidden on desktop) ── */
.sidebar-close {
    display: none;
}

/* ============================================================
   SIDEBAR  ──  mobile overrides (≤ 768 px)
   ============================================================ */
@media (max-width: 768px) {

    /* toggle button becomes visible */
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* overlay rendered but invisible until .active */
    .sidebar-overlay {
        display: block;
    }

    /* sidebar becomes a fixed off-screen drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100%;
        min-height: unset;
        padding: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    /* header gets top padding to clear status bar */
    .sidebar-header {
        padding-top: 56px;
    }

    /* open state */
    .sidebar.open {
        transform: translateX(0);
    }

    /* close button visible inside the header */
    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        background: none;
        border: none;
        font-size: 20px;
        color: var(--text-secondary);
        cursor: pointer;
        width: 34px;
        height: 34px;
        border-radius: 8px;
        transition: background 0.2s ease, color 0.2s ease;
    }

    .sidebar-close:hover {
        background: #fee2e2;
        color: #e53e3e;
    }
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert-gradient {
    border: none;
    border-radius: 12px;
    padding: 15px 20px;
}

.alert-gradient.success {
    background: linear-gradient(135deg, #48bb7815 0%, #38a16915 100%);
    color: #2f855a;
    border-left: 4px solid #48bb78;
}

.alert-gradient.warning {
    background: linear-gradient(135deg, #ed893615 0%, #dd6b2015 100%);
    color: #c05621;
    border-left: 4px solid #ed8936;
}

.alert-gradient.danger {
    background: linear-gradient(135deg, #f5656515 0%, #e53e3e15 100%);
    color: #c53030;
    border-left: 4px solid #f56565;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-custom {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table-custom thead {
    background: var(--primary-gradient);
    color: white;
}

.table-custom thead th {
    border: none;
    padding: 15px;
    font-weight: 600;
}

.table-custom tbody td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

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

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
    margin: 30px 0 20px;
}

.section-header h4 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    position: relative;
    padding-bottom: 10px;
}

.section-header h4::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 64px;
    color: var(--text-secondary);
    opacity: 0.3;
    margin-bottom: 20px;
}

.empty-state h5 {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ============================================================
   ANIMATIONS & SPINNER
   ============================================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

/* ============================================================
   RESPONSIVE  ──  mobile overrides
   ============================================================ */

/* ── 768 px and below: show bottom nav, hide sidebar ── */
@media (max-width: 768px) {

    /* explicitly re-assert the safe padding on mobile
       (some devices / bootstrap resets can clobber body padding) */
    body {
        padding-bottom: var(--bottom-safe);
    }

    /* FIX 6: single, explicit block that fully enables the bottom nav */
    .bottom-nav {
        visibility: visible;
        pointer-events: auto;
        opacity: 1;
    }
}

/* ── desktop: no bottom nav visible, drop padding back to normal ── */
@media (min-width: 769px) {
    body {
        padding-bottom: 40px;
    }
}

/* ── 576 px and below: tighten up large type ── */
@media (max-width: 576px) {
    .balance-card h2 {
        font-size: 28px;
    }

    .stat-value {
        font-size: 20px;
    }

    .plan-price {
        font-size: 28px;
    }
}