/* ================================
   CSS Variables & Design Tokens
   ================================ */

:root {
    /* Colors - Background (Deep Dark Space Theme) */
    --bg-primary: #050511;
    /* Deepest black/blue */
    --bg-secondary: #0a0a1f;
    /* Slightly lighter for contrast */
    --bg-tertiary: #13132b;
    /* Card fallback */

    /* Colors - Glassmorphism (iOS Style) */
    --glass-bg: rgba(30, 30, 50, 0.45);
    /* Slightly clearer but dark */
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-highlight: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --glass-blur: blur(25px) saturate(180%);

    /* Colors - Neon Accents (Default User: Neon Blue) */
    --accent-primary: #2AC9FF;
    /* Apple-like vibrant blue */
    --accent-hover: #00B4F0;
    --accent-glow: rgba(42, 201, 255, 0.6);
    --accent-dim: rgba(42, 201, 255, 0.15);

    /* Colors - Semantic */
    --profit: #32D74B;
    /* Apple Green */
    --profit-glow: rgba(50, 215, 75, 0.4);
    --loss: #FF453A;
    /* Apple Red */
    --loss-glow: rgba(255, 69, 58, 0.4);
    --warning: #FFD60A;
    --text-primary: #FFFFFF;
    --text-secondary: #EBEBF5;
    /* iOS secondary text */
    --text-muted: #8E8E93;

    /* Typography */
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    /* Modern, geometric */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing & Radius */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    /* iOS standard large */
    --radius-xl: 28px;
    /* iOS widget corners */
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-5: 1.25rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-10: 2.5rem;

    /* Layout */
    --header-height: 80px;
    --max-width: 1440px;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-smooth: 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Theme: Admin (Neon Red) */
body.theme-admin {
    --accent-primary: #FF3B30;
    --accent-hover: #D70015;
    --accent-glow: rgba(255, 59, 48, 0.6);
    --accent-dim: rgba(255, 59, 48, 0.15);
}

/* ================================
   Base Styles
   ================================ */

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

body {
    font-family: var(--font-body);
    background-color: #000000;
    /* Profound depth gradient */
    background-image:
        radial-gradient(circle at 15% 15%, rgba(42, 201, 255, 0.12) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(88, 86, 214, 0.12) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

ul {
    list-style: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: var(--text-primary);
    /* Ensure buttons inherit white text color by default */
}

/* Icons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition-fast);
    color: var(--text-secondary);
    /* Default to light gray */
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    /* White on hover */
}

/* Explicit white color for action buttons in tables if needed */
.table .btn-icon {
    color: rgba(255, 255, 255, 0.7);
}

.table .btn-icon:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* ================================
   Glassmorphism Utilities (iOS Style)
   ================================ */

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    /* Subtle inner glow for depth */
    box-shadow:
        var(--glass-shadow),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
}

/* Shine effect on hover for interactive panels */
.glass-panel.interactive:hover {
    background: rgba(40, 40, 60, 0.55);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.glass-panel.interactive::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transform: skewX(-25deg);
    transition: 0.5s;
    pointer-events: none;
}

.glass-panel.interactive:hover::after {
    left: 150%;
}

/* ================================
   Layout
   ================================ */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    height: var(--header-height);
    background: rgba(10, 10, 20, 0.6);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    /* Heavy iOS header blur */
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: var(--max-width);
    margin: 0 auto;
    height: 100%;
    padding: 0 var(--spacing-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    /* Space between User Widget and Settings Button */
}

/* iOS App Icon Style Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 16px;
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.logo-icon-box {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-primary), #5856D6);
    border-radius: 12px;
    /* App icon shape */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--accent-glow);
    color: white;
}

.logo-icon {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.logo-text {
    background: linear-gradient(180deg, #FFFFFF 0%, #EBEBF5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.logo-img {
    height: 48px;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(42, 201, 255, 0.3));
}

/* Tab Navigation (Floating Segmented Control) */
.tab-navigation {
    display: flex;
    justify-content: center;
    padding-top: var(--spacing-4);
    background: transparent;
    z-index: 90;
}

.nav-pills {
    display: flex;
    background: rgba(118, 118, 128, 0.24);
    /* iOS Segmented Control bg */
    padding: 4px;
    border-radius: 100px;
    backdrop-filter: blur(20px);
}

.tab-btn {
    padding: 8px 20px;
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 0.5px solid rgba(255, 255, 255, 0.1);
}

/* Main Content */
.main-content {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing-10) var(--spacing-6);
    flex: 1;
}

