/**
 * ============================================================
 * FRONTEND: principal.css
 * Rol:    Hoja de estilos principal del sistema.
 *          Define colores, layout (sidebar/main), tablas,
 *          formularios, botones y utilidades responsive.
 * ============================================================
 */

/* ------------------- Variables de color ------------------- */
:root {
    --c-prim:  #AC5300;
    --c-borde: #CCC;
    --c-fondo: #e8e8e8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Arial, sans-serif; font-size: 13px; background: var(--c-fondo); color: #222; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ------------------- Layout principal: sidebar, main, topbar ------------------- */
#wrap { display: flex; min-height: 100vh; }
#sidebar { width: 210px; background: var(--c-prim); color: #fff; position: fixed; top:0; left:0; bottom:0; overflow-y: auto; }
.sidebar-titulo { padding: 18px; text-align: center; font-weight: bold; border-bottom: 1px solid rgba(255,255,255,0.25); }
.logo-sidebar { max-width: 100%; height: auto; }
.sidebar-nav a { display: block; padding: 12px 18px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-nav a.activo, .sidebar-nav a:hover { background: rgba(0,0,0,0.15); }

#main { margin-left: 210px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
#topbar {
    background: #fff;
    border-bottom: 1px solid var(--c-borde);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
#contenido { padding: 18px 20px; flex: 1; }

/* ------------------- Topbar: titulo, usuario y rol ------------------- */
.topbar-titulo { font-size: 15px; font-weight: bold; color: var(--c-prim); }
.topbar-usuario {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #555;
    font-weight: normal;
}
.topbar-rol {
    background: #f0f4ff;
    color: #1a56c4;
    padding: 2px 8px;
    border: 1px solid #c5d4f5;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

/* ------------------- Encabezados y tarjetas ------------------- */
.pag-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.pag-titulo { font-size: 18px; font-weight: bold; }

.card { background: #fff; border: 1px solid var(--c-borde); border-radius: 6px; padding: 18px; margin-bottom: 16px; }
.filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    justify-content: space-between;
    background: #fff;
    padding: 12px;
    border: 1px solid var(--c-borde);
    border-radius: 6px;
    margin-bottom: 16px;
}
.filtro-izq, .filtro-der {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}
.filtro-der { margin-left: auto; }
.filtro-col { display: flex; flex-direction: column; }
.filtro-col label, .campo label { font-size: 11px; color: #555; margin-bottom: 3px; font-weight: bold; }

/* ------------------- Campos, grids y formularios ------------------- */
.campo { margin-bottom: 10px; }
.campos-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.campos-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.campos-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }

input, select, textarea { padding: 6px 8px; border: 1px solid var(--c-borde); border-radius: 4px; width: 100%; }
input[readonly] { background: #f5f5f5; }

/* ------------------- Botones ------------------- */
.btn { display: inline-block; padding: 7px 14px; border: none; border-radius: 4px; text-decoration: none; cursor: pointer; color: #fff; }
.btn-primario { background: #AC5300; }
.btn-verde    { background: #28a745; }
.btn-rojo     { background: #dc3545; }
.btn-gris     { background: #e9ecef; color: #333; font-weight: 600; border: 1px solid #ced4da; }
.btn-icono    { background: transparent; color: #333; padding: 4px 8px; }

/* ------------------- Tablas ------------------- */
.tabla-wrap { background: #fff; border: 1px solid var(--c-borde); border-radius: 6px; padding: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #eee; }
th { background: var(--c-prim); color: #fff; font-weight: bold; }
.tabla-vacia { padding: 20px; color: #777; font-style: italic; }

/* ------------------- Renglones de detalle en movimientos ------------------- */
.renglon { border: 1px solid var(--c-borde); border-radius: 4px; padding: 10px; margin-bottom: 10px; background: #fafafa; }

/* ------------------- Badges y etiquetas de estado ------------------- */
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; color: #fff; }
.badge-verde    { background: #28a745; }
.badge-azul     { background: #007bff; }
.badge-rojo     { background: #dc3545; }
.badge-amarillo { background: #ffc107; color: #333; }
.badge-gris     { background: #6c757d; }
.badge-peligrosidad { background: #f2f2f2; color: #444; border: 1px solid #d4d4d4; margin-right: 4px; margin-bottom: 2px; }
.btn-hds { font-size: 12px; padding: 4px 10px; white-space: nowrap; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; max-width: 220px; cursor: pointer; }
.btn-hds.hds-pendiente { opacity: 0.7; cursor: default; pointer-events: none; }

/* ------------------- Notificaciones ------------------- */
.notif-ok, .notif-error, .notif-warn { padding: 10px 12px; border-radius: 4px; margin-bottom: 14px; }
.notif-ok    { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.notif-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.notif-warn  { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

.acciones { white-space: nowrap; }

/* ------------------- Pantalla de login ------------------- */
#pagina-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fondo de la pantalla de login: imagen a pantalla completa,
       cubriendo todo el area del navegador sin importar el tamano. */
    background: url('../imagenes/IMG_5616.webp') no-repeat center center fixed;
    background-size: cover;
}
.login-caja { background: #fff; padding: 30px 40px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); min-width: 320px; }
.login-caja h2 { color: var(--c-prim); margin-bottom: 18px; font-size: 18px; text-align: center; }
.login-logo { text-align: center; margin-bottom: 18px; }
.logo-login { max-width: 220px; height: auto; }
.grupo { color: #fff; font-size: 11px; font-weight: bold; padding: 10px 18px 4px; opacity: 0.7; }
.sidebar-alertas { background: #dc3545; color: #fff; border-radius: 50%; padding: 2px 7px; font-size: 11px; margin-left: 6px; }

/* ------------------- Ajustes responsive ------------------- */
@media (max-width: 900px) {
    .campos-2, .campos-3, .campos-4 { grid-template-columns: 1fr; }
    #sidebar { display: none; }
    #main { margin-left: 0; }
}

/* ------------------- Modal reutilizable (logout / validaciones) ------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.modal-overlay.activo { display: flex; }
.modal-contenido {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
}
.modal-mensaje { margin-bottom: 20px; font-size: 16px; }
.modal-botones { display: flex; justify-content: center; gap: 15px; }

/* ------------------- Tablero: dos tablas lado a lado ------------------- */
.tablas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* ------------------- Paginacion client-side ------------------- */
.paginacion {
    background: #fafafa;
    border: 1px solid var(--c-borde);
    border-top: none;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    font-size: 12px;
    color: #555;
}
.paginacion-info { white-space: nowrap; }
.paginacion-botones { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.paginacion-botones .btn { padding: 4px 10px; font-size: 12px; }
.paginacion-botones .btn[disabled] { opacity: 0.45; cursor: default; pointer-events: none; }
.paginacion-pagina { white-space: nowrap; font-weight: bold; color: var(--c-prim); }
@media (max-width: 768px) {
    .tablas-grid { grid-template-columns: 1fr; }
    .paginacion { justify-content: center; text-align: center; }
}

/* ------------------- Icono de informacion (validaciones) ------------------- */
.info-icono {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    vertical-align: middle;
    cursor: pointer;
}

