/* ═══════════════════════════════════════════════════════════
   StockPulse AI — Custom Styles
   ═══════════════════════════════════════════════════════════ */

/* ──── BASE ──── */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ──── CUSTOM SCROLLBAR (adapts to theme) ──── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.dark ::-webkit-scrollbar-thumb {
    background: #374151;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

.ticker-scroll::-webkit-scrollbar {
    height: 3px;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.dark * {
    scrollbar-color: #374151 transparent;
}


/* ──── PAGE TRANSITIONS ──── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-transition {
    animation: fadeIn 0.3s ease-out;
}

#app-content > * {
    animation: fadeIn 0.3s ease-out;
}


/* ──── CARD HOVER EFFECTS ──── */
.card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.dark .card {
    background: #111827;
    border-color: #1f2937;
}

.card:hover {
    border-color: #d1d5db;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.05);
}
.dark .card:hover {
    border-color: #374151;
}

.card-clickable { cursor: pointer; }
.card-clickable:hover {
    border-color: #3b82f6;
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.1);
}

/* ──── METRIC CARD ──── */
.metric-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.dark .metric-card {
    background: #111827;
    border-color: #1f2937;
}

.metric-card .metric-label {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-card .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
}
.dark .metric-card .metric-value {
    color: #f9fafb;
}

.metric-card .metric-change {
    font-size: 0.8rem;
    font-weight: 600;
}

.metric-card .metric-change.positive {
    color: #22c55e;
}

.metric-card .metric-change.negative {
    color: #ef4444;
}

.metric-card .metric-change.neutral {
    color: #6b7280;
}


/* ──── CHANGE BADGE ──── */
.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 600;
    border-radius: 4px;
    line-height: 1;
}

