/* =============================================================================
   STOCK ANALYZER - TEMA DARK/LIGHT MODE
   ============================================================================= */

/* =============================================================================
   FEATURE CARDS (Home Page)
   ============================================================================= */

.features-container {
    display: flex;
    justify-content: center;
    align-items: stretch;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 20px;
    flex-wrap: wrap;
}

.feature-title {
    color: var(--text-primary) !important;
    margin-bottom: 5px;
    font-weight: 600;
}

.feature-desc {
    color: var(--text-muted) !important;
    font-size: 0.8rem;
    margin: 0;
}

.feature-divider {
    width: 1px;
    background: var(--border-primary);
    margin: 10px 0;
}

/* =============================================================================
   DOWNLOAD BUTTON
   ============================================================================= */

.download-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 12px 24px !important;
    color: #ffffff !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3) !important;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4) !important;
}

.download-btn span,
.download-btn .btn-text-white,
.btn-text-white {
    color: #ffffff !important;
}

/* =============================================================================
   SCORE LEVEL BADGE
   ============================================================================= */

.score-level-badge {
    font-weight: 600 !important;
    padding: 6px 16px !important;
}

/* =============================================================================
   DISCLAIMER
   ============================================================================= */

.disclaimer-text {
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
    margin: 0;
    padding: 12px 24px;
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.25);
    border-radius: 10px;
    display: inline-block;
}

/* =============================================================================
   YTD CARDS (Comparativa)
   ============================================================================= */

.ytd-card {
    text-align: center;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid;
    border-radius: 12px;
}

.ytd-label {
    color: var(--text-muted) !important;
    font-size: 0.7rem;
    margin-top: 4px;
}

/* =============================================================================
   SCORE BREAKDOWN (EvaluaciÃ³n tab)
   ============================================================================= */

/* Category name in score breakdown */
.score-category-name {
    font-weight: 600;
    color: var(--text-primary) !important;
}

/* Score value (9/20, etc) */
.score-value {
    font-weight: 700;
    margin-right: 12px;
}

/* "ver detalles" button */
.score-detail-btn {
    font-size: 0.75rem;
    color: var(--accent-primary) !important;
    cursor: pointer;
    transition: color 0.2s ease;
}

.score-detail-btn:hover {
    color: var(--accent-secondary) !important;
    text-decoration: underline;
}

/* Progress bar background */
.score-progress-bar {
    background-color: var(--bg-tertiary) !important;
}

/* Adjustment row in collapsed details */
.adjustment-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-primary);
}

.adjustment-metric {
    font-size: 0.8rem;
    color: var(--text-primary) !important;
    font-weight: 500;
    margin-left: 8px;
    margin-right: 8px;
}

.adjustment-reason {
    font-size: 0.8rem;
    color: var(--text-muted) !important;
}

.no-adjustments-text {
    color: var(--text-muted) !important;
    font-size: 0.8rem;
    margin: 8px 0;
}

/* =============================================================================
   SCORE SUMMARY CARDS (Resumen de PuntuaciÃ³n)
   ============================================================================= */

.score-summary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.score-summary-label {
    color: var(--text-muted) !important;
    font-size: 0.75rem;
    margin-bottom: 8px;
}

.score-total-card {
    background: var(--bg-tertiary);
}

/* Variables CSS - Dark Mode (Default) */
:root {
    /* Backgrounds */
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --bg-card: rgba(24, 24, 27, 0.9);
    --bg-input: #18181b;
    --bg-navbar: rgba(9, 9, 11, 0.98);
    --bg-hover: #3f3f46;
    
    /* Borders */
    --border-primary: #3f3f46;
    --border-secondary: rgba(63, 63, 70, 0.5);
    --border-light: #52525b;
    
    /* Text - brighter for dark mode */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-inverse: #09090b;
    
    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-gradient-start: #60a5fa;
    --accent-gradient-end: #a78bfa;
    
    /* Status Colors */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #facc15;
    --warning-bg: rgba(250, 204, 21, 0.15);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.15);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.15);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    
    /* Chart colors */
    --chart-bg: #18181b;
    --chart-grid: #3f3f46;
    --chart-text: #a1a1aa;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* Light Mode Variables */