.tab-content {
    display: none;
    animation: fadeScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tab-content.active {
    display: block;
}

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.98) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ================================
   Components
   ================================ */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: var(--transition-fast);
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--accent-primary);
    color: #000;
    box-shadow: 0 0 15px var(--accent-glow);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(255, 42, 95, 0.1);
    color: var(--loss);
    border: 1px solid rgba(255, 42, 95, 0.2);
}

.btn-danger:hover {
    background: rgba(255, 42, 95, 0.2);
    box-shadow: 0 0 15px var(--loss-glow);
}

/* Cards (iOS Style) */
.card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-6);
    margin-bottom: var(--spacing-6);
    box-shadow: var(--glass-shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-6);
}

.card-title {
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* Stat Cards (iOS Widget Style) */
.stat-card {
    background: rgba(35, 35, 50, 0.4);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    /* Rounded like App Icon/Widget */
    padding: 20px;
    /* Reduced from 24px per user request */
    min-width: 0;
    /* Prevent overflow in grid */
    position: relative;
    overflow: hidden;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    /* Square-ish aspect */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.stat-card:hover {
    transform: scale(1.02);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

/* Add gradient glow to top right of widget */
.stat-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%);
    filter: blur(20px);
    opacity: 0.5;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.stat-icon {
    font-size: 1.5rem;
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 3rem;
    /* Increased from 2.2rem */
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-top: auto;
    word-break: break-word;
    /* Prevent overflow for long values */
}

.stat-value.profit {
    color: var(--profit);
    text-shadow: 0 4px 20px rgba(50, 215, 75, 0.25);
}

.stat-value.loss {
    color: var(--loss);
    text-shadow: 0 4px 20px rgba(255, 69, 58, 0.25);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    font-size: 1rem;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 4px var(--accent-dim);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: var(--spacing-3);
    justify-content: flex-end;
    margin-top: var(--spacing-6);
}

@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
        gap: var(--spacing-3);
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-size: 0.95rem;
}

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

.table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Grid System */
.grid {
    display: grid;
    gap: 24px;
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
    /* Increased from 24px per user request */
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
}

.mb-8 {
    margin-bottom: 32px;
}

.mb-6 {
    margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
        /* Collapse to 2 columns */
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .nav-pills {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 8px 16px;
        white-space: nowrap;
    }

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
        /* Stack all grids on mobile */
    }

    .stat-value {
        font-size: 2.5rem;
        /* Increased from 2rem for mobile */
    }
}

/* Utilities */
.text-profit {
    color: var(--profit);
}

.text-loss {
    color: var(--loss);
}

.text-accent {
    color: var(--accent-primary);
}




/* ================================
   User Profile Widget (Themed)
   ================================ */
.user-profile {
    position: relative;
    /* margin-right: 16px; - Removed to rely on .header-actions gap: 16px for cleaner alignment */
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-profile-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #5856D6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.user-name {
    font-size: 14px;
    /* Standard readable size */
    font-weight: 600;
    line-height: 1.2;
}

.credit-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Increased from 4px */
    background: rgba(50, 215, 75, 0.15);
    /* Profit green tint */
    color: var(--profit);
    padding: 2px 8px;
    /* Slightly more padding */
    border-radius: 6px;
    font-size: 11px;
    /* Slightly larger than 0.7rem */
    font-weight: 700;
}

.credit-refresh-btn {
    color: var(--profit);
    cursor: pointer;
    opacity: 0.8;
    transition: 0.2s;
    margin-left: 2px;
    /* Extra space */
}

.credit-refresh-btn:hover {
    opacity: 1;
    transform: rotate(180deg);
}

.credit-refresh-btn.spinning {
    animation: spin 0.8s linear infinite;
}

/* Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 260px;
    background: rgba(20, 20, 35, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
}

.user-info-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 4px;
}

.user-info-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* ================================
   Sub-Tabs (Reusable Glassmorphism)
   ================================ */
.sub-nav-container {
    display: inline-flex;
    gap: 12px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    backdrop-filter: blur(10px);
    margin: 24px 0;
}

.sub-nav-btn {
    background: transparent;
    border: none;
    padding: 8px 24px;
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sub-nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.sub-nav-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

/* Legacy Learning Tabs (can be refactored to use above later) */
.learning-nav .sub-tab-btn {
    background: transparent;
    border: none;
    padding: 8px 24px;
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.learning-nav .sub-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.learning-nav .sub-tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 20px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    margin-top: 40px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}