/* table.css - Diseño mejorado con margen derecho corregido */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

:root {
    --primary-color: #69aeb6;
    --secondary-color: #3a7bd5;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --header-bg: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --even-row-bg: #f7f9fc;
    --hover-row-bg: #e9f3f7;
    --shadow-light: rgba(0, 0, 0, 0.05);
    --transition-speed: 0.3s;
}

/* Contenedor de tabla con sombra y bordes redondeados */
.content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 25px 0;
    font-family: 'Poppins', sans-serif;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px var(--shadow-light);
    background-color: #ffffff;
    border: 1px solid var(--border-color);
}

/* Contenedor para la tabla en desktop - AJUSTE PARA CORREGIR MARGEN DERECHO */
@media screen and (min-width: 941px) {
    .content table {
        display: table;
        white-space: normal;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Mantener el scroll horizontal solo en dispositivos móviles y tablets */
@media screen and (max-width: 940px) {
    .content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Estilos para encabezados */
.content table thead th {
    background: var(--header-bg);
    color: #ffffff;
    padding: 5px 20px;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    text-align: center;
    position: sticky;
    top: 0;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-speed);
}

/* Estilos para celdas */
.content table td {
    padding: 12px 20px;
    text-align: center;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    transition: all var(--transition-speed);
}

/* Filas alternas */
.content table tbody tr:nth-child(even) {
    background-color: var(--even-row-bg);
}

/* Hover sobre filas */
.content table tbody tr:hover {
    background-color: var(--hover-row-bg);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.content table tbody tr:first-child td {
    border-bottom: none;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Estilo para acciones o botones dentro de la tabla */
.content table .action-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition-speed);
}

.content table .action-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

/* Estilos responsivos */
@media screen and (max-width: 940px) {
    .content table {
        border-radius: 8px;
    }

    .content table thead th {
        padding: 12px 15px;
        font-size: 0.85rem;
    }

    .content table td {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

@media screen and (max-width: 760px) {
    .content table thead th {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .content table tbody tr:first-child td {
        font-size: 1.1rem;
    }

    .content table td {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* Para tablas con muchas columnas, un indicador de desplazamiento */
    .content section {
        position: relative;
    }

    @keyframes pulse {
        0% { opacity: 0.7; }
        50% { opacity: 0.3; }
        100% { opacity: 0.7; }
    }
}

/* Centrar el título "Historial de Aforos" */
#titulo-aforos {
    text-align: center;
    margin-bottom: 25px;
    font-weight: 600;
    color: var(--text-color);
}

/* Animación de entrada para la tabla */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content table {
    animation: fadeIn 0.5s ease-out forwards;
}

#medias-aforos-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    max-width: 100%;
}

#medias-aforos-table th,
#medias-aforos-table td {
    white-space: nowrap;
}

/* ===== Historial de Aforos: contenedor de altura fija con scroll en
   ambos ejes, para que el scroll horizontal esté siempre visible cerca
   de la cabecera y no haya que bajar hasta el final de la tabla ===== */
.table-responsive {
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.admin-table {
    width: max-content;
    min-width: 1200px;
    border-collapse: collapse;
    font-size: 0.85em;
    margin: 0; /* anula el margin: 25px 0 de .content table, sobra dentro de este contenedor */
}

.admin-table th,
.admin-table td {
    padding: 8px 10px;
    white-space: nowrap;
    text-align: center;
}

/* Cabecera fija tanto al hacer scroll vertical como horizontal */
.admin-table thead th,
.admin-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}
#tabla-historial-mermas.admin-table {
    min-width: 0;
    width: 100%;
}

/* Tablas sueltas que se meten solas en "table-responsive":
   el contenedor aporta borde, sombra y scroll; la tabla no los duplica. */
.content .table-responsive > table:not(.admin-table) {
    display: table;
    width: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    animation: none;
}

.content .table-responsive > table:not(.admin-table) thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}