/* ==========================================================================
   ORIGENWEB ERP - MODERN & MINIMALIST STYLESHEET (2026 REBRAND)
   ========================================================================== */

:root {
    --primary: #0168ff;       /* Azul Vibrante de Marca */
    --secondary: #232323;     /* Textos y elementos oscuros */
    --bg-warm: #f9e8ce;       /* Fondo 1 (Crema Cálido) */
    --bg-light: #f5f5f5;      /* Fondo 2 (Gris Claro Limpio) */
    --white: #ffffff;
    --success: #10b981;       /* Esmeralda moderno */
    --danger: #ef4444;        /* Rojo moderno */
    --warning: #f59e0b;       /* Ámbar */
    --border: #e5e7eb;
    --radius: 12px;           /* Bordes más suaves y modernos */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box !important; /* Forzamos control total sobre paddings */
    margin: 0;
    padding: 0;
}

body {
    font-family: '-apple-system', BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--secondary);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* Evita cualquier micro-desborde involuntario en el body */
}

/* --- Layout Base de Escritorio --- */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

/* --- Layout Base de Contenido Unificado y Centrado --- */
main {
    flex-grow: 1;
    padding: 100px 0 0 0; /* 30px de separación arriba para que respire con el header */
    max-width: 1400px;
    
    /* ELIMINADOS los desfases de 260px del antiguo sidebar */
    margin: 0 auto;              /* <-- CENTRA el contenedor perfectamente en la pantalla */
    width: 100%;                 /* <-- Toma todo el ancho disponible elásticamente */
    
    transition: var(--transition);
    box-sizing: border-box !important;
}

/* ==========================================================================
   SOPORTE DE ADAPTABILIDAD RESPONSIVA (MÓVILES)
   ========================================================================== */
   
   
   .ny-pauno{display:flex;gap:10px;}
   
@media (max-width: 768px) {
    body {
        flex-direction: column !important;
    }

    main {
        margin: 0 auto !important;  /* Mantiene el centrado en pantallas pequeñas */
        padding: 90px 16px 20px 16px !important; /* Espaciado interno cómodo para el dedo en el celular */
        width: 100% !important;
        max-width: 100vw !important;
    }

    .ny-pauno{display:grid;gap:10px;}
}

/* --- Tarjetas (Cards) Modernas --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.02);
    margin-bottom: 25px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* --- Métricas (Grid de Cifras) --- */
.dashboard-resumen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--border);
    transition: var(--transition);
}
.metric-card.primary { border-left-color: var(--primary); }
.metric-card.success { border-left-color: var(--success); }
.metric-card.danger { border-left-color: var(--danger); }

.metric-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 8px;
}
.metric-card p {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--secondary);
}

/* --- Formularios y Entradas Minimalistas --- */
select, input[type="text"], input[type="number"], input[type="date"], textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--secondary);
    background-color: var(--white);
    transition: var(--transition);
    outline: none;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(1, 104, 255, 0.15);
}

/* --- Botones Efecto Premium --- */
.btn-nuevo, button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--white);
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.btn-nuevo:hover, button[type="submit"]:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-nuevo:active, button[type="submit"]:active {
    transform: translateY(0);
}

/* --- Tablas Limpias --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

table th {
    background-color: #fafafa;
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

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

/* --- Badges Estilizados --- */
.badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 50px;
    text-align: center;
}
.badge-success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-danger { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* --- Modales Modernas --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(35, 35, 35, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--white);
    margin: 10% auto;
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    animation: slideUp 0.3s ease-out;
}

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

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}
.close:hover { color: var(--secondary); }

/* --- Botones de Acción Iconos Puros (20px) --- */
.btn-icon-only {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.btn-icon-only img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    transition: var(--transition);
}
.btn-icon-only:hover { transform: scale(1.1); }
.btn-icon-only:hover img { opacity: 0.8; }
.btn-icon-only:active { transform: scale(0.95); }

/* --- Sidebar Links --- */
.nav-link {
    display: block;
    padding: 12px 14px;
    color: #d4d4d4;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: var(--transition);
}
.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
    padding-left: 18px; 
}
.nav-link.active {
    background: var(--primary) !important;
    color: var(--white) !important;
    font-weight: 600;
}


/* ==========================================================================
   SOPORTE DE ADAPTABILIDAD RESPONSIVA (MÓVILES CRUCIALES < 768PX)
   ========================================================================== */
@media (max-width: 768px) {
    body {
        flex-direction: column !important; /* Apila el menú arriba y el main abajo */
    }

    /* CRUCIAL: Reseteo de márgenes de escritorio para liberar el viewport */
    .sidebar {
        position: sticky !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 10px 15px !important;
        margin: 0 !important;
        top: 0;
        z-index: 999;
        overflow: hidden !important;
    }

   

    .dashboard-resumen {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* Estructura del menú horizontal interno */
    .sidebar > div:first-child {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        gap: 15px !important;
    }
    
    .sidebar > div:first-child > div:first-child {
        margin-bottom: 0 !important;
        padding-left: 0 !important;
        flex-shrink: 0 !important;
    }

    .sidebar > div:first-child > div:first-child img {
        max-width: 100px !important;
    }

    .sidebar > div:first-child > div:first-child div {
        display: none !important; /* Oculta letrero Admin para ganar UI */
    }
    
    /* Carrusel Touch de los botones de navegación */
    .sidebar nav {
        display: flex !important;
        flex-direction: row !important;
        gap: 6px !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0px !important;
        flex-grow: 1 !important;
    }
    
    .nav-link {
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        display: inline-block !important;
    }

    .nav-link:hover {
        padding-left: 12px !important; /* Bloquea desplazamiento errático en touch */
    }
    
    .sidebar > div:last-child {
        display: none !important;
    }

    /* Transformación de Tablas a Tarjetas UI Verticales */
    table thead {
        display: none !important;
    }
    
    table, table tbody, table tr, table td {
        display: block !important;
        width: 100% !important;
    }

    table tr {
        background: var(--white);
        margin-bottom: 16px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px;
        box-shadow: var(--shadow);
    }

    table td {
        text-align: right !important;
        padding: 10px 8px !important;
        position: relative;
        border-bottom: 1px solid #f3f4f6;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    table td:last-child {
        border-bottom: none !important;
        justify-content: flex-end !important;
        padding-top: 14px;
    }

    /* Inyección responsiva mediante atributos data-label */
    table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.85rem;
        text-align: left;
    }

    /* Ajuste de espaciado táctil para iconos puros */
    td[data-label="Acciones"] div, td[data-label="Acción"] div {
        justify-content: flex-end !important;
        gap: 18px !important;
    }
}