@import url('https://fonts.googleapis.com/css2?family=League+Spartan:wght@100..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

:root {
    /* Backgrounds - Flat Dark Mode with new palette */
    --background: #0B0119; /* Deep Black-Plum */
    
    /* Solid dark backgrounds for cards and surfaces */
    --card-bg: #020e17; /* Very Dark Ocean Blue */
    --surface: #020e17; /* Very Dark Ocean Blue */
    --surface-card: #020e17; /* Very Dark Ocean Blue */
    --surface-elevated: #052137; /* Dark Ocean Blue */
    --surface-hover: rgba(210, 200, 221, 0.08); /* Lavender Plum with opacity */

    /* Core premium primary palette (Monochrome base & Dimmed Plum accents) */
    --primary: #020e17; /* Very Dark Ocean Blue */
    --primary-light: #052137; /* Dark Ocean Blue */
    --primary-dark: #0B0119; /* Deep Black-Plum */
    --accent-color: #D2C8DD; /* Lavender Plum */
    
    /* Dark secondary neutrals */
    --secondary: #020e17; /* Very Dark Ocean Blue */
    --secondary-light: #052137; /* Dark Ocean Blue */
    --text-on-primary: #FFFFFF; /* White */
    
    /* Semantics (Customized to fit the new style) */
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #052137; /* Dark Ocean Blue */
    
    /* High contrast text */
    --text: #FFFFFF; /* White */
    --text-primary: #FFFFFF; /* White */
    --text-light: #D2C8DD; /* Lavender Plum */
    --text-secondary: #D2C8DD; /* Lavender Plum */
    --text-muted: #6B5A7C; /* Muted Plum */
    
    /* Crisp clean borders and dividers */
    --border: rgba(210, 200, 221, 0.15); /* Lavender Plum with opacity */
    --border-color: rgba(210, 200, 221, 0.15);
    --border-light: rgba(210, 200, 221, 0.08);
    --border-dark: rgba(210, 200, 221, 0.25);
    
    /* Shadows for dark mode */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.45), 0 10px 10px -5px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
    
    /* Modern rounded borders */
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    
    --focus-ring: 0 0 0 3px rgba(210, 200, 221, 0.25); /* Lavender Plum glow */
    --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-slow: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

body {
    background-color: var(--background);
    color: var(--text-primary);
}

* {
    font-family: 'Poppins', sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .page-title, .logo, .nav-section-title, .stat-value, .kpi-value {
    font-family: 'League Spartan', sans-serif;
    color: var(--text-primary);
}


.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: var(--primary);
    color: var(--text-on-primary);
    padding: 1rem 1rem 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}
.sidebar:hover { overflow-y: auto; }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-on-primary);
    text-decoration: none;
    flex-shrink: 0;
}

.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.25rem;
}
.nav-menu::-webkit-scrollbar { width: 3px; }
.nav-menu::-webkit-scrollbar-track { background: transparent; }
.nav-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section { margin-bottom: 1rem; }
.nav-section-title {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.45);
    padding: 0 0.75rem;
    margin-bottom: 0.35rem;
}

.nav-item { margin-bottom: 0.15rem; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all var(--transition);
    font-weight: 500;
    font-size: 0.8rem;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-on-primary);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-on-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Main Content */