[data-theme="light"] {
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.98);
    --bg-input: #ffffff;
    --bg-navbar: rgba(255, 255, 255, 0.98);
    --bg-hover: #e2e8f0;
    
    /* Borders */
    --border-primary: #cbd5e1;
    --border-secondary: rgba(148, 163, 184, 0.5);
    --border-light: #e2e8f0;
    
    /* Text - improved contrast */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    
    /* Status colors - slightly darker for light mode */
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.1);
    --warning: #ca8a04;
    --warning-bg: rgba(202, 138, 4, 0.1);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.1);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.1);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Chart colors */
    --chart-bg: #ffffff;
    --chart-grid: #e2e8f0;
    --chart-text: #475569;
}

/* =============================================================================
   BASE STYLES
   ============================================================================= */

body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Container principal */
.container-fluid {
    background-color: var(--bg-primary) !important;
    min-height: 100vh;
    transition: background-color var(--transition-normal);
}

/* =============================================================================
   THEME TOGGLE BUTTON
   ============================================================================= */

.theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border-primary);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Icons for theme toggle */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun,
:root:not([data-theme]) .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme]) .theme-toggle .icon-moon {
    display: none;
}

/* =============================================================================
   NAVBAR
   ============================================================================= */

#navbar-container {
    background: var(--bg-navbar) !important;
    border-bottom: 1px solid var(--border-secondary) !important;
    transition: background var(--transition-normal), border-color var(--transition-normal);
}

/* Logo gradient - siempre visible */
#logo-home span:last-child {
    background: linear-gradient(135deg, var(--accent-gradient-start) 0%, var(--accent-gradient-end) 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* =============================================================================
   INPUTS & BUTTONS
   ============================================================================= */

#navbar-search-input,
#home-search-input,
input[type="text"] {
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
    transition: all var(--transition-fast);
}

#navbar-search-input:focus,
#home-search-input:focus,
input[type="text"]:focus {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
    outline: none !important;
}

#navbar-search-input::placeholder,
#home-search-input::placeholder,
input::placeholder {
    color: var(--text-muted) !important;
}

/* Primary buttons */
#navbar-search-btn,
#home-search-btn,
.btn-primary {
    background-color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
    color: white !important;
    transition: all var(--transition-fast);
}

#navbar-search-btn:hover,
#home-search-btn:hover,
.btn-primary:hover {
    background-color: var(--accent-primary-hover) !important;
    border-color: var(--accent-primary-hover) !important;
}

/* =============================================================================
   CARDS & CONTAINERS
   ============================================================================= */

.card,
.dbc-card {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
    transition: all var(--transition-normal);
}

.card-header {
    background-color: var(--bg-tertiary) !important;
    border-bottom: 1px solid var(--border-primary) !important;
    color: var(--text-primary) !important;
}

.card-body {
    background-color: transparent !important;
    color: var(--text-primary) !important;
}

/* Score card */
.score-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-primary) !important;
    border-radius: 16px;
    transition: all var(--transition-normal);
}

/* Metric cards */
.metric-card {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    transition: all var(--transition-normal);
}

.metric-label {
    color: var(--text-muted) !important;
    font-size: 0.75rem;
}

.metric-value {
    color: var(--text-primary) !important;
    font-size: 1.1rem;
    font-weight: 600;
}

/* =============================================================================
   TABS
   ============================================================================= */

.nav-tabs {
    border-bottom: 1px solid var(--border-primary) !important;
}

.nav-tabs .nav-link {
    color: var(--text-secondary) !important;
    background-color: transparent !important;
    border: none !important;
    transition: all var(--transition-fast);
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary) !important;
    background-color: var(--bg-hover) !important;
}

.nav-tabs .nav-link.active {
    color: var(--accent-primary) !important;
    background-color: var(--bg-secondary) !important;
    border-bottom: 2px solid var(--accent-primary) !important;
}

.tab-content {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    border-top: none !important;
    border-radius: 0 0 8px 8px;
    padding: 20px;
    transition: all var(--transition-normal);
}

/* =============================================================================
   TABLES
   ============================================================================= */

.table {
    color: var(--text-primary) !important;
}

