/* ===================================================================
   SynapseAlpha — Global Styles
   Reset, Variables, Body, Scrollbar, Navigation, Layout, Sidebar, Search
   =================================================================== */

/* === Reset & Variables === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Backgrounds */
    --bg: #09090b;
    --surface: #18181b;
    --surface-elevated: #27272a;
    --border: #3f3f46;
    --border-subtle: #27272a;

    /* Text */
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --muted: #a1a1aa;

    /* Accents */
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.12);
    --green-border: rgba(34, 197, 94, 0.25);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.12);
    --red-border: rgba(239, 68, 68, 0.25);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.12);
    --blue-border: rgba(59, 130, 246, 0.25);
    --amber: #f59e0b;
    --amber-dim: rgba(245, 158, 11, 0.12);
    --amber-border: rgba(245, 158, 11, 0.25);
    --purple: #a855f7;
    --purple-dim: rgba(168, 85, 247, 0.12);
    --purple-border: rgba(168, 85, 247, 0.25);
    --yellow: #ffd600;

    /* Layout */
    --nav-h: 56px;
    --sidebar-w: 300px;

    /* Typography */
    --font-ui: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace;

    /* Radius */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-pill: 100px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ===================================================================
   TOP NAVIGATION
   =================================================================== */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 1000;
    gap: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-icon {
    font-size: 20px;
    color: var(--blue);
    line-height: 1;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    transition: all 0.15s ease;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface);
}

.nav-link.active {
    color: var(--text);
    background: var(--surface-elevated);
}

.nav-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-controls select {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-family: var(--font-mono);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a1a1aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.nav-controls select:hover {
    border-color: var(--border);
}

.nav-controls select:focus {
    outline: none;
    border-color: var(--blue);
}

/* ===================================================================
   APP LAYOUT
   =================================================================== */
.app-layout {
    display: flex;
    margin-top: var(--nav-h);
    min-height: calc(100vh - var(--nav-h));
}

/* ===================================================================
   SIDEBAR
   =================================================================== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 20px 16px 16px;
    height: calc(100vh - var(--nav-h));
    position: sticky;
    top: var(--nav-h);
    overflow: hidden;
}

.sidebar-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

.sidebar-title span:first-child {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}

.history-count {
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-elevated);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    margin: 0 -4px;
    padding: 0 4px;
}

.history-item {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    background: transparent;
}

.history-item:hover {
    background: var(--surface-elevated);
}
.history-report-link {
    float: right;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 2px 4px;
    border-radius: 4px;
}
.history-item:hover .history-report-link { opacity: 1; }
.history-report-link:hover { color: var(--blue); background: var(--blue-dim); }

.history-item.selected {
    border-color: var(--blue);
    background: var(--blue-dim);
}

.history-item .ticker {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
    color: var(--text);
}

.history-item .date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.history-item .verdict-badge {
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    float: right;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.verdict-buy {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid var(--green-border);
}
.verdict-sell {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid var(--red-border);
}
.verdict-hold {
    background: var(--amber-dim);
    color: var(--amber);
    border: 1px solid var(--amber-border);
}

.compare-btn {
    margin-top: 12px;
    padding: 10px;
    background: var(--surface-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-ui);
    transition: all 0.15s ease;
}

.compare-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.compare-btn:not(:disabled):hover {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

/* ===================================================================
   MAIN CONTENT
   =================================================================== */
.main-content {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
    max-width: 960px;
}

/* Alias for legacy JS references */
main {
    flex: 1;
}

/* ===================================================================
   SEARCH SECTION
   =================================================================== */
.search-section {
    margin-bottom: 32px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-bar:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-dim), 0 0 24px var(--blue-dim);
}

.ticker-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.search-icon {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.ticker-input-wrapper input,
#ticker-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 15px;
    font-family: var(--font-ui);
    font-weight: 500;
    padding: 8px 0;
    outline: none;
    min-width: 200px;
}

#ticker-input::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.date-picker,
#date-input {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-family: var(--font-mono);
    width: 150px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

#date-input:hover,
#date-input:focus {
    border-color: var(--border);
    color: var(--text);
    outline: none;
}

.add-queue-btn {
    background: var(--surface-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.add-queue-btn:hover {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.analyze-btn {
    background: var(--blue);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    font-family: var(--font-ui);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.analyze-btn:hover {
    background: #2563eb;
    box-shadow: 0 0 16px var(--blue-dim);
}

.analyze-btn:disabled {
    opacity: 0.5;
    cursor: default;
    box-shadow: none;
}

/* ===================================================================
   AUTOCOMPLETE
   =================================================================== */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: -16px;
    width: 380px;
    max-height: 280px;
    overflow-y: auto;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: none;
    z-index: 200;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    transition: background 0.1s ease;
    gap: 12px;
}

.autocomplete-item:hover {
    background: var(--surface);
}

.autocomplete-item .symbol {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--blue);
    letter-spacing: 0.5px;
}

.autocomplete-item .name {
    color: var(--text-secondary);
    font-size: 12px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===================================================================
   QUEUE BAR
   =================================================================== */
.queue-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.queue-chip {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.5px;
}

.queue-chip .remove {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    transition: color 0.1s ease;
}

.queue-chip .remove:hover {
    color: var(--red);
}