.main-content {
    padding: 2rem;
    overflow-y: auto;
    background: var(--background);
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

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

/* Widgets & Cards */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    color: var(--text);
    transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

/* Punto de Equilibrio Widget */
.be-widget {
    background: var(--surface-elevated);
    position: relative;
    overflow: hidden;
}

.be-progress-container {
    height: 12px;
    background: var(--secondary);
    border-radius: 6px;
    margin: 1.5rem 0;
    position: relative;
}

.be-progress-bar {
    height: 100%;
    background: var(--accent-color);
    border-radius: 6px;
    transition: width 1s ease-out;
}

.be-marker {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 20px;
    background: var(--danger);
    z-index: 10;
}

.be-marker::after {
    content: 'Meta';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    color: var(--danger);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.transition {
    transition: all var(--transition);
}

/* Glass Card */
.glass-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.form-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}
.form-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.form-group.span-2 {
    grid-column: span 2;
}
.form-group.checkbox-group {
    flex-direction: row;
    align-items: center;
    height: 100%;
    padding-top: 1.5rem;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
}
.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.form-label.required::after {
    content: ' *';
    color: var(--danger);
}
.form-input, .input-text, .input-select {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--surface);
    color: var(--text);
}
.form-input:focus, .input-text:focus, .input-select:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}
.btn-secondary {
    background: var(--secondary);
    color: var(--text);
}
.btn-secondary:hover {
    background: var(--secondary-light);
    transform: translateY(-1px);
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
}
.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}
.btn-icon {
    padding: 0.5rem;
    border-radius: 6px;
    aspect-ratio: 1;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.table-premium {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}
.table-premium th {
    background: var(--surface-hover);
    padding: 12px 16px;
    border-bottom: 2px solid var(--border);
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}
.table-premium td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table-premium tr:hover {
    background: var(--surface-hover);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 58, 95, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}
.modal-container {
    background: var(--surface-elevated);
    border-radius: var(--radius);
    width: 90%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}
.modal-body {
    padding: 1.5rem;
}
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Badges */
.badge-premium {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.badge-soft-success {
    background: rgba(34,197,94,0.1);
    color: var(--success);
    border: 1px solid rgba(34,197,94,0.2);
}
.badge-soft-primary {
    background: rgba(30,58,95,0.1);
    color: var(--primary);
    border: 1px solid rgba(30,58,95,0.2);
}
.badge-soft-muted {
    background: var(--surface-hover);
    color: var(--text-light);
    border: 1px solid var(--border);
}
.badge-soft-danger {
    background: rgba(239,68,68,0.1);
    color: var(--danger);
    border: 1px solid rgba(239,68,68,0.2);
}

/* Dual Column Layout */
.dual-pane {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}
.pane-left {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.pane-right {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}
.search-box {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.list-scrollable {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}
.list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    margin-bottom: 0.5rem;
}
.list-item:hover {
    background: var(--surface-hover);
    border-color: var(--border);
}
.list-item.active {
    background: rgba(30,58,95,0.08);
    border-color: rgba(30,58,95,0.2);
    color: var(--primary);
}

/* Context Bar */
.context-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.context-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.context-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
}

/* Dropzone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.drop-zone:hover, .drop-zone.drop-active {
    border-color: var(--primary);
    background: rgba(30, 58, 95, 0.02);
}
.drop-zone svg {
    width: 48px;
    height: 48px;
    color: var(--text-light);
}

/* Stats Row */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-mini-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.stat-mini-card:hover {
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Premium Global Shadow, Border, and Depth Overrides (ERP Visual Overhaul)
   ========================================================================== */
.card, .glass-card, .pr-card, .kpi-card, .mod-tile, .table-wrapper, .pane-left, .pane-right, .stat-mini-card {
    box-shadow: var(--shadow-sm) !important;
    border: 1px solid var(--border-color) !important;
    background: var(--surface) !important;
    border-radius: var(--radius) !important;
    transition: all var(--transition) !important;
}

/* Hover only on interactive components, never on structural containers like wrappers and panes */
.kpi-card:hover, .mod-tile:hover, .stat-mini-card:hover, .card:hover, .pr-card:hover {
    box-shadow: var(--shadow-md) !important;
    transform: translateY(-4px) scale(1.008) !important;
    border-color: var(--accent-color) !important;
}
.table-wrapper:hover, .pane-left:hover, .pane-right:hover {
    box-shadow: var(--shadow-md) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* Enhancing general input and select fields inside the ERP */
.form-input, .input-text, .input-select, .modern-input, select[id*="Select"], .form-group input, .form-group textarea, .form-group select, .pr-search input, .search-input {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--surface-elevated) !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02) !important;
    padding: 0.6rem 0.85rem !important;
    transition: all var(--transition) !important;
    color: var(--text-primary) !important;
}

.form-input:focus, .input-text:focus, .input-select:focus, .modern-input:focus, select[id*="Select"]:focus, .form-group input:focus, .form-group textarea:focus, .form-group select:focus, .pr-search input:focus, .search-input:focus {
    border-color: var(--primary-light) !important;
    background: var(--surface) !important;
    box-shadow: var(--focus-ring) !important;
    outline: none !important;
}

/* Tables visual enhancements */
.table-premium th, #ultimasVentasTable th, table.kardex-table th {
    background: var(--surface-elevated) !important;
    border-bottom: 2px solid var(--border-color) !important;
    padding: 12px 16px !important;
    font-weight: 700 !important;
    color: var(--text-light) !important;
}

.table-premium td, #ultimasVentasTable td, table.kardex-table td {
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border-light) !important;
}

/* Modals premium flat shadow overlay (no glassmorphism) */
.modal-overlay {
    background: rgba(2, 6, 17, 0.8) !important;
    backdrop-filter: none !important;
}

.modal-container {
    box-shadow: var(--shadow-xl) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
}

/* Global Overrides to Strip Away Gradients (Forced flat fallback colors) */
.bg-gradient-to-r {
    background-image: none !important;
}
.from-rose-600.to-red-600 {
    background-color: var(--danger) !important;
}
.hover\:from-rose-500.hover\:to-red-500:hover {
    background-color: #dc2626 !important;
}
.from-indigo-600.to-violet-600 {
    background-color: #4f46e5 !important;
}
.hover\:from-indigo-500.hover\:to-violet-500:hover {
    background-color: #3730a3 !important;
}
.from-emerald-600.to-teal-600 {
    background-color: var(--success) !important;
}
.hover\:from-emerald-500.hover\:to-teal-500:hover {
    background-color: #059669 !important;
}
.from-amber-600.to-orange-600 {
    background-color: var(--warning) !important;
}
.hover\:from-amber-500.hover\:to-orange-500:hover {
    background-color: #d97706 !important;
}
.from-pink-600.to-rose-600 {
    background-color: #db2777 !important;
}
.hover\:from-pink-500.hover\:to-rose-500:hover {
    background-color: #be185d !important;
}
.tab-btn.active, .btn-oc-primary, .btn-pr-primary {
    background: var(--accent-color) !important;
    background-image: none !important;
}
.progress-fill, .be-progress-bar {
    background: var(--accent-color) !important;
    background-image: none !important;
}