.change-badge.positive {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.change-badge.negative {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}


/* ──── SIGNAL BADGES ──── */
.signal-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.signal-badge.buy,
.signal-badge.bullish,
.signal-badge.strong-buy {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.signal-badge.sell,
.signal-badge.bearish,
.signal-badge.strong-sell {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.signal-badge.neutral {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
    border: 1px solid rgba(107, 114, 128, 0.25);
}

.signal-badge.hold {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.25);
}


/* ──── VIX GAUGE ──── */
.vix-gauge {
    position: relative;
    width: 180px;
    height: 100px;
    overflow: hidden;
}

.vix-gauge-arc {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(
        from 180deg,
        #22c55e 0deg,
        #22c55e 36deg,
        #84cc16 36deg,
        #84cc16 72deg,
        #eab308 72deg,
        #eab308 108deg,
        #f97316 108deg,
        #f97316 144deg,
        #ef4444 144deg,
        #ef4444 180deg,
        transparent 180deg
    );
    -webkit-mask: radial-gradient(circle at center, transparent 55px, black 56px, black 85px, transparent 86px);
    mask: radial-gradient(circle at center, transparent 55px, black 56px, black 85px, transparent 86px);
}

.vix-gauge-needle {
    position: absolute;
    bottom: 4px;
    left: 50%;
    width: 3px;
    height: 60px;
    background: #f9fafb;
    border-radius: 2px;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(var(--needle-rotation, -90deg));
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

.vix-gauge-needle::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: #f9fafb;
    border-radius: 50%;
}

.vix-gauge-labels {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 0.6rem;
    color: #6b7280;
}

.vix-gauge-value {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: #f9fafb;
}


/* ──── SECTOR HEATMAP ──── */
.sector-heatmap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 4px;
}

.sector-heatmap-cell {
    padding: 0.75rem 0.5rem;
    border-radius: 6px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-height: 56px;
    justify-content: center;
}

.sector-heatmap-cell:hover {
    transform: scale(1.04);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.sector-heatmap-cell .sector-name {
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.2;
}

.sector-heatmap-cell .sector-change {
    font-size: 0.8rem;
    font-weight: 700;
}


/* ──── LOADING SKELETON ──── */
.skeleton {
    background: linear-gradient(90deg, #e5e7eb 25%, #d1d5db 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease-in-out infinite;
    border-radius: 6px;
}
.dark .skeleton {
    background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    background-size: 200% 100%;
}

@keyframes skeletonPulse {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.medium {
    width: 70%;
}

.skeleton-heading {
    height: 24px;
    width: 50%;
    margin-bottom: 12px;
}

.skeleton-card {
    height: 120px;
}

.skeleton-chart {
    height: 300px;
}


/* ──── LOADING SPINNER ──── */
.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
}
.dark .spinner {
    border-color: #1f2937;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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


/* ──── TOAST NOTIFICATIONS ──── */
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
    max-width: 360px;
}

.toast.success {
    background: #064e3b;
    border: 1px solid #065f46;
    color: #a7f3d0;
}

.toast.error {
    background: #7f1d1d;
    border: 1px solid #991b1b;
    color: #fecaca;
}

.toast.info {
    background: #1e3a5f;
    border: 1px solid #1e40af;
    color: #bfdbfe;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}


/* ──── TABLE STYLES ──── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-table thead th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.dark .data-table thead th {
    border-bottom-color: #1f2937;
}

.data-table tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}
.dark .data-table tbody td {
    border-bottom-color: #111827;
    color: #d1d5db;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.04);
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

.data-table tbody tr.clickable:hover {
    background: rgba(59, 130, 246, 0.08);
}


/* ──── BUTTON STYLES ──── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    outline: none;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}
.dark .btn-secondary {
    background: #1f2937;
    color: #d1d5db;
    border-color: #374151;
}

.btn-secondary:hover {
    background: #e5e7eb;
}
.dark .btn-secondary:hover {
    background: #374151;
    border-color: #4b5563;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.7rem;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}


/* ──── TAB STYLES ──── */
.tab-group {
    display: flex;
    gap: 2px;
    background: #f3f4f6;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.dark .tab-group {
    background: #111827;
    border-color: #1f2937;
}

.tab-btn {
    padding: 0.4rem 0.9rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: transparent;
}

.tab-btn:hover {
    color: #111827;
}
.dark .tab-btn:hover {
    color: #d1d5db;
}

.tab-btn.active {
    background: #ffffff;
    color: #111827;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.dark .tab-btn.active {
    background: #1f2937;
    color: #f9fafb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}


/* ──── INPUT STYLES ──── */
.input {
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: #111827;
}
.dark .input {
    background: #111827;
    border-color: #1f2937;
    color: #f9fafb;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.input::placeholder {
    color: #4b5563;
}


/* ──── MOBILE BOTTOM NAV ──── */
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 1023px) {
    .mobile-bottom-nav {
        display: block;
    }

    /* Add padding at bottom so content isn't hidden behind bottom nav */
    #app-content {
        padding-bottom: 4rem;
    }
}


/* ──── RESPONSIVE: SIDEBAR COLLAPSE ──── */
@media (max-width: 1023px) {
    #sidebar {
        transform: translateX(-100%);
    }
}


/* ──── SECTION HEADERS ──── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
}
.dark .section-title {
    color: #f9fafb;
}

.section-subtitle {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.15rem;
}


/* ──── CHART CONTAINER ──── */
.chart-container {
    position: relative;
    background: #ffffff;
    border: 1px solid #e5e7eb;
}
.dark .chart-container {
    background: #111827;
    border-color: #1f2937;
    border-radius: 0.75rem;
    padding: 1rem;
    overflow: hidden;
}

.chart-container canvas {
    max-width: 100%;
}


/* ──── MISC ──── */
.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(229, 231, 235, 0.5);
}
.dark .glass {
    background: rgba(17, 24, 39, 0.7);
    border-color: rgba(31, 41, 55, 0.5);
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Pulse dot for live indicator */
.pulse-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulseDot 2s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
}
