@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&family=Sora:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600&display=swap');

/* Shared stylesheet for common rules (keeps pages lightweight and consistent) */
:root {
    color-scheme: light;
    --font-body: "Manrope", "Noto Sans SC", "Noto Sans", sans-serif;
    --font-display: "Sora", "Noto Sans SC", "Noto Sans", sans-serif;
    --ui-bg: #f4f6f8;
    --ui-bg-alt: #eef1f4;
    --ui-surface: rgba(255, 255, 255, 0.88);
    --ui-surface-solid: #ffffff;
    --ui-border: rgba(31, 41, 55, 0.12);
    --ui-text: #2e3643;
    --ui-text-muted: #6b7280;
    --ui-accent: #7b8da3;
    --ui-accent-strong: #5e7084;
    --ui-shadow: 0 26px 55px rgba(15, 23, 42, 0.16);
    --ui-glow: 0 0 60px rgba(123, 141, 163, 0.2);
    --ui-highlight: rgba(123, 141, 163, 0.08);
    --ui-highlight-strong: rgba(123, 141, 163, 0.18);
    --ui-danger: #d27c7c;
    --ui-success: #2b9a6a;
    --ui-ambient-1: rgba(160, 176, 196, 0.28);
    --ui-ambient-2: rgba(186, 198, 214, 0.22);
    --theme-toggle-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='4'/><line x1='12' y1='2' x2='12' y2='5'/><line x1='12' y1='19' x2='12' y2='22'/><line x1='2' y1='12' x2='5' y2='12'/><line x1='19' y1='12' x2='22' y2='12'/><line x1='4.2' y1='4.2' x2='6.4' y2='6.4'/><line x1='17.6' y1='17.6' x2='19.8' y2='19.8'/><line x1='4.2' y1='19.8' x2='6.4' y2='17.6'/><line x1='17.6' y1='6.4' x2='19.8' y2='4.2'/></svg>");
}

html {
    --page-scale: 0.9;
    font-size: calc(100% * var(--page-scale));
}

html.home-page {
    --page-scale: 1;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --ui-bg: #1f1f20;
    --ui-bg-alt: #242426;
    --ui-surface: rgba(45, 46, 49, 0.92);
    --ui-surface-solid: #2b2d31;
    --ui-border: rgba(148, 163, 184, 0.18);
    --ui-text: #e7ebf0;
    --ui-text-muted: #9aa3ad;
    --ui-accent: #7b8fa6;
    --ui-accent-strong: #a7b6c7;
    --ui-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
    --ui-glow: 0 0 70px rgba(125, 143, 166, 0.22);
    --ui-highlight: rgba(123, 143, 166, 0.2);
    --ui-highlight-strong: rgba(123, 143, 166, 0.3);
    --ui-danger: #e09b9b;
    --ui-success: #62c896;
    --ui-ambient-1: rgba(90, 96, 108, 0.35);
    --ui-ambient-2: rgba(70, 76, 88, 0.3);
    --theme-toggle-icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'><path d='M21 12.8A8.5 8.5 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8Z'/></svg>");
}

body {
    font-family: var(--font-body);
    color: var(--ui-text);
}

.ui-controls {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 10px;
    z-index: 1200;
}

.ui-control {
    appearance: none;
    border: 1px solid var(--ui-border);
    background: var(--ui-surface);
    color: var(--ui-text);
    padding: 7px 18px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    backdrop-filter: blur(12px);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.14);
}

.ui-control:hover {
    transform: translateY(-1px);
    border-color: var(--ui-accent);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
}

