/* BudgetIQ Shared Theme - Light/Dark Mode */
/* Based on Money Masters, Rolly, TradeFix, Plancana reference designs */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ===== LIGHT MODE (Default) ===== */
:root, [data-theme="light"] {
    --primary: #17C8D8;
    --primary-dark: #0EA5B7;
    --primary-light: #E0F7FA;
    --primary-gradient: linear-gradient(135deg, #17C8D8 0%, #0EA5B7 100%);
    --secondary: #7C3AED;
    --secondary-light: #EDE9FE;
    --secondary-gradient: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    --accent-green: #10B981;
    --accent-green-light: #D1FAE5;
    --accent-red: #EF4444;
    --accent-red-light: #FEE2E2;
    --accent-orange: #F59E0B;
    --accent-orange-light: #FEF3C7;
    --accent-gold: #EAB308;
    --accent-blue: #3B82F6;
    --accent-pink: #EC4899;

    --bg: #F5F7FA;
    --bg-white: #FFFFFF;
    --card: #FFFFFF;
    --card-hover: #F8FAFC;
    --card-border: #E5E7EB;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-lg: 0 4px 12px rgba(0,0,0,0.08);

    --text: #1F2937;
    --text2: #6B7280;
    --text3: #9CA3AF;
    --text-white: #FFFFFF;
    --text-on-primary: #FFFFFF;

    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --divider: #F3F4F6;

    --input-bg: #F9FAFB;
    --input-border: #D1D5DB;
    --input-focus: var(--primary);

    --header-bg: var(--primary-gradient);
    --header-text: #FFFFFF;

    --nav-bg: #FFFFFF;
    --nav-border: #E5E7EB;
    --nav-active: var(--primary);
    --nav-inactive: #9CA3AF;

    --overlay: rgba(0,0,0,0.5);
    --modal-bg: #FFFFFF;

    --profit: #10B981;
    --loss: #EF4444;

    --skeleton: #E5E7EB;
    --skeleton-shine: #F3F4F6;

    --chart-grid: #E5E7EB;
    --chart-text: #6B7280;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    --primary: #22D3EE;
    --primary-dark: #17C8D8;
    --primary-light: rgba(34,211,238,0.12);
    --primary-gradient: linear-gradient(135deg, #0EA5B7 0%, #0D9488 100%);
    --secondary: #A78BFA;
    --secondary-light: rgba(167,139,250,0.12);
    --secondary-gradient: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    --accent-green: #34D399;
    --accent-green-light: rgba(52,211,153,0.12);
    --accent-red: #F87171;
    --accent-red-light: rgba(248,113,113,0.12);
    --accent-orange: #FBBF24;
    --accent-orange-light: rgba(251,191,36,0.12);
    --accent-gold: #FBBF24;
    --accent-blue: #60A5FA;
    --accent-pink: #F472B6;

    --bg: #0F1117;
    --bg-white: #1A1D27;
    --card: #1A1D27;
    --card-hover: #22252F;
    --card-border: #2D3140;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --card-shadow-lg: 0 4px 12px rgba(0,0,0,0.4);

    --text: #F1F5F9;
    --text2: #94A3B8;
    --text3: #64748B;
    --text-white: #FFFFFF;
    --text-on-primary: #FFFFFF;

    --border: #2D3140;
    --border-light: #252836;
    --divider: #252836;

    --input-bg: #252836;
    --input-border: #3B3F51;
    --input-focus: var(--primary);

    --header-bg: linear-gradient(135deg, #0F1117 0%, #1A1D27 100%);
    --header-text: #F1F5F9;

    --nav-bg: #1A1D27;
    --nav-border: #2D3140;
    --nav-active: var(--primary);
    --nav-inactive: #64748B;

    --overlay: rgba(0,0,0,0.7);
    --modal-bg: #1A1D27;

    --profit: #34D399;
    --loss: #F87171;

    --skeleton: #252836;
    --skeleton-shine: #2D3140;

    --chart-grid: #2D3140;
    --chart-text: #94A3B8;
}

/* ===== BASE RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== SHARED HEADER ===== */
.biq-header {
    background: var(--header-bg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 50;
}

.biq-header-icon {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.18);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

[data-theme="dark"] .biq-header-icon {
    background: rgba(255,255,255,0.08);
}

.biq-header-text h1 {
    font-size: 17px;
    font-weight: 700;
    color: var(--header-text);
    line-height: 1.2;
}

.biq-header-text p {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    margin-top: 2px;
}

[data-theme="dark"] .biq-header-text p {
    color: var(--text3);
}

.biq-header-right {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Theme Toggle Button */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: var(--header-text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

[data-theme="dark"] .theme-toggle {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

.theme-toggle:active {
    transform: scale(0.9);
}

/* ===== SHARED BOTTOM NAV ===== */
.biq-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    border-top: 1px solid var(--nav-border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

[data-theme="dark"] .biq-nav {
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.biq-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--nav-inactive);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 12px;
    transition: color 0.2s;
    position: relative;
}

.biq-nav a .nav-icon {
    font-size: 20px;
    line-height: 1;
}

.biq-nav a.active {
    color: var(--nav-active);
}

.biq-nav a.active::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* ===== SHARED CARDS ===== */
.biq-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--card-shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.biq-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* ===== SHARED BUTTONS ===== */
.biq-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.biq-btn:active {
    transform: scale(0.98);
}

.biq-btn-primary {
    background: var(--primary-gradient);
    color: var(--text-on-primary);
    box-shadow: 0 2px 8px rgba(23,200,216,0.25);
}

.biq-btn-secondary {
    background: var(--secondary-gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124,58,237,0.25);
}

.biq-btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text2);
}

.biq-btn-outline:active {
    background: var(--card-hover);
}

.biq-btn-success {
    background: var(--accent-green);
    color: #fff;
}

.biq-btn-danger {
    background: var(--accent-red-light);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

.biq-btn-sm {
    padding: 8px 16px;
    font-size: 12px;
    width: auto;
    border-radius: 10px;
}

.biq-btn-pill {
    border-radius: 24px;
}

/* ===== SHARED INPUTS ===== */
.biq-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.biq-input:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(23,200,216,0.1);
}

.biq-input::placeholder {
    color: var(--text3);
}

.biq-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 01.708 0L8 8.293l2.646-2.647a.5.5 0 01.708.708l-3 3a.5.5 0 01-.708 0l-3-3a.5.5 0 010-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.biq-textarea {
    resize: vertical;
    min-height: 80px;
}

.biq-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
}

/* ===== SHARED MODAL ===== */
.biq-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.biq-modal-overlay.active {
    display: flex;
}

.biq-modal {
    background: var(--modal-bg);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

.biq-modal-center {
    border-radius: 20px;
    max-width: 500px;
    margin: auto;
    animation: scaleIn 0.2s ease;
}

.biq-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.biq-modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.biq-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-light);
    border: none;
    color: var(--text2);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== SHARED TABS ===== */
.biq-tabs {
    display: flex;
    background: var(--border-light);
    border-radius: 12px;
    padding: 3px;
    margin-bottom: 16px;
}

.biq-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 10px;
    font-family: inherit;
    transition: all 0.2s;
}

.biq-tab.active {
    background: var(--card);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="dark"] .biq-tab.active {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ===== STATS GRID ===== */
.biq-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.biq-stat {
    background: var(--bg);
    border-radius: 12px;
    padding: 12px;
}

[data-theme="dark"] .biq-stat {
    background: var(--card-hover);
}

.biq-stat-label {
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.biq-stat-value {
    font-size: 18px;
    font-weight: 800;
}

.biq-stat-value.profit { color: var(--profit); }
.biq-stat-value.loss { color: var(--loss); }

/* ===== BADGES ===== */
.biq-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.biq-badge-green { background: var(--accent-green-light); color: var(--accent-green); }
.biq-badge-red { background: var(--accent-red-light); color: var(--accent-red); }
.biq-badge-purple { background: var(--secondary-light); color: var(--secondary); }
.biq-badge-blue { background: rgba(59,130,246,0.1); color: var(--accent-blue); }
.biq-badge-orange { background: var(--accent-orange-light); color: var(--accent-orange); }

/* ===== PROGRESS BAR ===== */
.biq-progress {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}

.biq-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--primary-gradient);
    transition: width 0.5s ease;
}

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

.biq-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.biq-empty-text {
    color: var(--text2);
    font-size: 14px;
    margin-bottom: 16px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== SKELETON LOADING ===== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.biq-skeleton {
    background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-shine) 50%, var(--skeleton) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

/* ===== UTILITY ===== */
.text-profit { color: var(--profit) !important; }
.text-loss { color: var(--loss) !important; }
.text-primary { color: var(--primary) !important; }
.text-secondary { color: var(--secondary) !important; }
.text-muted { color: var(--text2) !important; }
.fw-bold { font-weight: 700 !important; }
.fw-extra { font-weight: 800 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.text-center { text-align: center !important; }

/* ===== TRANSITIONS ===== */
.biq-card, .biq-btn, .biq-input, .biq-nav, .biq-header, .biq-modal {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}