.table thead th {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-primary) !important;
}

.table tbody td {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-primary) !important;
}

.table-striped tbody tr:nth-of-type(odd) td {
    background-color: var(--bg-tertiary) !important;
}

.table-hover tbody tr:hover td {
    background-color: var(--bg-hover) !important;
}

/* =============================================================================
   ALERTS & SIGNALS - Modern Card Design
   ============================================================================= */

/* Base alert box style */
.alert-box {
    padding: 12px 16px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    border-left: 4px solid;
    border-top: 1px solid var(--border-primary);
    border-right: 1px solid var(--border-primary);
    border-bottom: 1px solid var(--border-primary);
    transition: all 0.2s ease;
}

.alert-box:hover {
    background-color: var(--bg-tertiary);
}

.alert-box strong {
    font-weight: 600;
    font-size: 0.9rem;
}

.alert-box span {
    color: var(--text-primary) !important;
    font-size: 0.9rem;
}

.alert-box .text-muted {
    color: var(--text-muted) !important;
    font-size: 0.8rem !important;
    opacity: 0.9;
}

/* Success/Fortalezas */
.alert-success-custom,
.alert-box.alert-success-custom {
    border-left-color: var(--success) !important;
}

.alert-success-custom strong,
.alert-box.alert-success-custom strong {
    color: var(--success) !important;
}

/* Warning/Advertencias */
.alert-warning-custom,
.alert-box.alert-warning-custom {
    border-left-color: var(--warning) !important;
}

.alert-warning-custom strong,
.alert-box.alert-warning-custom strong {
    color: var(--warning) !important;
}

/* Danger/Riesgo */
.alert-danger-custom,
.alert-box.alert-danger-custom {
    border-left-color: var(--danger) !important;
}

.alert-danger-custom strong,
.alert-box.alert-danger-custom strong {
    color: var(--danger) !important;
}

/* Info */
.alert-info-custom,
.alert-box.alert-info-custom {
    border-left-color: var(--info) !important;
}

.alert-info-custom strong,
.alert-box.alert-info-custom strong {
    color: var(--info) !important;
}

.badge {
    transition: all var(--transition-fast);
}

/* =============================================================================
   SUGGESTIONS DROPDOWN
   ============================================================================= */

#navbar-search-suggestions,
#home-search-suggestions,
.search-suggestions {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
    box-shadow: var(--shadow-lg);
}

.suggestion-item {
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-secondary) !important;
    transition: background-color var(--transition-fast);
}

.suggestion-item:hover {
    background-color: var(--bg-hover) !important;
}

/* =============================================================================
   HOME VIEW SPECIFIC
   ============================================================================= */

#home-view {
    background-color: var(--bg-primary) !important;
}

/* Hero section text */
#home-view h1,
#home-view h2,
#home-view h3 {
    color: var(--text-primary) !important;
}

#home-view p {
    color: var(--text-secondary) !important;
}

/* Feature boxes in home */
#home-view .feature-box {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-primary) !important;
}

/* =============================================================================
   ANALYSIS VIEW SPECIFIC
   ============================================================================= */

#analysis-view {
    background-color: var(--bg-primary) !important;
}

/* Company header */
#company-header {
    color: var(--text-primary) !important;
}

#company-header h2,
#company-header h3,
#company-header h4 {
    color: var(--text-primary) !important;
}

/* =============================================================================
   CHARTS (Plotly)
   ============================================================================= */

.js-plotly-plot .plotly .bg {
    fill: var(--chart-bg) !important;
}

/* Note: Plotly charts need JavaScript updates for full theme support */

/* =============================================================================
   SCROLLBAR
   ============================================================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =============================================================================
   TEXT UTILITIES
   ============================================================================= */

.text-muted {
    color: var(--text-muted) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-info {
    color: var(--info) !important;
}

/* Ensure paragraphs and small text are readable */
p, span, small, .small {
    color: var(--text-secondary);
}

/* Headers should always be primary text color */
h1, h2, h3, h4, h5, h6, 
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--text-primary) !important;
}

/* Feature boxes in home - fix text colors */
.card-body p,
.card-body span,
.card-body small {
    color: var(--text-secondary) !important;
}

