/* Light Theme */
html[data-bs-theme="light"] {
    --bg-color-start: hsl(210, 30%, 98%);
    --bg-color-end: hsl(210, 30%, 90%);
    --font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --bg-glow-1: hsla(210, 80%, 80%, 0.3); /* Soft blue */
    --bg-glow-2: hsla(50, 80%, 80%, 0.2);  /* Soft yellow/orange */
    --surface-color: #ffffff;
    --surface-color-rgb: 255, 255, 255;
    --primary-text-color: #212529;
    --secondary-text-color: #6c757d;
    --bitcoin-orange: #f2a900;
    --accent-blue: #0d6efd;
    --accent-blue-rgb: 13, 110, 253;
    --border-color: #dee2e6;
    --border-color-rgb: 222, 226, 230;
}

/* Dark Theme */
html[data-bs-theme="dark"] {
    --bg-color-start: hsl(240, 10%, 10%);
    --bg-color-end: hsl(240, 10%, 5%);
    --font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --bg-glow-1: hsla(210, 50%, 20%, 0.4); /* Soft dark blue */
    --bg-glow-2: hsla(260, 50%, 20%, 0.3); /* Soft dark purple */
    --surface-color: #1e1e1e;
    --surface-color-rgb: 30, 30, 30;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #a0a0a0;
    --bitcoin-orange: #f2a900;
    --accent-blue: #0d6efd;
    --accent-blue-rgb: 13, 110, 253;
    --border-color: #444;
    --border-color-rgb: 68, 68, 68;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color-end);
    background-image: 
        radial-gradient(at 0% 0%, var(--bg-glow-1) 0px, transparent 50%),
        radial-gradient(at 95% 95%, var(--bg-glow-2) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--primary-text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
}

/* Estilo del H1 para el tema oscuro: Mantenemos el efecto de degradado */
html[data-bs-theme="dark"] h1 {
    background: linear-gradient(45deg, var(--bitcoin-orange), #ffdd99);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Estilo del H1 para el tema claro: Usamos un color sólido para máxima legibilidad */
html[data-bs-theme="light"] h1 {
    color: #212529; /* Color oscuro por defecto de Bootstrap para texto */
}

/* Controles de la esquina superior derecha */
#top-right-controls {
    position: absolute;
    top: 0;
    right: 1rem; /* Ajustado para que no pegue al borde */
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Hacemos que el contenedor del gráfico sea responsive */
#chart-container {
    /* Efecto Glassmorphism */
    background: rgba(var(--surface-color-rgb), 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px); /* Para Safari */
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    width: 100%;
    border: 1px solid rgba(var(--surface-color-rgb), 0.18);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    /* Estilos para el estado de carga */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 450px;
}

/* El SVG llenará el contenedor, y el navegador lo escalará */
#chart-container svg {
    width: 100%;
    height: auto;
    font-family: 'Inter', sans-serif;
}

/* Estilos para los ejes */
.axis path,
.axis line {
    stroke: var(--border-color);
}

.axis text {
    fill: var(--secondary-text-color);
    font-size: 0.8rem; /* Aumentamos ligeramente el tamaño para mejor legibilidad */
    font-family: var(--font-monospace); /* Usamos una fuente monoespaciada para los datos */
}

.axis--y .tick line {
    stroke: var(--border-color);
    stroke-dasharray: 2, 2;
}

.line {
    fill: none;
    stroke: var(--bitcoin-orange);
    stroke-width: 2px;
}

.fictitious-line {
    stroke-dasharray: 4, 4; /* Crea el efecto de línea de puntos */
    stroke-opacity: 0.7; /* La hace ligeramente más transparente */
}

.event-marker {
    stroke: var(--surface-color);
    stroke-width: 2px;
    cursor: pointer;
    transform-origin: center; /* Asegura que la escala se haga desde el centro */
    transform-box: fill-box;  /* Clave para la compatibilidad en Firefox */
    transition: transform 0.2s ease-in-out, opacity 0.3s ease-in-out, stroke 0.2s ease-in-out, stroke-width 0.2s ease-in-out;
}

.event-marker:hover {
    stroke: var(--bitcoin-orange);
    stroke-width: 3px;
}

