/* Stock Intelligence Module Styles */

/* Base Layout */
/* Increased specificity to override .view.active (display: block) */
.stock-intel-container.view,
.stock-intel-container {
    padding: var(--space-lg);
    max-width: 1600px;
    margin: 0 auto;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    display: grid !important;
    /* Force grid layout */
    grid-template-columns: 1fr;
    /* Default to stack, then desktop override */
    gap: var(--space-xl);
    min-height: calc(100vh - 80px);
}

@media (min-width: 1025px) {

    .stock-intel-container.view,
    .stock-intel-container {
        grid-template-columns: 320px 1fr;
    }
}

/* Sidebar (History & Controls combined if needed, or just History) */
.stock-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    border-right: 1px solid var(--line-subtle);
    padding-right: var(--space-md);
}

.stock-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.history-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line-subtle);
}

.history-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary);
}

.history-ticker {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}

.history-meta {
    font-size: 0.75rem;
    color: var(--text-subtle);
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

/* Delete button — hidden by default, revealed on hover */
.history-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
    z-index: 2;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    background: rgba(255, 82, 82, 0.15);
    color: #FF5252;
}

/* Main Content Area */
.stock-main {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* Input Section */
.stock-input-section {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
    /* Ensure bottom alignment for inputs/buttons */
    background: var(--bg-surface);
    padding: var(--space-md);
    border-radius: 12px;
    border: 1px solid var(--line-subtle);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
    /* Align labels/inputs to bottom if heights differ */
}

.input-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.stock-input {
    background: #000;
    border: 1px solid var(--line-subtle);
    border-radius: 8px;
    padding: 0 16px;
    /* Use flex/line-height for centering */
    height: 46px;
    /* Fixed height matching button */
    color: white;
    font-family: var(--font-mono);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.stock-input:focus {
    border-color: var(--primary);
    outline: none;
}

.stock-select {
    background: #000;
    border: 1px solid var(--line-subtle);
    border-radius: 8px;
    padding: 0 16px;
    /* Use flex/line-height for centering */
    height: 46px;
    /* Fixed height matching button */
    color: white;
    font-family: var(--font-display);
    font-size: 0.9rem;
    cursor: pointer;
    -webkit-appearance: none;
    /* Remove default arrow to style if needed, but keeping simple for now */
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
}

.analyze-btn {
    background: var(--primary);
    color: #000;
    font-family: var(--font-display);
    font-weight: 700;
    padding: 0 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    transition: transform 0.1s, opacity 0.2s;
    height: 46px;
    /* Match input height */
}

.analyze-btn:hover {
    opacity: 0.9;
}

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

.analyze-btn:disabled {
    background: var(--line-subtle);
    cursor: not-allowed;
    color: var(--text-muted);
}

/* -----------------------------------------------------------------------
 * DeepThink Toggle — pill-shaped switch with glow on activation.
 * Matches dark HUD aesthetic. Toggle state managed via aria-checked.
 * How to undo: remove this block + HTML toggle div.
 * ----------------------------------------------------------------------- */
.deepthink-toggle-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    justify-content: flex-end;
}

.deepthink-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 88px;
    height: 46px;
    padding: 0 8px;
    background: #111;
    border: 1px solid var(--line-subtle);
    border-radius: 23px;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    font-family: var(--font-display);
    color: var(--text-muted);
}

.deepthink-toggle:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.deepthink-knob {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #333;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

.deepthink-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.3s ease;
    pointer-events: none;
}

/* Active (ON) state via aria-checked */
.deepthink-toggle[aria-checked="true"] {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.25), inset 0 0 8px rgba(99, 102, 241, 0.1);
}

.deepthink-toggle[aria-checked="true"] .deepthink-knob {
    transform: translateX(32px);
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
}

.deepthink-toggle[aria-checked="true"] .deepthink-label {
    color: #06b6d4;
}

/* Report View */
.stock-report {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.stock-report.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Executive Summary Card */
.exec-summary-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid var(--line-subtle);
    border-radius: 12px;
    padding: var(--space-lg);
    display: grid;
    grid-template-columns: 1fr 180px;
    /* Reduced from 300px */
    gap: var(--space-lg);
}

.exec-content h1 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: var(--space-sm);
    color: white;
}

.exec-content .price-display {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--text-subtle);
    margin-bottom: var(--space-md);
}

.exec-content p {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-main);
    opacity: 0.9;
}

/* Conviction Gauge */
.conviction-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    border: 1px solid var(--line-subtle);
    border-radius: 8px;
    padding: var(--space-xs);
    /* Reduced padding */
    position: relative;
    overflow: hidden;
    max-width: 100px;
    /* Reduced from 140px */
    height: 140px;
    /* Fixed height to keep it vertical but smaller */
}

.gauge-score {
    font-size: 1.5rem;
    /* Reduced from 2rem */
    font-weight: 900;
    font-family: var(--font-display);
    line-height: 1;
}

.gauge-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 4px;
    font-weight: 700;
}

.gauge-ring {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px;
    opacity: 0.1;
    pointer-events: none;
}

/* Color coding for Conviction */
.conviction-STRONG_BUY {
    color: #00E676;
}

.conviction-BUY {
    color: #69F0AE;
}

.conviction-NEUTRAL {
    color: #B0BEC5;
}

.conviction-SELL {
    color: #FF5252;
}

.conviction-STRONG_SELL {
    color: #D50000;
}

.conviction-STRONG_BUY .gauge-ring {
    background: #00E676;
}

.conviction-BUY .gauge-ring {
    background: #69F0AE;
}

.conviction-NEUTRAL .gauge-ring {
    background: #B0BEC5;
}

.conviction-SELL .gauge-ring {
    background: #FF5252;
}

.conviction-STRONG_SELL .gauge-ring {
    background: #D50000;
}

/* Modules Grid */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-lg);
}

.module-card {
    background: var(--bg-surface);
    border: 1px solid var(--line-subtle);
    border-radius: 12px;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line-subtle);
    padding-bottom: var(--space-sm);
}

.module-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
}

.module-content {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-main);
}

/* Risk Tags */
.risk-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: var(--space-sm);
}

.risk-tag {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.05);
    /* Default */
    border: 1px solid var(--line-subtle);
    color: var(--text-subtle);
}

.risk-tag.critical {
    background: rgba(213, 0, 0, 0.1);
    border-color: rgba(213, 0, 0, 0.4);
    color: #FF8A80;
}

.risk-tag.high {
    background: rgba(255, 82, 82, 0.1);
    border-color: rgba(255, 82, 82, 0.4);
    color: #FF8A80;
}

.risk-tag.medium {
    background: rgba(255, 171, 64, 0.1);
    border-color: rgba(255, 171, 64, 0.4);
    color: #FFD180;
}

.risk-tag.low {
    background: rgba(105, 240, 174, 0.05);
    border-color: rgba(105, 240, 174, 0.2);
    color: #B9F6CA;
}

/* Loading State */
.stock-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-muted);
}

.ticker-loader {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: var(--space-md);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.stock-empty {
    text-align: center;
    padding: var(--space-xl) * 2;
    color: var(--text-muted);
    border: 1px dashed var(--line-subtle);
    border-radius: 12px;
}

/* Responsive */
@media (max-width: 1024px) {
    .stock-intel-container {
        grid-template-columns: 1fr;
    }

    .stock-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--line-subtle);
        padding-right: 0;
        padding-bottom: var(--space-md);
        display: none;
        /* Hide sidebar on mobile for now or make collapsible */
    }

    .exec-summary-card {
        grid-template-columns: 1fr;
    }
}