/* ==========================================================================
   Reset básico y configuración general
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px; /* Base para rem */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f6; /* Un gris muy claro diferente */
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: #007bff; /* Azul primario Bootstrap */
    text-decoration: none;
}
a:hover {
    color: #0056b3;
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    color: #343a40; /* Gris oscuro */
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 500;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; margin-bottom: 1rem;}
h3 { font-size: 1.5rem; margin-bottom: 0.75rem;}


/* ==========================================================================
   Estructura Principal (Layout con Sidebar)
   ========================================================================== */
.page-wrapper {
    display: flex;
    flex-grow: 1;
}

.sidebar {
    width: 260px;
    background-color: #2c3e50; /* Azul oscuro/grisáceo */
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
    overflow-y: auto; /* Para scroll si el menú es largo */
}

.sidebar-header {
    padding: 20px 15px;
    text-align: center;
    border-bottom: 1px solid #34495e;
}
.sidebar-logo {
    max-width: 100%;
    height: auto;
    max-height: 80px; /* Ajusta esto si tu logo se ve muy grande o pequeño */
    display: inline-block;
}
.sidebar-header a { text-decoration: none; }

.sidebar-nav ul {
    list-style: none;
}
.sidebar-nav ul li a {
    display: block;
    padding: 14px 20px; /* Ajustado */
    color: #bdc3c7;
    text-decoration: none;
    font-size: 0.95rem;
    border-left: 4px solid transparent; /* Más grueso */
    transition: background-color 0.2s, color 0.2s, border-left-color 0.2s;
}
.sidebar-nav ul li a:hover {
    background-color: #34495e;
    color: #ffffff;
    border-left-color: #3498db;
}
.sidebar-nav ul li a.active {
    background-color: #1f2b38; /* Un poco más oscuro para activo */
    color: #ffffff;
    font-weight: 600;
    border-left-color: #3498db;
}

.main-content {
    flex-grow: 1;
    margin-left: 260px; /* Mismo ancho que el sidebar */
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease-in-out; /* Para animación con menú colapsado */
}

.top-header {
    background-color: #ffffff;
    padding: 12px 25px; /* Ajustado */
    box-shadow: 0 1px 4px rgba(0,0,0,0.08); /* Sombra más suave */
    display: flex;
    align-items: center;
    min-height: 60px; /* Altura mínima */
    /* position: sticky; top: 0; z-index: 900; */ /* Opcional si se quiere pegajoso */
}
.top-header h1 {
    font-size: 1.3rem; /* Ajustado */
    color: #333;
    margin: 0;
    font-weight: 600;
}

#mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #333;
    cursor: pointer;
    margin-right: 15px;
    padding: 5px;
}

.main-content main { /* <main> interno */
    padding: 25px;
    flex-grow: 1;
    background-color: #f4f7f6; /* Fondo del área de contenido */
}

/* El .container ahora es para agrupar contenido DENTRO de .main-content main */
.container {
    width: 100%;
    max-width: 100%; /* Ocupa el ancho del <main> interno */
    margin: 0 auto 25px auto; /* Margen inferior opcional */
    padding: 25px;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-radius: 6px;
}
.container:last-child {
    margin-bottom: 0;
}


/* ==========================================================================
   Dashboard (Público y Admin) - Ajustes para hacerlo más pequeño
   ========================================================================== */
.dashboard-public .charts-grid,
.dashboard-admin .charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Gráficos más estrechos */
    gap: 20px;
}
.dashboard-public .chart-container,
.dashboard-admin .chart-container {
    border: 1px solid #e0e0e0; /* Borde más suave */
    padding: 15px;
    border-radius: 5px;
    background-color: #fff; /* Fondo blanco para cada gráfico */
}
.dashboard-public .chart-container.full-width,
.dashboard-admin .chart-container.full-width {
    grid-column: 1 / -1;
}
.dashboard-public .chart-container canvas,
.dashboard-admin .chart-container canvas {
    width: 100% !important;
    max-height: 280px; /* Altura más pequeña */
}
.dashboard-public .chart-container h3,
.dashboard-admin .chart-container h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    text-align: center;
    color: #444;
    font-weight: 600;
}

/* ==========================================================================
   Formularios
   ========================================================================== */
form div {
    margin-bottom: 1.25rem; /* 20px */
}
label {
    display: block;
    margin-bottom: 0.5rem; /* 8px */
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}
input[type="text"],
input[type="password"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 0.75rem; /* 12px */
    border: 1px solid #ced4da;
    border-radius: 0.25rem; /* 4px */
    font-size: 1rem;
    line-height: 1.5;
    background-color: #fff;
    background-clip: padding-box;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}