/* Estilo para resaltar un marcador desde la cronología */
.event-marker.highlighted {
    stroke: var(--bitcoin-orange);
    stroke-width: 4px;
    transform: scale(1.7);
}

/* Estilo para el foco del teclado para accesibilidad */
.event-marker:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Animación de pulso para los marcadores de eventos */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

.event-marker.pulsing {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Colores de las categorías de eventos */
.event-marker.category-technology { fill: #0dcaf0; } /* Bootstrap info */
.event-marker.category-market { fill: #fd7e14; } /* Bootstrap orange */
.event-marker.category-adoption { fill: #198754; } /* Bootstrap success */
.event-marker.category-regulation { fill: #dc3545; } /* Bootstrap danger */
.event-marker.category-security { fill: #6f42c1; } /* Bootstrap indigo */
.event-marker.category-halving { fill: #d63384; } /* Bootstrap pink, para mejor contraste */

/* Estilos para los puntos de color en los botones de filtro */
.filter-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0,0,0,0.2);
}
.filter-dot.category-technology { background-color: #0dcaf0; }
.filter-dot.category-market { background-color: #fd7e14; }
.filter-dot.category-adoption { background-color: #198754; }
.filter-dot.category-regulation { background-color: #dc3545; }
.filter-dot.category-security { background-color: #6f42c1; }
.filter-dot.category-halving { background-color: #d63384; }

.tooltip {
    position: absolute;
    text-align: center;
    padding: 8px;
    font: 12px 'Inter', sans-serif;
    background: rgba(40, 40, 40, 0.9);
    color: #fff;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    max-width: 250px;
    line-height: 1.4;
}

/* Estilo para la cronología de eventos */
.list-group-item {
    transition: opacity 0.3s ease-in-out;
}

/* Estilo para el precio dentro del tooltip */
.tooltip .tooltip-price {
    font-family: var(--font-monospace);
    font-size: 1.1em;
}

/* Estilo específico para el tooltip de eventos */
.tooltip.tooltip-event {
    background: var(--accent-blue);
    color: #fff;
    text-align: left;
}

.tooltip hr {
    margin: 4px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.5);
}

/* Estilos para el brush */
.context .line {
    stroke-width: 1.5px;
    stroke: var(--secondary-text-color);
}

.brush .selection {
    fill: var(--bitcoin-orange);
    fill-opacity: 0.3;
    stroke: var(--bitcoin-orange);
}

/* Estilos para el tooltip interactivo */
.hover-line {
    stroke: var(--primary-text-color);
    stroke-width: 1px;
    stroke-dasharray: 3,3;
}

.hover-dot {
    fill: var(--bitcoin-orange);
    stroke: var(--surface-color);
    stroke-width: 2px;
}

/* Estilos para las áreas de mercado */
.market-area {
    opacity: 0.1;
}
.market-area.bull {
    fill: #28a745; /* Verde */
}
.market-area.bear {
    fill: #dc3545; /* Rojo */
}

/* Responsive adjustments for mobile devices */
@media (max-width: 768px) {
    #top-right-controls {
        position: relative;
        top: auto;
        right: auto;
        justify-content: center;
        margin-bottom: 1.5rem;
    }

    h1 {
        font-size: 1.75rem; /* Reduce title size for better fit on mobile */
    }
}

/* Estilos modernos para botones */
#event-filters .btn,
#scale-toggle,
#reset-zoom,
#top-right-controls .btn {
    background: rgba(var(--surface-color-rgb), 0.5);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(var(--border-color-rgb), 0.2);
    transition: all 0.3s ease;
}

#event-filters .btn:hover, #event-filters .btn.active, /* Estilos para filtros */
#scale-toggle:hover, #reset-zoom:hover,
#top-right-controls .btn:hover, #top-right-controls .btn.active { /* Estilos para controles superiores */
    background: rgba(var(--surface-color-rgb), 0.75);
    border-color: rgba(var(--accent-blue-rgb), 0.5);
    box-shadow: 0 0 15px rgba(var(--accent-blue-rgb), 0.3);
    color: var(--primary-text-color); /* Asegura la legibilidad del texto en estado activo/hover */
}