/* Sprock Trading - OLED Cyber Theme */
/* Mobile-First "Control Deck" Layout */

:root {
    /* OLED Deep Blacks */
    --bg-primary: #000000;
    --bg-secondary: #050505;
    --bg-tertiary: #0A0A0A;
    --bg-glass: rgba(10, 10, 10, 0.85);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    /* Neons */
    --neon-cyan: #06b6d4;
    --neon-indigo: #6366f1;
    --neon-purple: #a855f7;
    --neon-green: #10b981;
    --neon-red: #ef4444;

    /* Status */
    --positive: #10b981;
    --negative: #ef4444;

    /* Layout */
    --header-height: 48px;
    --deck-height: 180px;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
    font-size: 14px;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* ===== 1. TOP BAR & TICKER ===== */
.top-bar {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    z-index: 10;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--neon-cyan);
    font-weight: 700;
    letter-spacing: 0.05em;
    font-size: 1rem;
    flex-shrink: 0;
}

.logo-icon {
    width: 1.25rem;
    height: 1.25rem;
}

.ticker-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(90deg, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, black 10%, black 90%, transparent);
}

.ticker-track {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    white-space: nowrap;
    /* Optional: Add scrolling animation here later */
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.ticker-symbol {
    color: var(--text-secondary);
    font-weight: 500;
}

.ticker-price {
    color: var(--text-primary);
    font-weight: 600;
}

.ticker-change {
    font-size: 0.7rem;
}

.ticker-separator {
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.3;
}

.status-indicator {
    padding: 0.25rem;
}

.status-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 5px currentColor;
}

.status-indicator.connected .status-dot {
    background: var(--neon-green);
    color: var(--neon-green);
}

.ticker-change.positive {
    color: var(--positive);
}

.ticker-change.negative {
    color: var(--negative);
}

/* ===== 2. CHART VIEWPORT ===== */
.chart-viewport {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    /* Make space for Control Deck */
}

/* Info overlay on top of chart */
.chart-overlay-info {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 5;
    pointer-events: none;
    /* Let clicks pass through to chart */
}

.chart-symbol-tag {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

#chart-symbol {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.tf-tag {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-secondary);
}

.chart-price-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chart-price-display .price {
    font-size: 1.125rem;
    font-family: var(--font-mono);
    font-weight: 600;
}

#chart-container {
    width: 100%;
    height: 100%;
}

/* ===== 3. CONTROL DECK ===== */
.control-deck {
    height: auto;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    z-index: 20;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.deck-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

/* Segmented Control for Timeframes */
.segmented-control {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 4px;
    flex: 1;
    gap: 4px;
}

.tf-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.tf-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

/* Asset Tabs */
.asset-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.asset-tab {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.asset-tab .symbol {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.asset-tab .name {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.asset-tab.active {
    background: linear-gradient(145deg, rgba(6, 182, 212, 0.1), rgba(6, 182, 212, 0.05));
    border-color: rgba(6, 182, 212, 0.3);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.1);
}

.asset-tab.active .symbol {
    color: var(--neon-cyan);
}

/* AI Trigger Button */
.ai-trigger {
    background: linear-gradient(135deg, var(--neon-indigo), var(--neon-purple));
    border: none;
    border-radius: 16px;
    height: 52px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: white;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    transition: transform 0.1s;
}

.ai-trigger:active {
    transform: scale(0.98);
}

.ai-trigger svg {
    width: 1.25rem;
    height: 1.25rem;
}

.ai-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    animation: glow-sweep 3s infinite;
}

@keyframes glow-sweep {

    0%,
    80% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* ===== 4. CHAT SHEET ===== */
.chat-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 85vh;
    background: #111;
    border-radius: 20px 20px 0 0;
    z-index: 100;
    transform: translateY(110%);
    /* Hidden */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-sheet::before {
    /* Backdrop overlay */
    content: '';
    position: fixed;
    top: -100vh;
    left: 0;
    right: 0;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
    z-index: -1;
}

.chat-sheet.open {
    transform: translateY(0);
}

.chat-sheet.open::before {
    opacity: 1;
    pointer-events: auto;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 12px auto;
}

.chat-header {
    padding: 0 1.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-title {
    display: flex;
    gap: 0.5rem;
    color: var(--neon-purple);
    font-weight: 600;
}

.close-sheet {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.chat-input-area {
    padding: 1rem 1.5rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 0.75rem;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 12px 16px;
    color: white;
    font-size: 1rem;
    outline: none;
}

#chat-input:focus {
    border-color: var(--neon-indigo);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--neon-indigo);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Chat Messages Styling */
.chat-welcome {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-secondary);
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.quick-prompt {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
}

.chat-message {
    padding: 8px 0;
    animation: fadeIn 0.3s ease;
}

.chat-message.user {
    text-align: right;
}

.chat-message.user .message-content {
    background: var(--neon-indigo);
    color: white;
    display: inline-block;
    padding: 10px 16px;
    border-radius: 16px 16px 2px 16px;
    text-align: left;
}

.chat-message.assistant .message-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 4px 16px 16px 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Desktop Overrides */
@media (min-width: 1024px) {

    /* Keep the deck layout but perhaps constrain width or move it to side-bar in future */
    /* For now, uniform interface is fine for a unified trading terminal */
    .control-deck {
        max-width: 600px;
        margin: 0 auto;
        border-radius: 24px 24px 0 0;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
    }

    .chat-sheet {
        max-width: 500px;
        left: auto;
        right: 2rem;
        border-radius: 20px 20px 0 0;
    }
}