/* Constantes CSS */
:root {
    --altura-footer: 70px;
    --altura-botones-fijos: 80px;
    --espacio-botones-footer: 10px;
    --altura-titulo: 120px;
    --espacio-consistente: 20px;
    --color-primario: #4CAF50;
    --color-primario-hover: #45a049;
    --color-secundario: #f44336;
    --color-secundario-hover: #d32f2f;
    --color-fondo: #f0f0f0;
    --color-texto: #333;
    --color-texto-secundario: #666;
    --sombra-suave: 0 4px 12px rgba(0, 0, 0, 0.1);
    --sombra-fuerte: 0 4px 15px rgba(0, 0, 0, 0.2);
    --transicion-rapida: 0.2s ease;
    --transicion-media: 0.3s ease;
    --border-radius: 12px;
}

/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: var(--altura-footer);
    line-height: 1.6;
    overscroll-behavior: none;
}

/* Título principal */
.titulo {
    text-align: center;
    padding: 20px 15px 10px;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    color: var(--color-texto);
    font-weight: 700;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Fecha */
.fecha-container {
    text-align: center;
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: var(--color-texto-secundario);
    width: 90%;
    max-width: 800px;
    margin: 0 auto 15px;
    display: none;
    padding: 0 15px;
}

/* CONTENEDOR PRINCIPAL */
.contenedor-principal {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 15px 20px;
    box-sizing: border-box;
    min-height: calc(100vh - var(--altura-titulo) - var(--altura-footer) - 30px);
}

/* ESTADO INICIAL */
.estado-inicial {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 30px;
    height: 100%;
    padding: 20px 0;
    animation: fadeIn 0.5s ease;
}

/* Animación de entrada */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* GIF container */
.gif-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #e8f5e9;
    border-radius: var(--border-radius);
    box-shadow: var(--sombra-suave);
    overflow: hidden;
    padding: 15px;
    border: 1px solid rgba(76, 175, 80, 0.1);
}

.gif-container img {
    width: 100%;
    max-width: 280px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.gif-container img:hover {
    transform: scale(1.01);
}

.gif-texto {
    width: 100%;
    text-align: center;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: #2c3e50;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 12px 15px;
    font-weight: 600;
    border-radius: 8px;
    border-left: 4px solid var(--color-primario);
}

.gif-texto-separador {
    display: block;
    font-size: 0.85em;
    font-weight: normal;
    color: var(--color-texto-secundario);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(76, 175, 80, 0.2);
}

/* BOTÓN COMENZAR */
.boton-comenzar-container {
    width: 100%;
    max-width: 300px;
    display: flex;
    justify-content: center;
}

.boton-comenzar {
    background: linear-gradient(135deg, var(--color-primario), var(--color-primario-hover));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 18px 35px;
    font-size: clamp(1.2rem, 3vw, 1.4rem);
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--sombra-fuerte);
    transition: all var(--transicion-rapida);
    width: 100%;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.boton-comenzar:hover,
.boton-comenzar:active {
    background: linear-gradient(135deg, var(--color-primario-hover), var(--color-primario));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
}

.boton-comenzar:active {
    transform: translateY(0);
}

/* ESTADO ENTRENAMIENTO */
.estado-entrenamiento {
    display: none;
    flex-direction: column;
    width: 100%;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.contenedor-principal.con-registros .estado-inicial {
    display: none;
}

.contenedor-principal.con-registros .estado-entrenamiento {
    display: flex;
}

/* Tabla de series */
.tabla-container {
    width: 100%;
    max-width: 800px;
    margin: 15px auto;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transicion-media);
    border-radius: var(--border-radius);
    background: white;
    box-shadow: var(--sombra-suave);
}

.tabla-container.con-registros {
    max-height: min(50vh, 400px);
    overflow-y: auto;
    border: 1px solid #e0e0e0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 15px 10px;
    text-align: center;
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    color: var(--color-texto);
    font-weight: 600;
    border-bottom: 2px solid var(--color-primario);
}

td {
    padding: 12px 10px;
    text-align: center;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--color-texto);
    border-bottom: 1px solid #eee;
}

tbody tr {
    transition: background-color var(--transicion-rapida);
}

tbody tr:hover {
    background-color: #f9f9f9;
}

tbody tr:last-child td {
    border-bottom: none;
}

.contenido-celda {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Botón eliminar serie */
.boton-eliminar {
    background-color: var(--color-secundario);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transicion-rapida);
    flex-shrink: 0;
}

.boton-eliminar:hover {
    background-color: var(--color-secundario-hover);
    transform: scale(1.1);
}

