/* 
    K15 - ESTÉTICA PREMIUM & SCROLL ESTABLE (v2.9)
    Combinando diseño moderno con solución técnica de desplazamiento.
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --primary: #1e3a8a;
    --primary-light: #2563eb;
    --accent: #f59e0b;
    --bg-light: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --white: #ffffff;
    --sidebar-width: 260px;
    --topbar-height: 70px;
    --success: #10b981;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius-lg: 16px;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent; 
}

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    overflow: hidden; /* Scroll gestionado por view-port */
}

body {
    display: flex;
}

/* SIDEBAR REFINADO */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e3a8a 0%, #172554 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    height: 100vh;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3000; /* Superior al overlay (2000) */
    box-shadow: 10px 0 30px rgba(0,0,0,0.3);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-toggle {
    background: transparent !important;
    color: white !important;
    border: none !important;
    font-size: 1.5rem !important;
    padding: 10px !important;
    box-shadow: none !important;
}

.sidebar-logo {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #fff;
}

.version-badge {
    font-size: 0.65rem;
    background: rgba(255,255,255,0.15);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 10px;
    font-weight: 400;
    opacity: 0.8;
}

.nav-group {
    padding: 20px 12px;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.nav-item .icon { font-size: 1.2rem; margin-right: 12px; }

/* MAIN WRAPPER */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    background: var(--bg-light);
}

/* TOP BAR ELEGANTE */
.top-bar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    z-index: 900;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

/* VIEW PORT - MOTOR DE SCROLL ESTABLE */
.view-port {
    position: absolute;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 30px;
    -webkit-overflow-scrolling: touch;
}

/* DISEÑO DE TARJETAS (CARDS) */
.card-form {
    background: var(--white);
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 25px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: transform 0.2s ease;
}

/* BOTONES MODERNOS */
.btn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
}

.btn:active { transform: scale(0.96); }

.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 6px -1px rgba(30, 58, 138, 0.2); }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }

.btn-accent { background: var(--accent); color: white; }
.btn-ghost { background: #f1f5f9; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: #e2e8f0; color: var(--text-main); }

.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

.btn-success { background: var(--success); color: white; }

/* TABLAS REFINADAS */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; padding: 15px; font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); text-align: left; }
td { padding: 15px; border-top: 1px solid #f1f5f9; font-size: 0.95rem; }

/* SEARCH BOX */
.search-box {
    width: 100%;
    padding: 12px 18px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
    background: #fff;
}
.search-box:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* PRODUCT CARD PREMIUM */
.product-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 20px;
    border: 1px solid #eef2f6;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -5px rgba(0,0,0,0.08);
    border-color: var(--primary-light);
}

.product-card .action-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f1f5f9;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
}

.product-card .action-btn:hover {
    background: var(--primary);
    color: white;
}

.product-card .prod-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: #f8fafc;
    padding: 4px 10px;
    border-radius: 6px;
    width: fit-content;
}

.product-card .prod-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    margin-top: 5px;
}

.product-card .prod-prices {
    background: #f8fafc;
    padding: 12px;
    border-radius: 12px;
    margin-top: 5px;
}

.product-card .prod-price-main {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.product-card .prod-price-sub {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.product-card.low-stock {
    border-left: 5px solid var(--danger);
}

/* RESPONSIVIDAD MÓVIL Y TABLET (HASTA 1024PX) */
@media (max-width: 1024px) {
    .sidebar { 
        position: fixed; 
        left: -260px; 
        height: 100vh; 
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.active { 
        left: 0; 
    }
    .main-wrapper {
        margin-left: 0;
    }
    .top-bar { 
        padding: 0 15px; 
    }
    .view-port { 
        padding: 15px; 
        top: 70px;
    }
    .mobile-only { display: block !important; }
    
    .grid-list {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

.mobile-only { display: none; }
.hidden { display: none !important; }

/* OVERLAYS & MODALS */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}
.modal-content {
    background: white; padding: 30px; border-radius: 20px;
    width: 95%; max-width: 550px;
    animation: slideUp 0.3s ease-out;
}

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

/* SISTEMA DE NOTIFICACIONES (TOAST) */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    color: white;
    border-radius: 12px;
    z-index: 9999;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
