/* =====================================================
   VARIABLES GLOBALES
===================================================== */
:root {
    /* Altura del header (responsiva) */
    --header-h: clamp(120px, 15vh, 180px);

    /* Altura del footer (responsiva) */
    --footer-h: clamp(60px, 10vh, 100px);

    /* Espacio vertical entre secciones principales */
    --content-gap: 20px;

    /* Paleta de colores del sistema */
    
    --azul: #007bff;            /* Color principal / marca */
    --rojo: #e10600;            /* Color principal / marca */
    --amarillo: #ffd400;        /* Color secundario */
    --amarillo-hover: #ffb600;  /* Hover para botones amarillos */
    --verde: #2ecc71;           /* Estados positivos / OK */
    --gris-claro: #f9f9f9;      /* Fondo general */
    --gris-borde: #dddddd;      /* Bordes y separadores */
    --blanco: #ffffff;          /* Fondos y contenedores */
    --negro: #000000;           /* Texto oscuro */
}


/* =====================================================
   RESET + BODY (NUNCA SCROLL)
===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: Arial, sans-serif;
    background-color: var(--gris-claro);
    overflow: hidden;
}

/* =====================================================
   LAYOUT PRINCIPAL
===================================================== */
.app-layout {
    height: 100vh;
    display: grid;
    grid-template-rows: var(--header-h) 1fr;
    gap: var(--content-gap);
}

/* =========================
   HEADER
========================= */

.site-header {
    background-color: var(--blanco);   /* Color de fondo del header */
    border-bottom: 6px solid var(--azul); /* Línea roja inferior decorativa */
    padding: 0 32px;                   /* Espacio interno horizontal */
    z-index: 10;                       /* Prioridad visual sobre otros elementos */
}

.header-grid {
    height: 100%;                      /* Usa toda la altura del header */
    display: grid;                     /* Activa CSS Grid */
    grid-template-columns: auto 1fr auto; /* Izquierda, centro flexible, derecha */
    align-items: center;               /* Centra verticalmente los elementos */
}

.header-left {
    display: flex;                     /* Usa Flexbox */
    flex-direction: column;            /* Elementos en columna */
    gap: 6px;                          /* Separación entre elementos */
    font-weight: 600;                  /* Texto semi-negrita */
}

.header-center {
    text-align: center;                /* Centra el texto horizontalmente */
}

.brand-title {
    font-size: 2.8rem;                 /* Tamaño grande del texto */
    font-weight: 900;                  /* Texto muy grueso */
    color: var(--rojo);                /* Color rojo de la marca */
    text-decoration: none;             /* Quita subrayado del enlace */
}

.header-right {
    display: flex;                     /* Flexbox para alineación horizontal */
    align-items: center;               /* Centra verticalmente los elementos */
    gap: 12px;                         /* Espacio entre elementos */
}

.logo {
    height: 110px;                     /* Altura fija del logo */
    width: auto;                       /* Mantiene proporción */
    object-fit: contain;               /* Evita deformación de la imagen */
    animation: logoFadeIn 0.9s ease-out both; /* Animación de aparición suave */
}


/* =====================================================
   MAIN (ÚNICO SCROLL GLOBAL)
===================================================== */
.app-main {
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}

/* =====================================================
   POS LAYOUT
===================================================== */
.pos-layout {
    display: grid;
    grid-template-columns: 65% 35%;
    gap: 20px;
    min-height: 0;
}

.pos-left,
.pos-right {
    background-color: var(--blanco);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.1);
    overflow: auto;
    min-height: 0;
}

.autocomplete-box {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    z-index: 999;
}

.autocomplete-item {
    padding: 8px;
    cursor: pointer;
}

.autocomplete-item:hover {
    background: #f0f0f0;
}


/* =====================================================
   TÍTULOS
===================================================== */
h1 {
    text-align: center;
    color: var(--rojo);
    font-size: 2.4rem;
    margin-bottom: 20px;
}

h3 {
    margin-bottom: 15px;
}

/* =====================================================
   TABLAS
===================================================== */
table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--rojo);
    color: var(--blanco);
}

th, td {
    padding: 12px;
    border-bottom: 1px solid var(--gris-borde);
}

/* =====================================================
   BOTONES UNIFICADOS
===================================================== */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 30px;
    min-width: 150px;
    border-radius: 12px;
    font-weight: 800;
    border: none;
    cursor: pointer;
    transition: all .15s ease;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,.15);
}

