/* === MOBILE RESPONSIVENESS ENHANCEMENTS ===
   Enhances existing mobile rules in style.css (@768px)
   IMPORTANT: Only affects screens <= 768px
*/

@media (max-width: 768px) {

    /* ========== FIX: TABS NAVIGATION ========== */
    /* Icon-only tabs on mobile - no horizontal scroll */
    .tabs-nav {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow: hidden !important;
        gap: 0 !important;
        padding: 0 !important;
        background: rgba(10, 10, 20, 0.98) !important;
        border-top: 1px solid rgba(0, 255, 157, 0.3) !important;
        backdrop-filter: blur(20px) !important;
        justify-content: space-around !important;
        /* Safe area for iPhone notch */
        padding-bottom: env(safe-area-inset-bottom, 0) !important;
    }

    .tab-btn {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 10px 4px 8px 4px !important;
        font-size: 0.6rem !important;
        text-align: center !important;
        border-radius: 0 !important;
        border: none !important;
        background: transparent !important;
        color: rgba(255, 255, 255, 0.5) !important;
        transition: all 0.2s ease !important;
        gap: 2px !important;
    }

    .tab-icon {
        font-size: 1.3rem !important;
        line-height: 1 !important;
    }

    .tab-text {
        font-size: 0.55rem !important;
        font-weight: 500 !important;
        letter-spacing: 0.3px !important;
    }

    .tab-btn.active {
        background: linear-gradient(180deg, rgba(0, 255, 157, 0.15), transparent) !important;
        color: #00ff9d !important;
        font-weight: 700 !important;
    }

    .tab-btn.active .tab-icon {
        transform: scale(1.1) !important;
    }

    .tab-btn.active .tab-text {
        color: #00ff9d !important;
    }

    /* ========== FIX: DASHBOARD CONTENT AREA ========== */
    .dashboard {
        padding: 12px 12px 85px 12px !important;
        overflow-y: auto !important;
        height: 100vh !important;
        height: 100dvh !important;
    }

    /* ========== FIX: APP CONTAINER ========== */
    .app-container {
        display: flex !important;
        flex-direction: column !important;
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden !important;
    }

    /* ========== FIX: SIDEBAR COMPLETELY HIDDEN ========== */
    .sidebar {
        display: none !important;
    }

    /* ========== FIX: TAB CONTENT - PREVENT CLIPPING ========== */
    .tab-content {
        overflow: visible !important;
        overflow-y: auto !important;
        padding-top: 0 !important;
    }

    .tab-content.active {
        display: flex !important;
        flex-direction: column !important;
    }

    /* ========== FIX: HUD HEADER ========== */
    .hud {
        flex-direction: column !important;
        gap: 6px !important;
        padding: 12px !important;
        font-size: 0.8rem !important;
        margin-bottom: 12px !important;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
        flex-shrink: 0 !important;
    }

    .hud .separator {
        display: none !important;
    }

    .hud-title {
        font-size: 0.85rem !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        line-height: 1.3 !important;
    }

    /* ========== COMMAND CENTER TAB ========== */
    .networth-hero {
        padding: 20px 16px !important;
        margin-bottom: 16px !important;
    }

    .networth-value {
        font-size: 1.8rem !important;
    }

    .networth-breakdown {
        font-size: 0.75rem !important;
    }

    .automation-dashboard {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .auto-card {
        width: 100% !important;
    }

    .command-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .command-card {
        padding: 14px !important;
    }

    .card-value {
        font-size: 1.3rem !important;
    }

    /* Goals & Flow Split */
    .dashboard-split-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }

    .goals-section,
    .flow-section {
        width: 100% !important;
    }

    .goals-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .next-actions {
        padding: 12px !important;
    }

    /* ========== FINTECH TAB ========== */
    .fintech-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .fintech-card {
        padding: 16px !important;
    }

    /* ========== DEBT TAB ========== */
    .debt-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .debt-card {
        padding: 14px !important;
    }

    .debt-amount {
        font-size: 1.5rem !important;
    }

    /* ========== BOT TAB - TRADING TERMINAL ========== */
    .terminal-header {
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important;
        padding: 10px !important;
    }

    .trading-display {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .orderbook-panel,
    .metrics-panel,
    .signals-panel {
        width: 100% !important;
    }

    .price-ticker {
        padding: 14px !important;
    }

    .ticker-price,
    #price-display {
        font-size: 1.5rem !important;
    }

    .orderbook {
        padding: 10px !important;
    }

    .ob-current {
        padding: 10px !important;
        font-size: 0.9rem !important;
    }

    .metric-group {
        padding: 12px !important;
    }

    .metric-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .metric-hero {
        padding: 18px !important;
    }

    .hero-value {
        font-size: 1.6rem !important;
    }

    .profit-display {
        flex-direction: column !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .profit-value {
        font-size: 1.3rem !important;
    }

    .loops-display {
        flex-direction: column !important;
        align-items: center !important;
        gap: 6px !important;
    }

    .loop-number {
        font-size: 1.5rem !important;
    }

    .signal-gauge {
        padding: 18px !important;
    }

    .gauge-value {
        font-size: 2rem !important;
    }

    .indicators-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }

    .indicator {
        padding: 8px 4px !important;
    }

    .ind-label {
        font-size: 0.55rem !important;
    }

    .ind-value {
        font-size: 0.75rem !important;
    }

    /* Inventory & Transaction Panels */
    .inventory-panel,
    .transaction-log-panel {
        margin-top: 12px !important;
        padding: 10px !important;
    }

    .table-responsive {
        max-height: 150px !important;
    }

    /* ========== PORTFOLIO TAB ========== */
    .portfolio-header {
        flex-direction: column !important;
        gap: 10px !important;
        padding: 14px !important;
        text-align: center !important;
    }

    .portfolio-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .portfolio-card {
        padding: 14px !important;
    }

    .allocation {
        font-size: 1.5rem !important;
    }

    /* ========== DOCTRINE TAB ========== */
    .doctrine-section {
        padding: 14px !important;
    }

    .rules-grid {
        grid-template-columns: 1fr !important;
    }

    .phases-timeline {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .phase {
        min-width: unset !important;
        padding: 14px !important;
    }

    /* ========== FLOW MANAGER ========== */
    .flow-manager {
        padding: 12px !important;
    }

    .flow-health-container {
        margin-bottom: 12px !important;
    }

    .flow-health-bar {
        height: 14px !important;
    }

    .flow-legend {
        flex-wrap: wrap !important;
        gap: 6px !important;
        font-size: 0.65rem !important;
        justify-content: center !important;
    }

    .flow-section-group {
        padding: 10px !important;
        margin-bottom: 10px !important;
    }

    .group-header {
        font-size: 0.85rem !important;
    }

    .flow-summary-grid {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .add-flow-row {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .add-input-name,
    .add-input-amount {
        flex: 1 1 40% !important;
        min-width: 80px !important;
        padding: 8px !important;
        font-size: 0.85rem !important;
    }

    .btn-add-flow {
        flex: 0 0 40px !important;
    }

    /* ========== PROJECTIONS ========== */
    .proj-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .proj-item {
        padding: 10px !important;
    }
}

/* ========== EXTRA SMALL SCREENS ========== */
@media (max-width: 400px) {

    .tabs-nav {
        overflow-x: scroll !important;
    }

    .tab-btn {
        min-width: 60px !important;
        padding: 12px 6px !important;
        font-size: 0.55rem !important;
    }

    .networth-value {
        font-size: 1.5rem !important;
    }

    .card-value {
        font-size: 1.1rem !important;
    }

    .ticker-price,
    #price-display {
        font-size: 1.2rem !important;
    }

    .hero-value {
        font-size: 1.4rem !important;
    }

    .gauge-value {
        font-size: 1.6rem !important;
    }

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

    .metric-grid {
        grid-template-columns: 1fr !important;
    }
}

/* === DOCTRINE ELITE STYLES (Global) === */
.rule-card.gold {
    border-color: #ffd700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.15);
}

.rule-card.gold .rule-text {
    color: #ffe066;
}

.rule-card.neon {
    border-color: var(--neon-blue);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(189, 0, 255, 0.05) 100%);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.2);
}