.card-body h5,
.card-body h6,
.card-body .h5,
.card-body .h6 {
    color: var(--text-primary) !important;
}

/* Home page feature descriptions */
#home-view p {
    color: var(--text-secondary) !important;
}

#home-view h1, 
#home-view h2, 
#home-view h3,
#home-view h4,
#home-view h5,
#home-view h6 {
    color: var(--text-primary) !important;
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
    .theme-toggle {
        bottom: 15px;
        right: 15px;
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .theme-toggle {
        display: none !important;
    }
}

/* =============================================================================
   LOADING STATES
   ============================================================================= */

.loading-spinner {
    border-color: var(--border-primary);
    border-top-color: var(--accent-primary);
}

/* =============================================================================
   MISC OVERRIDES
   ============================================================================= */

hr {
    border-color: var(--border-primary) !important;
    opacity: 0.5;
}

a {
    color: var(--accent-primary);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* Ensure all headings inherit proper color */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
}

/* Code blocks */
code, pre {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-primary);
}

/* Selection */
::selection {
    background-color: var(--accent-primary);
    color: white;
}

/* =============================================================================
   OVERRIDE INLINE STYLES (for elements with hardcoded colors)
   ============================================================================= */

/* Force text colors on elements that might have inline styles */
[data-theme="light"] [style*="color: #fff"],
[data-theme="light"] [style*="color: #ffffff"],
[data-theme="light"] [style*="color: white"],
[data-theme="light"] [style*="color:#fff"],
[data-theme="light"] [style*="color:#ffffff"] {
    color: var(--text-primary) !important;
}

[data-theme="light"] [style*="color: #a1a1aa"],
[data-theme="light"] [style*="color: #71717a"],
[data-theme="light"] [style*="color:#a1a1aa"],
[data-theme="light"] [style*="color:#71717a"] {
    color: var(--text-secondary) !important;
}

/* Fix background colors in light mode */
[data-theme="light"] [style*="background: #18181b"],
[data-theme="light"] [style*="background: #09090b"],
[data-theme="light"] [style*="background-color: #18181b"],
[data-theme="light"] [style*="background-color: #09090b"],
[data-theme="light"] [style*="background:#18181b"],
[data-theme="light"] [style*="background:#09090b"] {
    background-color: var(--bg-secondary) !important;
}

/* Fix border colors in light mode */
[data-theme="light"] [style*="border-color: #3f3f46"],
[data-theme="light"] [style*="border: 1px solid #3f3f46"] {
    border-color: var(--border-primary) !important;
}

/* =============================================================================
   ADDITIONAL COMPONENT FIXES
   ============================================================================= */