textarea {
    min-height: 120px;
    resize: vertical;
}
input[type="file"] {
    padding: 0.5rem 0.75rem; /* Ajuste para input file */
}
button[type="submit"], .button {
    display: inline-block;
    background-color: #007bff;
    color: white;
    padding: 0.75rem 1.25rem; /* 12px 20px */
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
button[type="submit"]:hover, .button:hover {
    background-color: #0056b3;
}

/* Estilos para formularios de acción en tablas (Select + Botón) */
.action-form {
    display: flex;
    align-items: center;
    gap: 5px; /* Espacio entre select y botón */
    max-width: 100%;
}
.action-form select {
    flex: 1; /* El select ocupa el espacio disponible */
    min-width: 0; /* Permite que se encoja si es necesario */
}

/* ==========================================================================
   Tablas
   ========================================================================== */
.table-responsive { /* Contenedor para scroll horizontal en tablas */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.25rem; /* 20px */
    margin-bottom: 1rem;
    font-size: 0.9rem;
    background-color: #fff;
}
th, td {
    border: 1px solid #dee2e6;
    padding: 0.75rem; /* 12px */
    text-align: left;
    vertical-align: middle;
}
th {
    background-color: #e9ecef;
    font-weight: 600;
    color: #495057;
    vertical-align: bottom;
}
tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}
tbody tr:hover {
    background-color: #e2e6ea; /* Un poco más oscuro en hover */
}
td form select, td form button { /* Elementos de formulario en tabla */
    font-size: 0.85rem;
    padding: 0.375rem 0.5rem; /* 6px 8px */
    margin-right: 5px;
}
td form button {
    min-width: 40px; /* Para botones pequeños como "OK" */
}

/* ==========================================================================
   Mensajes y Alertas
   ========================================================================== */
.error, .errors p.error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
}
.errors { /* Contenedor para múltiples errores */
    padding: 0; border: none; background: none;
}
.success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
}

/* ==========================================================================
   Detalles del Evento (página evento.php)
   ========================================================================== */
.evento-detalle {
    margin-bottom: 1.5rem; /* 24px */
    padding: 1.25rem; /* 20px */
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background-color: #fdfdfd;
}
.evento-detalle p {
    margin-bottom: 0.6rem; /* ~10px */
    color: #555;
}
.evento-detalle strong {
    color: #333;
    margin-right: 5px;
}
.evento-detalle img {
    max-width: 100%;
    height: auto;
    margin-top: 1rem;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
}
.evento-detalle hr {
    margin: 1.5rem 0;
    border: 0;
    border-top: 1px solid #eee;
}

/* ==========================================================================
   Indicadores de Estado (para tablas)
   ========================================================================== */