/* Cronómetro */
.cronometro-container {
    width: 100%;
    max-width: 800px;
    margin: 20px auto;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #e8f5e9, #d4edda);
    border-radius: var(--border-radius);
    box-shadow: var(--sombra-suave);
    border: 1px solid rgba(76, 175, 80, 0.2);
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transicion-media);
}

.cronometro-container.mostrar {
    opacity: 1;
    transform: translateY(0);
}

#cronometro {
    font-size: clamp(1.8rem, 5vw, 2.2rem);
    font-weight: 700;
    color: var(--color-texto);
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
    margin-bottom: 5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.cronometro-etiqueta {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: var(--color-texto-secundario);
    font-weight: 500;
}

/* BOTONES FIJOS - MEJORADO PARA MÓVILES */
.botones-fijos {
    position: fixed;
    bottom: calc(var(--altura-footer) + var(--espacio-botones-footer));
    left: 0;
    right: 0;
    display: none;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform var(--transicion-media) ease, opacity var(--transicion-media) ease;
    opacity: 0;
}

.botones-fijos.visible {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.boton {
    min-width: 140px;
    height: 55px;
    border-radius: var(--border-radius);
    border: none;
    color: white;
    font-size: clamp(0.95rem, 2.5vw, 1rem);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all var(--transicion-rapida);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    letter-spacing: 0.3px;
    padding: 0 20px;
}

.boton-registrar { 
    background: linear-gradient(135deg, var(--color-primario), var(--color-primario-hover));
}

.boton-borrar { 
    background: linear-gradient(135deg, var(--color-secundario), var(--color-secundario-hover));
}

.boton:hover,
.boton:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.boton:active {
    transform: translateY(0);
}

/* Feedback táctil para móviles */
@media (hover: none) {
    .boton:hover {
        transform: none;
    }
    
    .boton:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* FOOTER */
footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    text-align: center;
    font-size: clamp(0.75rem, 2vw, 0.85rem);
    color: var(--color-texto-secundario);
    padding: 12px 15px;
    background-color: rgba(240, 240, 240, 0.95);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-top: 1px solid #ddd;
    height: var(--altura-footer);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    z-index: 999;
}

footer a {
    color: var(--color-texto);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transicion-rapida);
}

footer a:hover {
    color: var(--color-primario);
    text-decoration: underline;
}

footer a:last-child {
    color: #FF5F5F;
    font-weight: 600;
}

/* Scroll personalizado solo para la tabla */
.tabla-container::-webkit-scrollbar {
    width: 8px;
}

.tabla-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tabla-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.tabla-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* RESPONSIVE PARA MÓVILES */
@media (max-width: 768px) {
    :root {
        --altura-footer: 65px;
        --altura-botones-fijos: 70px;
        --espacio-consistente: 15px;
    }

    .contenedor-principal {
        padding: 0 10px 15px;
    }

    .botones-fijos {
        gap: 15px;
        padding: 12px 15px;
        bottom: calc(var(--altura-footer) + 8px);
    }

    .boton {
        min-width: 120px;
        height: 50px;
        font-size: 0.9rem;
        padding: 0 15px;
    }

    .tabla-container.con-registros {
        max-height: 40vh;
    }

    .gif-container {
        padding: 12px;
    }

    .gif-container img {
        max-width: 250px;
    }
}

@media (max-width: 480px) {
    .botones-fijos {
        gap: 12px;
        padding: 10px 12px;
    }

    .boton {
        min-width: 110px;
        height: 48px;
        font-size: 0.85rem;
    }

    .contenido-celda {
        gap: 8px;
    }

    .boton-eliminar {
        width: 24px;
        height: 24px;
        font-size: 1rem;
    }
}

/* Dark mode opcional */
@media (prefers-color-scheme: dark) {
    :root {
        --color-fondo: #1a1a1a;
        --color-texto: #ffffff;
        --color-texto-secundario: #aaaaaa;
    }

    body {
        background-color: var(--color-fondo);
        color: var(--color-texto);
    }

    .gif-container,
    .cronometro-container {
        background-color: #2a2a2a;
    }

    .tabla-container {
        background: #2a2a2a;
        border-color: #444;
    }

    thead {
        background: linear-gradient(135deg, #333, #444);
    }

    td {
        border-color: #444;
    }

    tbody tr:hover {
        background-color: #333;
    }

    .botones-fijos {
        background: rgba(42, 42, 42, 0.98);
        border-top-color: rgba(255,255,255,0.1);
    }

    footer {
        background-color: rgba(26, 26, 26, 0.95);
        border-top-color: #444;
    }
    }