/* Alert boxes */
.alert {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

.alert-danger {
    background-color: var(--danger-bg) !important;
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

.alert-warning {
    background-color: var(--warning-bg) !important;
    border-color: var(--warning) !important;
    color: var(--warning) !important;
}

.alert-success {
    background-color: var(--success-bg) !important;
    border-color: var(--success) !important;
    color: var(--success) !important;
}

.alert-info {
    background-color: var(--info-bg) !important;
    border-color: var(--info) !important;
    color: var(--info) !important;
}

/* Dismissable alert X button */
.alert .btn-close {
    filter: var(--text-primary) === '#fafafa' ? invert(1) : none;
}

[data-theme="light"] .alert .btn-close {
    filter: none;
}

[data-theme="dark"] .alert .btn-close,
:root:not([data-theme]) .alert .btn-close {
    filter: invert(1);
}

/* Score circle and related elements */
.score-display {
    color: var(--text-primary) !important;
}

/* Metric cards specific styling */
.metric-card,
[class*="metric"] {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Quick pick buttons */
.btn-outline-primary {
    color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--accent-primary) !important;
    color: white !important;
}

/* Footer text */
footer, 
.footer,
#analysis-footer {
    color: var(--text-muted) !important;
}

/* Dropdown menus */
.dropdown-menu {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
}

.dropdown-item {
    color: var(--text-primary) !important;
}

.dropdown-item:hover {
    background-color: var(--bg-hover) !important;
}

/* Modals */
.modal-content {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

.modal-header {
    border-bottom-color: var(--border-primary) !important;
}

.modal-footer {
    border-top-color: var(--border-primary) !important;
}

/* Tooltips */
.tooltip-inner {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Progress bars */
.progress {
    background-color: var(--bg-tertiary) !important;
}

/* List groups */
.list-group-item {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
    color: var(--text-primary) !important;
}

/* Collapse/Accordion */
.accordion-item {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
}

.accordion-button {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

.accordion-button:not(.collapsed) {
    background-color: var(--accent-primary) !important;
    color: white !important;
}

/* =============================================================================
   CRITICAL FIXES - INLINE STYLE OVERRIDES
   ============================================================================= */

/* Fix ALL text that might have hardcoded dark colors */
[data-theme="light"] * {
    --inline-text-fix: var(--text-primary);
}

/* Feature boxes descriptions - FORCE readable text */
[style*="color: #71717a"],
[style*="color:#71717a"],
[style*="color: #a1a1aa"],
[style*="color:#a1a1aa"],
[style*="color: rgb(113, 113, 122)"],
[style*="color: rgb(161, 161, 170)"] {
    color: var(--text-secondary) !important;
}

/* Download PDF button fix */
button[style*="background"],
.btn[style*="background"] {
    color: white !important;
}

/* Table first column - metric names */
.table td:first-child,
.table th:first-child,
table td:first-child,
table th:first-child {
    color: var(--text-primary) !important;
}

/* ALL table cells should be readable */
.table td,
.table th,
table td,
table th {
    color: var(--text-primary) !important;
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
}

/* Table headers */
.table thead th,
table thead th {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Fix description text in feature cards */
.card p,
.card span,
.card small,
.card .small,
.card-body p,
.card-body span {
    color: var(--text-secondary) !important;
}

/* Fix the 4 feature boxes on home page */
#home-view .card,
#home-view [class*="card"] {
    background-color: var(--bg-secondary) !important;
}

#home-view .card p,
#home-view .card span,
#home-view .card small {
    color: var(--text-secondary) !important;
}

#home-view .card h5,
#home-view .card h6,
#home-view .card strong {
    color: var(--text-primary) !important;
}

/* Force all small/muted text to be visible */
.small, small, .text-muted, .text-secondary {
    color: var(--text-muted) !important;
}

/* Row/Col containers with inline backgrounds */
[style*="background: #27272a"],
[style*="background-color: #27272a"],
[style*="background:#27272a"],
[style*="background-color:#27272a"],
[style*="background: #18181b"],
[style*="background-color: #18181b"],
[style*="background:#18181b"],
[style*="background-color:#18181b"],
[style*="background: rgb(39, 39, 42)"],
[style*="background: rgb(24, 24, 27)"] {
    background-color: var(--bg-secondary) !important;
}

/* Ensure buttons with inline styles have white text */
button[style*="#6366f1"],
button[style*="#818cf8"],
button[style*="rgb(99, 102, 241)"],
[style*="background: #6366f1"],
[style*="background-color: #6366f1"] {
    color: white !important;
}

/* Fix any div with gray background to use theme colors */
div[style*="background"][style*="#2"] {
    background-color: var(--bg-secondary) !important;
}

div[style*="background"][style*="#1"] {
    background-color: var(--bg-primary) !important;
}

/* Comparison table specific fixes */
[class*="comparison"] td,
[class*="comparison"] th,
[id*="comparison"] td,
[id*="comparison"] th {
    color: var(--text-primary) !important;
}

/* Row hover states */
tr:hover td {
    background-color: var(--bg-hover) !important;
}

/* Badge fixes */
.badge {
    color: white !important;
}

.badge-primary, .bg-primary {
    background-color: var(--accent-primary) !important;
}

.badge-success, .bg-success {
    background-color: var(--success) !important;
}

.badge-danger, .bg-danger {
    background-color: var(--danger) !important;
}

.badge-warning, .bg-warning {
    background-color: var(--warning) !important;
    color: #000 !important;
}

/* Evaluation bars text */
[class*="progress"] span,
[class*="bar"] span {
    color: var(--text-primary) !important;
}

/* Score breakdown cards in evaluation */
[style*="background"][style*="fee"] {
    color: var(--danger) !important;
}

[style*="background"][style*="dcf"],
[style*="background"][style*="d1f"] {
    color: var(--success) !important;
}

/* Light mode specific overrides */
[data-theme="light"] [style*="color: #fff"],
[data-theme="light"] [style*="color:#fff"],
[data-theme="light"] [style*="color: #ffffff"],
[data-theme="light"] [style*="color:#ffffff"],
[data-theme="light"] [style*="color: white"],
[data-theme="light"] [style*="color:white"] {
    color: var(--text-primary) !important;
}

/* But keep button text white in light mode */
[data-theme="light"] button[style*="background"] {
    color: white !important;
}

[data-theme="light"] .btn-primary,
[data-theme="light"] [class*="btn"][style*="background"] {
    color: white !important;
}

/* Ensure the download button is always readable */
#download-btn,
[id*="download"],
button:has(> span:contains("Descargar")),
button:has(> span:contains("PDF")) {
    color: white !important;
}

/* =============================================================================
   LIGHT MODE - FORCE ALL TEXT COLORS (AGGRESSIVE OVERRIDE)
   ============================================================================= */

/* En light mode, forzar colores de texto legibles para TODOS los elementos con inline styles */
[data-theme="light"] [style*="color: #fff"],
[data-theme="light"] [style*="color:#fff"],
[data-theme="light"] [style*="color: #ffffff"],
[data-theme="light"] [style*="color:#ffffff"],
[data-theme="light"] [style*="color: white"],
[data-theme="light"] [style*="color:white"],
[data-theme="light"] [style*="color: #e4e4e7"],
[data-theme="light"] [style*="color:#e4e4e7"],
[data-theme="light"] [style*="color: #d4d4d8"],
[data-theme="light"] [style*="color:#d4d4d8"],
[data-theme="light"] [style*="color: #fafafa"],
[data-theme="light"] [style*="color:#fafafa"] {
    color: #1e293b !important;
}

/* Textos grises/muted en light mode - hacerlos mÃ¡s oscuros */
[data-theme="light"] [style*="color: #71717a"],
[data-theme="light"] [style*="color:#71717a"],
[data-theme="light"] [style*="color: #a1a1aa"],
[data-theme="light"] [style*="color:#a1a1aa"],
[data-theme="light"] [style*="color: #52525b"],
[data-theme="light"] [style*="color:#52525b"] {
    color: #475569 !important;
}

/* Links/accent en light mode */
[data-theme="light"] [style*="color: #a5b4fc"],
[data-theme="light"] [style*="color:#a5b4fc"],
[data-theme="light"] [style*="color: #60a5fa"],
[data-theme="light"] [style*="color:#60a5fa"] {
    color: #4f46e5 !important;
}

/* Fondos oscuros -> claros en light mode */
[data-theme="light"] [style*="background: #18181b"],
[data-theme="light"] [style*="background-color: #18181b"],
[data-theme="light"] [style*="background:#18181b"],
[data-theme="light"] [style*="background-color:#18181b"],
[data-theme="light"] [style*="background: #1f1f23"],
[data-theme="light"] [style*="background-color: #1f1f23"],
[data-theme="light"] [style*="background: linear-gradient(145deg, #18181b"] {
    background: #f8fafc !important;
}

[data-theme="light"] [style*="background: #27272a"],
[data-theme="light"] [style*="background-color: #27272a"],
[data-theme="light"] [style*="background:#27272a"],
[data-theme="light"] [style*="background-color:#27272a"] {
    background: #f1f5f9 !important;
}

[data-theme="light"] [style*="background: rgba(24, 24, 27"],
[data-theme="light"] [style*="background: rgba(39, 39, 42"] {
    background: rgba(241, 245, 249, 0.8) !important;
}

/* Bordes oscuros -> claros en light mode */
[data-theme="light"] [style*="border-color: #3f3f46"],
[data-theme="light"] [style*="border-color:#3f3f46"],
[data-theme="light"] [style*="border: 1px solid #3f3f46"],
[data-theme="light"] [style*="border: 2px solid #3f3f46"] {
    border-color: #e2e8f0 !important;
}

[data-theme="light"] [style*="border-bottom: 1px solid #27272a"],
[data-theme="light"] [style*="border-bottom: 2px solid #3f3f46"] {
    border-bottom-color: #e2e8f0 !important;
}

/* Tablas en light mode - FORZAR */
[data-theme="light"] table th,
[data-theme="light"] table td,
[data-theme="light"] .table th,
[data-theme="light"] .table td {
    color: #1e293b !important;
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

[data-theme="light"] table thead th,
[data-theme="light"] .table thead th {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
}

/* Cards de mÃ©tricas en light mode */
[data-theme="light"] .ytd-card,
[data-theme="light"] .score-summary-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
}

/* Metric cards background */
[data-theme="light"] [class*="metric"] {
    background-color: #ffffff !important;
}

/* Asegurar que los botones mantengan texto blanco en light mode */
[data-theme="light"] button[style*="background: linear-gradient"] span,
[data-theme="light"] .download-btn span,
[data-theme="light"] .download-btn {
    color: #ffffff !important;
}

/* Score category boxes */
[data-theme="light"] .score-category-name {
    color: #1e293b !important;
}

/* Progress bar background en light mode */
[data-theme="light"] .progress,
[data-theme="light"] .score-progress-bar,
[data-theme="light"] [style*="backgroundColor: #27272a"] {
    background-color: #e2e8f0 !important;
}

/* =============================================================================
   INSTITUTIONAL METRICS CARDS (Altman Z-Score, Piotroski F-Score)
   ============================================================================= */

.institutional-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 16px;
}

.institutional-title {
    font-weight: 600;
    color: var(--text-primary) !important;
    margin-bottom: 8px;
}

.institutional-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.institutional-label {
    font-size: 0.85rem;
    color: var(--text-muted) !important;
    margin-left: 8px;
}

.institutional-desc {
    font-size: 0.8rem;
    color: var(--text-muted) !important;
    margin-top: 8px;
    margin-bottom: 0;
}

/* =============================================================================
   HOME PAGE
   ============================================================================= */

.home-subtitle {
    color: var(--text-muted) !important;
    font-size: 1.1rem;
    margin-bottom: 30px;
}

/* =============================================================================
   HR (Horizontal Rules)
   ============================================================================= */

.theme-hr {
    border-color: var(--border-primary) !important;
}

/* =============================================================================
   COMPARISON TABLE (Comparativa tab)
   ============================================================================= */

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 12px;
}