.ui-control[data-theme-toggle] {
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 0;
    color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ui-control[data-theme-toggle]::before {
    content: "";
    width: 18px;
    height: 18px;
    background-color: var(--ui-text);
    -webkit-mask-image: var(--theme-toggle-icon);
    mask-image: var(--theme-toggle-icon);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.ui-control[data-theme-toggle]::after {
    content: attr(data-theme-badge);
    position: absolute;
    bottom: -5px;
    right: -6px;
    padding: 1px 6px;
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-radius: 999px;
    background: var(--ui-surface-solid);
    color: var(--ui-text);
    border: 1px solid var(--ui-border);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.ui-control[data-theme-toggle][data-theme-mode="system"]::after {
    opacity: 1;
    transform: translateY(0);
}

.card-home-link {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ui-surface-solid);
    border: 1px solid var(--ui-border);
    color: var(--ui-text-muted);
    text-decoration: none;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    z-index: 2;
}

.card-home-link:hover {
    transform: translateY(-1px);
    color: var(--ui-text);
    border-color: var(--ui-accent);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
}

.card-home-link svg {
    width: 18px;
    height: 18px;
}
.is-hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .ui-controls {
        top: 16px;
        right: 16px;
        gap: 8px;
    }

    .ui-control {
        padding: 6px 14px;
        font-size: 11px;
        letter-spacing: 0.12em;
    }

    .ui-control[data-theme-toggle] {
        width: 35px;
        height: 35px;
        padding: 0;
    }

    .ui-control[data-theme-toggle]::after {
        bottom: -4px;
        right: -5px;
        font-size: 7px;
        padding: 1px 5px;
    }
}

/* Mobile: responsive rules for better canvas usage */
@media (max-width: 480px) {
    html {
        font-size: calc(14px * var(--page-scale)); /* Naturally scale down UI elements by reducing base font size */
    }

    html, body {
        width: 100%;
        height: auto !important; /* Allow body to grow with content */
        min-height: 100vh;
        margin: 0;
        padding: 0 !important;
        overflow-x: hidden;
        overflow-y: auto !important; /* Enable scrolling on the body for mobile */
        display: block;
    }

    /* Dashboard: main content should use all available width */
    .main-content {
        padding: 4rem 1rem 1rem 1rem !important; 
        width: 100% !important;
        height: auto !important; /* Disable fixed height from desktop */
        overflow-y: visible !important; /* Let the body handle the scrolling */
        box-sizing: border-box;
        margin: 0 !important;
    }

    /* Ensure the middle navigation area is scrollable if height is limited */
    .sidebar .nav-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep the bottom profile anchored but ensure it doesn't get cut off */
    .user-profile {
        margin-top: auto;
        padding: 1rem 1.5rem;
        flex-shrink: 0;
        background: var(--ui-surface-solid); /* Keep it visible over nav scroll */
    }

    /* Small height screens adjustment */
    @media (max-height: 600px) {
        .logo-area { padding-bottom: 1rem; }
        .nav-group { margin-bottom: 1rem; }
    }

    /* Floating action buttons or inputs */
    input, .action-btn, .btn-action {
        width: 100% !important;
        font-size: 1rem; /* keep input text readable */
    }

    /* Compact variant override: avoid forcing compact buttons to full width on mobile */
    .btn-compact {
        width: auto !important;
        min-width: 96px;
    }

    /* Restore centered, card-like login/register on mobile */
    .main-wrapper {
        max-width: 360px !important;
        width: calc(100% - 32px) !important;
        margin: 3rem auto !important;
        padding: 2rem 1.5rem !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 8px;
        background: var(--ui-surface);
        min-height: auto !important;
    }

}

/* Aff Management Styles */
.aff-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.aff-stat-card {
    background: var(--ui-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}
.aff-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.aff-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--accent-color);
    opacity: 0.5;
}
.aff-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.aff-stat-value {
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text-primary);
}
.aff-invite-area {
    background: var(--ui-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}
.aff-input-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
.aff-input-group input {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--table-header-bg);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.9rem;
    outline: none;
}
.reward-description {
    background: var(--ui-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
}
.reward-description h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1.2rem;
    color: var(--text-primary);
}
.reward-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.reward-list li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
.reward-list li::before {
    content: "";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
    font-size: 1.2rem;
    top: -2px;
}


/* Token Key / Code Bubble Styles */
.token-key-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.6rem;
    background-color: var(--ui-highlight);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}
.token-key-cell:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background-color: var(--ui-surface-solid);
}
.token-key-cell .copy-icon {
    opacity: 0.5;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
.token-key-cell:hover .copy-icon {
    opacity: 1;
}