.status-pendiente { background-color: #ffc107; color: #212529; padding: 0.25em 0.5em; border-radius: 0.2em; font-size: 0.8em; display: inline-block; }
.status-en-revisión { background-color: #17a2b8; color: white; padding: 0.25em 0.5em; border-radius: 0.2em; font-size: 0.8em; display: inline-block; }
.status-aprobada { background-color: #28a745; color: white; padding: 0.25em 0.5em; border-radius: 0.2em; font-size: 0.8em; display: inline-block; }
.status-completada { background-color: #6c757d; color: white; padding: 0.25em 0.5em; border-radius: 0.2em; font-size: 0.8em; display: inline-block; }
.status-rechazada { background-color: #dc3545; color: white; padding: 0.25em 0.5em; border-radius: 0.2em; font-size: 0.8em; display: inline-block; }

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
    text-align: center;
    padding: 1.25rem; /* 20px */
    background-color: #2c3e50;
    color: #ecf0f1;
    font-size: 0.9rem;
    width: 100%;
    margin-top: auto; /* Empuja el footer al final si el contenido es corto */
}

/* ==========================================================================
   Responsive (Mobile-first approach adaptado)
   ========================================================================== */

/* Estilos para móvil (por defecto, ya que no hay media query min-width) */
.sidebar {
    transform: translateX(-100%); /* Oculto por defecto en móvil */
    position: fixed;
    height: 100vh;
    z-index: 1000;
}
.sidebar.open {
    transform: translateX(0); /* Visible cuando la clase .open está presente */
}
.main-content {
    margin-left: 0; /* Contenido ocupa todo el ancho en móvil */
    width: 100%;
}
#mobile-menu-toggle {
    display: block; /* Visible en móvil */
}
.top-header h1 { /* Centrar título en móvil si el botón está a la izquierda */
    flex-grow: 1;
    text-align: center;
    margin-right: 40px; /* Espacio para que no choque con el botón si está a la der. */
}

/* Ajuste de color para Móviles: Que la barra superior coincida con la sidebar */
@media (max-width: 991px) {
    .top-header {
        background-color: #2c3e50; /* Mismo azul que la sidebar */
        color: #ffffff;
    }
    .top-header h1 {
        color: #ffffff;
    }
    #mobile-menu-toggle {
        color: #ffffff;
    }
}

/* Tablets y pantallas pequeñas (ej. >= 768px) */
@media (min-width: 768px) {
    .charts-grid {
        /* Podrías querer 2 columnas aquí si no lo hace auto-fit ya */
    }
    .top-header h1 {
        text-align: left; /* Alinear a la izquierda en tablets */
        margin-right: 0;
    }
}


/* Escritorio y pantallas grandes (ej. >= 992px) - Donde el menú lateral es visible */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0); /* Siempre visible */
        position: fixed; /* Fijo */
    }
    .main-content {
        margin-left: 260px; /* Espacio para el sidebar */
    }
    #mobile-menu-toggle {
        display: none; /* Ocultar botón de hamburguesa */
    }
    .top-header h1 {
        flex-grow: 0; /* No necesita crecer */
    }
}

/* Ajustes adicionales para tablas en pantallas muy pequeñas si el método data-label no se usa */
@media (max-width: 600px) {
    /* Si no usas data-labels, esto es un scroll simple */
    .table-responsive {
        /* Ya tiene overflow-x: auto */
    }
    td form, td form select, td form button {
        display: block;
        width: 100%;
        margin-bottom: 5px;
    }
    td form select { margin-right: 0; }
}

/* ==========================================================================
   Tablas Responsivas Tipo Tarjeta (Mejorado para Móvil)
   ========================================================================== */
@media (max-width: 768px) {
    /* Forzar a la tabla y sus partes a comportarse como bloques */
    .table-responsive table, 
    .table-responsive thead, 
    .table-responsive tbody, 
    .table-responsive th, 
    .table-responsive td, 
    .table-responsive tr {
        display: block;
    }
    .main-content main { /* <main> interno */
    padding: 16px;
}
    /* Ocultar las cabeceras de la tabla original (pero mantenerlas accesibles) */
    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Estilo de "Tarjeta" para cada fila */
    .table-responsive tr {
        border: 1px solid #e0e0e0;
        margin-bottom: 15px;
        background-color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        padding: 10px 0;
    }

    /* Estilo para cada celda (ahora fila de la tarjeta) */
    .table-responsive td {
        border: none;
        border-bottom: 1px solid #f0f0f0;
        position: relative;
        padding-left: 45% !important; /* Espacio para la etiqueta a la izquierda */
        text-align: right;
        padding-top: 10px;
        padding-bottom: 10px;
        padding-right: 15px;
        min-height: 40px;
    }

    /* La etiqueta (Label) generada por CSS */
    .table-responsive td:before {
        position: absolute;
        top: 10px;
        left: 15px;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        color: #555;
        content: attr(data-label); /* Toma el texto del atributo HTML */
    }

    .table-responsive td:last-child {
        border-bottom: 0;
    }
    
    /* Ajustes para botones dentro de las tarjetas */
    .table-responsive td form {
        display: inline-block;
        width: auto;
    }
}

/* ==========================================================================
   KPI Cards (Indicadores Clave)
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.kpi-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-left: 5px solid #007bff; /* Color por defecto */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.kpi-card h3 {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}
.kpi-card .number {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
}
.kpi-card.warning { border-left-color: #ffc107; }
.kpi-card.danger { border-left-color: #dc3545; }
.kpi-card.success { border-left-color: #28a745; }

/* ==========================================================================
   Estilos de Impresión (Exportar a PDF)
   ========================================================================== */
@media print {
    .sidebar, .top-header, .no-print, footer {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    .container {
        box-shadow: none;
        border: none;
        padding: 0;
        max-width: 100%;
    }
    body {
        background-color: #fff;
    }
    .chart-container {
        break-inside: avoid; /* Evita que un gráfico se corte entre páginas */
    }
}