/* Table headers */
.comparison-th {
    padding: 14px 12px;
    border-bottom: 2px solid var(--border-primary);
    text-align: center;
}

.comparison-th-metric {
    text-align: left;
    padding: 14px 16px;
    color: var(--text-muted) !important;
    font-size: 0.85rem;
    min-width: 120px;
}

.comparison-th-company {
    color: #3b82f6 !important;
    font-weight: 700;
    min-width: 80px;
}

.comparison-th-muted {
    color: var(--text-muted) !important;
    font-size: 0.85rem;
    min-width: 70px;
}

/* Table cells */
.comparison-td {
    padding: 12px;
    border-bottom: 1px solid var(--border-primary);
    text-align: center;
}

.comparison-metric {
    padding: 12px 16px;
    font-weight: 500;
    text-align: left;
    color: var(--text-primary) !important;
}

.comparison-company {
    color: #3b82f6 !important;
    font-weight: 600;
}

.comparison-muted {
    color: var(--text-muted) !important;
}

.comparison-verdict {
    padding: 12px 16px;
    font-weight: 600;
}

/* =============================================================================
   DESGLOSE DEL SCORE - Category boxes background
   ============================================================================= */

/* Estas son las cajas grises de las categorÃ­as en evaluaciÃ³n */
.progress {
    background-color: var(--bg-tertiary) !important;
}

/* Mejorar legibilidad de nÃºmeros de puntuaciÃ³n */
.score-value {
    font-weight: 700 !important;
    margin-right: 12px !important;
}

/* =============================================================================
   SCORE CATEGORY BOXES - THE GRAY BOXES IN DESGLOSE DEL SCORE
   ============================================================================= */

.score-category-box {
    padding: 14px 18px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border-primary);
}

.score-category-box:hover {
    background: var(--bg-tertiary);
}