.rule-card.stealth {
    border-color: #444;
    background: rgba(20, 20, 20, 0.8);
    color: #aaa;
}

.rule-card.stealth .rule-icon {
    opacity: 0.7;
}

.phase.highlight {
    border: 1px solid var(--neon-purple);
    background: linear-gradient(135deg, rgba(189, 0, 255, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
    box-shadow: 0 0 20px rgba(189, 0, 255, 0.1);
}

.phase-config ul {
    list-style: none;
    padding-left: 0;
    margin-top: 8px;
}

.phase-config li {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    padding-left: 12px;
    position: relative;
}

.phase-config li::before {
    content: '•';
    color: var(--neon-green);
    position: absolute;
    left: 0;
}

/* ═══════════════════════════════════════════════════════════════
   🛡️ SPIRIT THEME SYSTEM - Dynamic Bot Theming
   ═══════════════════════════════════════════════════════════════ */

/* === SPIRIT THEME VARIABLES === */
:root {
    --spirit-primary: #ff6b00;
    --spirit-secondary: #ffd700;
    --spirit-glow: rgba(255, 107, 0, 0.3);
    --spirit-gradient: linear-gradient(135deg, #ff6b00, #ffd700);
}

[data-spirit="ignis"] {
    --spirit-primary: #ff6b00;
    --spirit-secondary: #ffd700;
    --spirit-glow: rgba(255, 107, 0, 0.4);
    --spirit-gradient: linear-gradient(135deg, #ff6b00, #ffd700);
}

[data-spirit="ventus"] {
    --spirit-primary: #9945ff;
    --spirit-secondary: #14F195;
    --spirit-glow: rgba(153, 69, 255, 0.4);
    --spirit-gradient: linear-gradient(135deg, #9945ff, #14F195);
}

[data-spirit="fang"] {
    --spirit-primary: #00ff9d;
    --spirit-secondary: #ffd700;
    --spirit-glow: rgba(0, 255, 157, 0.4);
    --spirit-gradient: linear-gradient(135deg, #00ff9d, #ffd700);
}

/* === SPIRIT BACKGROUND WATERMARK (Subtle) === */
.spirit-watermark {
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    height: 350px;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.spirit-watermark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.08;
    filter: grayscale(30%) brightness(1.2);
    transition: all 0.5s ease;
    transform: translateX(20%) translateY(-10%);
}

[data-spirit="ignis"] .spirit-watermark img {
    filter: grayscale(0%) brightness(1.2) sepia(30%) hue-rotate(-10deg);
    opacity: 0.12;
}

[data-spirit="ventus"] .spirit-watermark img {
    filter: grayscale(0%) brightness(1.3) hue-rotate(220deg);
    opacity: 0.10;
}

[data-spirit="fang"] .spirit-watermark img {
    filter: grayscale(0%) brightness(1.2) hue-rotate(100deg);
    opacity: 0.10;
}

/* === SPIRIT BADGE (Next to Trading Pair) === */
.spirit-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 8px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 1px;
    border-radius: 4px;
    background: var(--spirit-gradient);
    color: #000;
    vertical-align: middle;
}

/* === TERMINAL HEADER WRAPPER (Fixes layout) === */
.terminal-header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: 15px;
    gap: 20px;
}

.terminal-header-wrapper .terminal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* === COMPACT SPIRIT SELECTOR (Orbs) === */
.spirit-selector-compact {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.spirit-orb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.spirit-orb:hover {
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.spirit-orb.active {
    border-color: var(--spirit-primary);
    box-shadow: 0 0 15px var(--spirit-glow), inset 0 0 10px var(--spirit-glow);
    transform: scale(1.15);
}

.spirit-orb[data-spirit="ignis"].active {
    border-color: #ff6b00;
    box-shadow: 0 0 15px rgba(255, 107, 0, 0.6), inset 0 0 10px rgba(255, 107, 0, 0.3);
}

.spirit-orb[data-spirit="ventus"].active {
    border-color: #9945ff;
    box-shadow: 0 0 15px rgba(153, 69, 255, 0.6), inset 0 0 10px rgba(153, 69, 255, 0.3);
}

.spirit-orb[data-spirit="fang"].active {
    border-color: #00ff9d;
    box-shadow: 0 0 15px rgba(0, 255, 157, 0.6), inset 0 0 10px rgba(0, 255, 157, 0.3);
}

/* === DYNAMIC THEME APPLICATION TO BOT ELEMENTS === */
[data-spirit] .terminal-header {
    border-bottom-color: var(--spirit-primary);
    box-shadow: 0 2px 20px var(--spirit-glow);
}

[data-spirit] .profit-value.positive {
    color: var(--spirit-primary) !important;
}

[data-spirit] .metric-hero {
    border: 1px solid var(--spirit-glow);
    box-shadow: 0 0 25px var(--spirit-glow);
}

[data-spirit] .hero-value {
    color: var(--spirit-primary);
}

[data-spirit] .ob-depth.buy {
    background: linear-gradient(90deg, var(--spirit-primary), transparent);
}

[data-spirit] .gauge-value {
    color: var(--spirit-primary);
}

[data-spirit] .signal-gauge {
    border-color: var(--spirit-glow);
}

[data-spirit] .profit-chart-panel {
    border-color: var(--spirit-glow) !important;
}

/* === MOBILE RESPONSIVE SPIRIT HERO === */
@media (max-width: 768px) {
    .spirit-hero {
        height: 220px;
        border-radius: 12px;
        margin-bottom: 15px;
    }

    .spirit-selector {
        gap: 6px;
        flex-wrap: wrap;
    }

    .spirit-btn {
        padding: 8px 14px;
        font-size: 0.75rem;
        border-radius: 20px;
    }

    .spirit-name {
        font-size: 1.8rem;
        letter-spacing: 2px;
    }

    .spirit-type {
        font-size: 0.8rem;
        letter-spacing: 1px;
    }

    .spirit-quote {
        font-size: 0.7rem;
        display: none;
    }

    .spirit-info {
        padding: 15px;
    }
}

/* === HERO STATS ROW (PROTAGONISTS) === */
.hero-stats-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    margin-top: -10px;
    /* Pull up */
}

.hero-card {
    background: rgba(16, 20, 30, 0.6);
    border-radius: 12px;
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    min-height: 100px;
}

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

.hero-card .hero-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    opacity: 0.3;
}

.hero-label {
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #888;
    margin-bottom: 5px;
}

.hero-val {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* THEMES */
.hero-gold {
    border: 1px solid rgba(255, 215, 0, 0.2);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.05);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.05) 0%, rgba(10, 10, 10, 0.8) 100%);
}

.hero-gold .hero-val {
    color: var(--gold-primary);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.hero-gold:hover {
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.4);
}

.hero-emerald {
    border: 1px solid rgba(0, 255, 157, 0.25);
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.1);
    background: linear-gradient(135deg, rgba(0, 255, 157, 0.05) 0%, rgba(10, 10, 10, 0.8) 100%);
    transform: scale(1.02);
    z-index: 2;
}

.hero-emerald .hero-val {
    color: var(--emerald-life);
    text-shadow: 0 0 20px rgba(0, 255, 157, 0.4);
}

.hero-emerald:hover {
    transform: scale(1.02) translateY(-3px);
    box-shadow: 0 0 35px rgba(0, 255, 157, 0.2);
    border-color: rgba(0, 255, 157, 0.5);
}

.hero-blue {
    border: 1px solid rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.05);
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.05) 0%, rgba(10, 10, 10, 0.8) 100%);
}

.hero-blue .hero-val {
    color: var(--cyan-holo);
    text-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.hero-blue:hover {
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.15);
    border-color: rgba(0, 240, 255, 0.4);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .hero-stats-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .hero-emerald {
        transform: none;
    }

    .hero-emerald:hover {
        transform: translateY(-3px);
    }

    .hero-val {
        font-size: 1.8rem;
    }
}