/* Panel de mareas: reproduccion del Anuario y curva del dia.
   Reutiliza .panel-flotante / .panel-header / .panel-body de resolver.css */

/* Debajo del panel de pasos, que ocupa arriba a la izquierda.
   Sin transform: hacerDraggable() escribe top/left y un transform lo desplazaria. */
.panel-mareas {
    bottom: 44px;
    left: 26px;
    width: 510px;
    max-width: calc(100vw - 52px);
}

.panel-mareas .panel-body {
    max-height: 66vh;
    overflow-y: auto;
    padding: 0.75rem;
}

/* --- Paso de resolución sincronizado --- */

#mareas-paso-activo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.25rem;
    margin-bottom: 0.65rem;
    padding: 0.42rem 0.55rem;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #2563eb;
    border-radius: 0.45rem;
    background: linear-gradient(90deg, #eff6ff, #f8fafc);
}

.mareas-paso-insignia {
    flex: 0 0 auto;
    padding: 0.16rem 0.42rem;
    border-radius: 999px;
    background: #1d4ed8;
    color: #fff;
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.025em;
}

.mareas-paso-titulo {
    min-width: 0;
    color: #1e3a8a;
    font-size: 0.78rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#mareas-paso-activo.fase-sm {
    border-left-color: #7c3aed;
    background: linear-gradient(90deg, #f5f3ff, #f8fafc);
}

#mareas-paso-activo.fase-sm .mareas-paso-insignia { background: #7c3aed; }

#mareas-paso-activo.fase-sbq,
#mareas-paso-activo.fase-resumen {
    border-left-color: #16a34a;
    background: linear-gradient(90deg, #f0fdf4, #f8fafc);
}

#mareas-paso-activo.fase-sbq .mareas-paso-insignia,
#mareas-paso-activo.fase-resumen .mareas-paso-insignia { background: #15803d; }

/* --- Anuario --- */

.mareas-anuario-cabecera {
    font-weight: 700;
    color: #1e3a8a;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.mareas-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.mareas-tabla th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    border-bottom: 1px solid #cbd5e1;
    padding: 0.2rem 0.4rem;
}

.mareas-tabla td {
    padding: 0.22rem 0.4rem;
    border-bottom: 1px solid #eef2f7;
    font-family: 'Courier New', monospace;
}

.mareas-tabla tbody tr {
    cursor: pointer;
}

.mareas-tabla tbody tr:hover {
    background: #eff6ff;
}

.mareas-tipo {
    font-weight: 700;
}

.marea-pm .mareas-tipo {
    color: #1d4ed8;
}

.marea-pm {
    background: #eff6ff;
}

.marea-bm .mareas-tipo {
    color: #0f766e;
}

.marea-bm {
    background: #f0fdfa;
}

/* --- Grafico --- */

#mareas-grafico {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

#mareas-corte {
    width: 100%;
    margin-top: 0.5rem;
    overflow: hidden;
    border: 1px solid #dbeafe;
    border-radius: 0.5rem;
    background: linear-gradient(#f8fafc, #eff6ff);
}

#mareas-corte:empty {
    display: none;
}

.mareas-svg {
    display: block;
}

.mareas-eje-txt {
    font-size: 9.5px;
    fill: #526277;
}

.mareas-eje-titulo {
    font-size: 10px;
    font-weight: 700;
    fill: #334155;
}

.mareas-punto-txt {
    font-size: 9.5px;
    font-weight: 700;
    fill: #334155;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 3px;
    stroke-linejoin: round;
}

.mareas-punto-txt.pleamar {
    fill: #1d4ed8;
}

.mareas-punto-txt.bajamar {
    fill: #0f766e;
}

.mareas-punto-txt.destacado {
    fill: #dc2626;
}

.mareas-cota-txt {
    font-size: 9.5px;
    font-weight: 700;
}

.mareas-cursor-txt {
    font-size: 10px;
    font-weight: 800;
    fill: #111827;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 3px;
    stroke-linejoin: round;
}

/* Modo correccion aditiva: el Anuario da abjp y ca en vez de la curva */
.mareas-ca-label {
    font-family: inherit !important;
    color: #475569;
}

/* --- Leyenda --- */

.mareas-leyenda {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.9rem;
    margin: 0.5rem 0;
    font-size: 0.7rem;
    color: #475569;
}

.mareas-leyenda-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.mareas-leyenda-item i {
    width: 16px;
    height: 0;
    border-top-width: 3px;
    border-top-style: solid;
    display: inline-block;
}

.ln-doceavos { border-top-color: #1d4ed8; }
.ln-sinusoidal { border-top-color: #0891b2; border-top-style: dashed !important; }
.ln-hm { border-top-color: #059669; }
.ln-sc { border-top-color: #b45309; }
.ln-sm { border-top-color: #7c3aed; }
.ln-sbq { border-top-color: #dc2626; }

/* --- Controles --- */

#mareas-controles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.6rem;
}

.mareas-control {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.72rem;
    color: #475569;
}

.mareas-control-ancho {
    grid-column: 1 / -1;
}

.mareas-control input[type="number"] {
    padding: 0.28rem 0.4rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    width: 100%;
}

.mareas-control input[type="range"] {
    width: 100%;
}

.mareas-control output {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #1e3a8a;
    font-size: 0.8rem;
}

/* --- Lectura --- */

#mareas-lectura {
    background: #f8f9fa;
    border-left: 4px solid #1e3a8a;
    border-radius: 0.25rem;
    padding: 0.5rem 0.6rem;
}

.mareas-lectura-fila {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.18rem 0;
    font-size: 0.78rem;
    border-bottom: 1px solid #e9ecef;
}

.mareas-lectura-fila:last-child {
    border-bottom: none;
}

.mareas-lectura-fila.destacada {
    font-weight: 700;
    color: #166534;
}

.mareas-lectura-label {
    color: #495057;
}

.mareas-lectura-fila.destacada .mareas-lectura-label {
    color: #166534;
}

.mareas-lectura-valor {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #1e3a8a;
    text-align: right;
    white-space: nowrap;
}

.mareas-lectura-fila.destacada .mareas-lectura-valor {
    color: #166534;
}

@media (max-width: 700px) {
    .panel-mareas {
        left: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
        max-width: none;
    }

    .panel-mareas .panel-body {
        max-height: 58vh;
    }

    .mareas-paso-titulo {
        white-space: normal;
    }
}