.btn-add { background: #5b8db8; }
.btn-edit { background: #6f8fbf; }
.btn-delete { background: #c0392b; color: #fff; }

/* =====================================================
   MODAL
===================================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal.active {
    display: flex;
}

/* =====================================================
   RESPONSIVE
===================================================== */
@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }

    .brand-title {
        font-size: 2rem;
    }
}
/* =====================================================
   VENTA OK
===================================================== */

.venta-ok {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}


/* =====================================================
   INVENTARIO.php (TABLA FULL WIDTH SIN SCROLL HORIZONTAL)
===================================================== */

.actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.buscador {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.buscador input {
    padding: 10px;
    width: 260px;
    border-radius: 8px;
    border: 1px solid var(--gris-borde);
}

/* CONTENEDOR DE TABLA */
.tabla-wrapper {
    width: 100%;
    background: var(--blanco);
    border-radius: 12px;
    box-shadow: 0 6px 14px rgba(0,0,0,.08);
    overflow-x: hidden;      /* 🔴 elimina scroll horizontal */
    overflow-y: auto;
}

/* TABLA AJUSTADA A PANTALLA */
.tabla-wrapper table {
    width: 100%;
    table-layout: fixed;     /* 🔑 clave para no desbordar */
    border-collapse: collapse;
}

/* ENCABEZADO */
.tabla-wrapper thead {
    background-color: var(--rojo);
    color: var(--blanco);
}

/* CELDAS */
.tabla-wrapper th,
.tabla-wrapper td {
    padding: 8px 6px;
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 1px solid var(--gris-borde);

    /* EVITA DESBORDE */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* CONTROL DE COLUMNAS PROBLEMÁTICAS */
.tabla-wrapper td:nth-child(3),  /* Artículo */
.tabla-wrapper td:nth-child(4),  /* Proveedor */
.tabla-wrapper td:nth-child(10), /* Locación */
.tabla-wrapper td:nth-child(11)  /* Lote */ {
    max-width: 160px;
}

/* IMÁGENES */
.tabla-wrapper img {
    width: 36px;
    height: auto;
    max-width: 100%;
    border-radius: 6px;
    display: block;
    margin: auto;
}

/* =====================================================
   MODALES INVENTARIO 
===================================================== */

.modal-content {
    background: var(--blanco);
    padding: 30px;
    border-radius: 0;

    width: 70%;
    max-width: 100vw;

    max-height: 95vh;      /* Usa viewport, no porcentajes */
    overflow-y: auto;      /* Scroll vertical si es necesario */
    overflow-x: hidden;    /* Evita scroll horizontal */
}
.modal-content {
    box-sizing: border-box;
}




.modal-content input,
.modal-content select {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid var(--gris-borde);
}

.acciones-form {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.hidden {
    display: none;
}

.danger {
    color: #c0392b;
}

/* =====================================================
   FORMULARIOS INVENTARIO
===================================================== */

.form-row {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.campo {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.campo label {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.campo input,
.campo select {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: #f9fafb;
    transition: border 0.18s, box-shadow 0.18s;
}

.campo input:focus,
.campo select:focus {
    border-color: #5e87af;
    box-shadow: 0 0 0 3px rgba(94,135,175,0.12);
    outline: none;
}
/* =====================================================
   INVENTARIO – AJUSTE DE ANCHOS CLAVE
===================================================== */

.tabla-wrapper table {
    table-layout: fixed;
}

/* CÓDIGO */
.tabla-wrapper th:nth-child(2),
.tabla-wrapper td:nth-child(2) {
    width: 12%;
}

/* ARTÍCULO */
.tabla-wrapper th:nth-child(3),
.tabla-wrapper td:nth-child(3) {
    width: 20%;
}

/* PROVEEDOR */
.tabla-wrapper th:nth-child(4),
.tabla-wrapper td:nth-child(4) {
    width: 14%;
}

/* ESTADO */
.tabla-wrapper th:nth-child(12),
.tabla-wrapper td:nth-child(12) {
    width: 10%;
}

/* COLUMNAS SECUNDARIAS MÁS COMPACTAS */

.tabla-wrapper th:nth-child(8),
.tabla-wrapper td:nth-child(8),   /* Mín */
.tabla-wrapper th:nth-child(9),
.tabla-wrapper td:nth-child(9)    /* Cant */
{
    width: 5%;
}
.tabla-wrapper th:nth-child(1),
.tabla-wrapper td:nth-child(1),   /* Sitio */
.tabla-wrapper th:nth-child(5),
.tabla-wrapper td:nth-child(5),   /* Compra */
.tabla-wrapper th:nth-child(6),
.tabla-wrapper td:nth-child(6),   /* Venta */
.tabla-wrapper th:nth-child(7),
.tabla-wrapper td:nth-child(7)    /* Utilidad */
{
    width: 6%;
}

/* LOCACIÓN Y LOTE */
.tabla-wrapper th:nth-child(10),
.tabla-wrapper td:nth-child(10),
.tabla-wrapper th:nth-child(11),
.tabla-wrapper td:nth-child(11) {
    width: 8%;
}

/* IMAGEN */
.tabla-wrapper th:nth-child(13),
.tabla-wrapper td:nth-child(13) {
    width: 6%;
}

/* =====================================================
   POS - TABLA CON 15 RENGLONES
===================================================== */

.pos-table-wrapper {
    max-height: 480px;           /* ~15 renglones */
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid var(--gris-borde);
}

/* Header fijo mientras haces scroll */
.pos-table-wrapper thead th {
    position: sticky;
    top: 0;
    background-color: var(--rojo);
    color: var(--blanco);
    z-index: 5;
}

/* Ajuste visual para filas del POS */
.pos-table-wrapper th,
.pos-table-wrapper td {
    padding: 10px 12px;
    font-size: 0.95rem;
}

.pos-table-wrapper thead th {
    position: sticky;
    top: 0;
}

/* =====================================================
   BOTÓN ELIMINAR MINI (POS)
===================================================== */
.btn-delete {
    padding: 4px 8px;
    min-width: auto;
    font-size: 0.75rem;
    border-radius: 6px;
    line-height: 1;
}



