:root {
    --bg-dark: #0f1115;
    --card-bg: rgba(25, 28, 36, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f2f5;
    --text-secondary: #a0aab2;
    --accent-glow: rgba(0, 255, 170, 0.3);
    --accent-color: #00ffaa;
    --buy-color: #00ffaa;
    --sell-color: #ff4757;
    --hold-color: #feca57;
    --graph-pending: #2d3436;
    --graph-active: #0984e3;
    --graph-done: #00ffaa;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Animated Background */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}
.shape1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(9,132,227,0.4) 0%, rgba(0,0,0,0) 70%);
    top: -200px;
    left: -100px;
}
.shape2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0,255,170,0.3) 0%, rgba(0,0,0,0) 70%);
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}
.shape3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(108,92,231,0.3) 0%, rgba(0,0,0,0) 70%);
    top: 40%;
    left: 30%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.2); }
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

/* Header & Search */
.header {
    text-align: center;
    margin-top: 4rem;
}

.header h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.gradient-text {
    background: linear-gradient(135deg, #00ffaa 0%, #0984e3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.search-container {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

#query-input {
    width: 100%;
    padding: 1.2rem 1.5rem;
    font-size: 1.1rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: rgba(15, 17, 21, 0.8);
    color: white;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    font-family: 'Outfit', sans-serif;
}

#query-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-glow);
}

#search-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    bottom: 8px;
    width: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0984e3 0%, #00ffaa 100%);
    color: #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#search-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--accent-glow);
}

#search-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Glass Card Utilities */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.hidden {
    display: none !important;
}

/* --- Graph Visualizer --- */
.graph-container {
    background: rgba(15, 17, 21, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem 2rem;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.graph-title {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    font-weight: 500;
}

.status-text {
    margin-top: 2rem;
    font-size: 1.1rem;
    color: var(--accent-color);
    font-weight: 500;
    min-height: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* CSS Grid for Graph Nodes */
.graph-wrapper {
    display: grid;
    grid-template-columns: 80px 40px 180px 40px 180px 20px 20px 180px;
    grid-template-rows: 100px 100px 100px;
    align-items: center;
    justify-content: center;
    gap: 0;
    overflow-x: auto;
    padding: 1rem;
}

.node-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

.graph-node {
    padding: 1rem;
    border-radius: 16px;
    background: var(--graph-pending);
    color: #fff;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    transition: all 0.4s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.node-icon {
    font-size: 1.8rem;
}

.node-label {
    font-size: 0.9rem;
}

/* Graph States */
.graph-node.pending {
    opacity: 0.6;
    border-color: rgba(255,255,255,0.1);
}

.graph-node.active {
    opacity: 1;
    background: rgba(9, 132, 227, 0.2);
    border-color: var(--graph-active);
    box-shadow: 0 0 20px rgba(9, 132, 227, 0.4);
    transform: scale(1.05);
}

.graph-node.done {
    opacity: 1;
    background: rgba(0, 255, 170, 0.1);
    border-color: var(--graph-done);
    box-shadow: 0 0 15px rgba(0, 255, 170, 0.2);
}

#node-start {
    border-radius: 50%;
    width: 60px;
    height: 60px;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0;
}

/* Graph Lines */
.line {
    background: #444;
    transition: background 0.4s ease, box-shadow 0.4s ease;
    z-index: 1;
}

.line.active {
    background: var(--graph-active);
    box-shadow: 0 0 10px var(--graph-active);
}

.line.done {
    background: var(--graph-done);
    box-shadow: 0 0 5px var(--graph-done);
}

.line.horizontal {
    height: 3px;
    width: 100%;
}

.line.vertical {
    width: 3px;
    height: 100%;
    margin: 0 auto;
}

/* Specific line adjustments for routing */
.top-branch { height: 50%; align-self: flex-end; }
.bottom-branch { height: 50%; align-self: flex-start; }
.branch-left-top { align-self: flex-end; }
.branch-left-bottom { align-self: flex-start; }
.branch-right-top { align-self: flex-end; }
.branch-right-bottom { align-self: flex-start; }

/* --- Dashboard --- */
.dashboard {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.decision-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.decision-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--accent-color);
}

.decision-card.buy::before { background: var(--buy-color); box-shadow: 0 0 20px var(--buy-color); }
.decision-card.sell::before { background: var(--sell-color); box-shadow: 0 0 20px var(--sell-color); }
.decision-card.hold::before { background: var(--hold-color); box-shadow: 0 0 20px var(--hold-color); }

.decision-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.decision-header h2 {
    font-size: 3rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.decision-card.buy h2 { color: var(--buy-color); }
.decision-card.sell h2 { color: var(--sell-color); }
.decision-card.hold h2 { color: var(--hold-color); }

.stock-ticker {
    font-size: 1.2rem;
    background: rgba(255,255,255,0.1);
    padding: 0.3rem 1rem;
    border-radius: 20px;
    color: var(--text-primary);
}

.decision-reason {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 800px;
    line-height: 1.6;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.dashboard h3 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.metric-item {
    background: rgba(0,0,0,0.2);
    padding: 1.2rem;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
}

.metric-value.positive { color: var(--buy-color); }
.metric-value.negative { color: var(--sell-color); }

/* News */
.news-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.news-list::-webkit-scrollbar {
    width: 6px;
}
.news-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}
.news-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.news-card {
    background: rgba(0,0,0,0.2);
    padding: 1.2rem;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: transform 0.2s ease, background 0.2s ease;
}

.news-card:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.05);
}

.news-title {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.news-title a {
    color: inherit;
    text-decoration: none;
}
.news-title a:hover {
    color: var(--accent-color);
}

.news-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

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

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

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .graph-wrapper {
        transform: scale(0.8);
        transform-origin: left center;
    }
}
