/* ===== VARIABLES Y RESET ===== */
:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #7209b7;
    --success: #4cc9f0;
    --danger: #f72585;
    --warning: #f8961e;
    --info: #4895ef;
    --dark: #212529;
    --light: #f8f9fa;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --sidebar-width: 280px;
    --border-radius: 12px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto !important;
}

body.loaded {
    background: #f5f7fa;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--dark) 0%, #1a1a2e 100%);
    color: white;
    padding: 1.5rem 1.25rem;
    display: none !important;
    flex-direction: column;
    z-index: 99999 !important; /* Juan Sebastian: Prioridad absoluta sobre tablas y modales */
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    transform: translateX(-100%);
    /* Mobile First: Hidden by default */
}

/* Solo visible cuando el usuario esté autenticado */
body.logged-in .sidebar {
    display: flex !important;
}

/* Juan Sebastian: Asegurar visibilidad del botón hamburguesa */
[id^="toggle-sidebar"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    z-index: 1001;
    cursor: pointer;
    transition: var(--transition);
    color: var(--primary);
    font-size: 1.1rem;
    margin-right: 15px;
}

[id^="toggle-sidebar"]:hover {
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

/* Ocultar en la landing / portal */
body:not(.logged-in) [id^="toggle-sidebar"] {
    display: none !important;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 4999;
    display: none;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* Desktop styles */
@media (min-width: 992px) {
    body.logged-in .sidebar {
        transform: translateX(0);
    }
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

@media (min-width: 992px) {
    .sidebar.collapsed {
        width: 0;
        padding: 0;
        overflow: hidden;
    }
}

.sidebar-header {
    margin-bottom: 40px;
}

.company-logo {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary);
}

.company-logo i {
    font-size: 2rem;
    color: var(--primary);
}

.company-logo h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
    color: white;
}

.company-logo p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-menu {
    flex: 1;
    list-style: none;
    padding-top: 20px;
    overflow-y: auto;
    margin-right: -10px;
    padding-right: 10px;
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.menu-item {
    margin-bottom: 10px;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
}

.menu-item a:hover {
    background: rgba(67, 97, 238, 0.2);
    color: white;
    transform: translateX(10px);
}

.menu-item.active a {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

.menu-item i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding-top: 15px;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
}

.user-avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.current-date {
    text-align: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 0;
    padding: 1.5rem;
    min-height: 100vh;
    overflow-y: visible !important;
    overflow-x: hidden;
    background: #f5f7fa;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0 !important;
}

@media (min-width: 992px) {
    #main-content {
        margin-left: var(--sidebar-width, 280px);
        padding: 2.5rem;
        transition: margin-left 0.3s ease-in-out;
    }
    
    /* Cuando el sidebar esté oculto o colapsado */
    body.sidebar-collapsed #main-content,
    #main-content.expanded {
        margin-left: 0 !important;
    }
}

/* Estilo para tarjetas de Pedidos y Contenedores */
.pedidos-card, .metals-card, .form-container, .table-container {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    padding: 25px;
    margin-bottom: 25px;
    transition: var(--transition);
}

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

/* Fix para el top-bar cuando hay sidebar */
.top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

/* Juan Sebastian: Estados para sidebar colapsado en escritorio */
.sidebar.collapsed {
    transform: translateX(-100%);
}

.main-content.expanded {
    margin-left: 0 !important;
}

@media (min-width: 992px) {
    .sidebar.collapsed {
        width: 0;
        padding: 0;
        overflow: hidden;
    }
}

/* ===== PAGES SYSTEM ===== */
.page {
    display: none;
    animation: fadeIn 0.5s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== COMMON COMPONENTS ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 15px;
    position: relative;
    z-index: 1000;
}

@media (max-width: 576px) {
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }

    .top-controls {
        width: 100%;
        justify-content: space-between;
    }
}

.page-title {
    flex: 1;
    width: 100%;
}

.page-title h1 {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.page-title h1 i {
    color: var(--primary);
    font-size: 2.2rem;
}

.subtitle {
    color: var(--gray);
    font-size: 0.95rem;
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.styled-select {
    padding: 12px 20px;
    border: 2px solid var(--gray-light);
    border-radius: 50px;
    background: white;
    color: var(--dark);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    min-width: 180px;
}

.styled-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #0ea5e9);
    color: white;
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--gray);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--gray-light);
    color: var(--dark);
}

.btn-icon.btn-sm {
    padding: 6px;
    font-size: 0.9rem;
}

.btn-danger {
    color: var(--danger) !important;
}

.btn-danger:hover {
    background: var(--danger) !important;
    color: white !important;
}

/* responsive helpers */
.d-lg-none {
    display: none;
}

@media (max-width: 991px) {
    .d-lg-none {
        display: inline-flex;
    }
}

.btn-icon i {
    pointer-events: none;
    /* Evita que el click se registre en el icono en lugar del botón */
}

/* ===== KPIs (DASHBOARD SPECIFIC) ===== */
.kpis-section {
    margin-bottom: 40px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
}

.kpi-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.kpi-primary::before {
    background: var(--primary);
}

.kpi-success::before {
    background: var(--success);
}

.kpi-warning::before {
    background: var(--warning);
}

.kpi-danger::before {
    background: var(--danger);
}

.kpi-icon {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
}

.kpi-primary .kpi-icon {
    background: var(--primary);
}

.kpi-success .kpi-icon {
    background: var(--success);
}

.kpi-warning .kpi-icon {
    background: var(--warning);
}

.kpi-danger .kpi-icon {
    background: var(--danger);
}

.kpi-content {
    flex: 1;
}

.kpi-content h3 {
    font-size: 0.95rem;
    color: var(--gray);
    margin-bottom: 10px;
    font-weight: 600;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--dark);
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 10px;
}

.trend-up {
    color: #10b981;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.trend-down {
    color: var(--danger);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.kpi-subtext {
    font-size: 0.85rem;
    color: var(--gray);
}

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile First: 1 column */
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
}

.column {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.dashboard-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.dashboard-card:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 25px 15px;
    border-bottom: 1px solid var(--gray-light);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.card-icon {
    font-size: 1.5rem;
    color: var(--primary);
}

.card-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--dark);
}

.card-controls {
    display: flex;
    gap: 10px;
}

.mini-select {
    padding: 8px 15px;
    border: 1px solid var(--gray-light);
    border-radius: 8px;
    background: white;
    color: var(--dark);
    font-size: 0.85rem;
    cursor: pointer;
}

.card-content {
    padding: 25px;
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray);
    font-weight: 500;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
}

.text-success {
    color: #10b981 !important;
}

.text-danger {
    color: var(--danger) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-muted {
    color: var(--gray) !important;
}

/* ===== PROGRESS BAR ===== */
.progress-section {
    margin-bottom: 25px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--dark);
}

.progress-bar-container {
    height: 10px;
    background: var(--gray-light);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 5px;
    transition: width 1s ease;
}

.progress-mini {
    height: 4px;
    background: var(--gray-light);
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.progress-bar-mini {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
}

/* ===== CHARTS ===== */
.chart-container {
    height: 200px;
    position: relative;
    margin: 20px 0;
}

.chart-container-small {
    height: 150px;
    margin: 20px 0;
}

.chart-container-large {
    height: 300px;
    margin: 20px 0;
}

/* ===== TOP INDICATOR ===== */
.top-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: var(--gray-light);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.top-indicator.highlight {
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.1), rgba(114, 9, 183, 0.1));
    border-left: 4px solid var(--primary);
}

.metric-value {
    margin-left: auto;
    font-weight: 600;
    color: var(--primary);
}

/* ===== RANKING ===== */
.ranking-container {
    max-height: 250px;
    overflow-y: auto;
    margin: 20px 0;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-light);
}

.ranking-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--gray);
    gap: 15px;
}

.ranking-placeholder i {
    font-size: 2rem;
}

/* ===== STOCK SECTION ===== */
.status-badge {
    padding: 8px 15px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
}

.status-optimo {
    background: #10b981;
    color: white;
    padding: 5px 15px;
    border-radius: 50px;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.risk-chart {
    width: 100px;
    height: 100px;
}

.alert-box {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #dbeafe;
    border-radius: var(--border-radius);
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.critical-items {
    padding: 20px;
    background: #fef2f2;
    border-radius: var(--border-radius);
    border: 1px solid #fecaca;
}

.critical-items h4 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: #dc2626;
}

.no-critical {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: #10b981;
    gap: 10px;
}

.no-critical i {
    font-size: 2rem;
}

/* ===== TIMELINE ===== */
.timeline-section {
    margin-top: 30px;
}

.chart-legend {
    display: flex;
    gap: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--gray);
}

.legend-color {
    width: 15px;
    height: 15px;
    border-radius: 3px;
}

.legend-color.production {
    background: var(--primary);
}

.legend-color.sales {
    background: var(--success);
}

/* ===== INFO BOX ===== */
.info-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: var(--gray-light);
    border-radius: var(--border-radius);
    color: var(--gray);
    font-size: 0.85rem;
    margin-top: 20px;
}

/* ===== NOTIFICATIONS ===== */
.notifications-container {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 350px;
}

.notification {
    background: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
}

.notification-success {
    border-left-color: #10b981;
    background: #f0fdf4;
}

.notification-error {
    border-left-color: var(--danger);
    background: #fef2f2;
}

.notification-warning {
    border-left-color: var(--warning);
    background: #fffbeb;
}

.notification-info {
    border-left-color: var(--info);
    background: #eff6ff;
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* ===== PÁGINA DE INVENTARIO ===== */
.inventario-container {
    padding: 20px;
}

.filtros-section {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.search-box {
    position: relative;
    margin-bottom: 15px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid var(--gray-light);
    border-radius: 50px;
    font-size: 1rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 15px;
    border: 2px solid var(--gray-light);
    background: white;
    color: var(--dark);
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.stats-inventario {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
}

.stat-card i {
    font-size: 2rem;
    color: var(--primary);
}

.stat-card h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
}

.stat-card p {
    color: var(--gray);
    font-size: 0.9rem;
}

.table-container {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.productos-table {
    width: 100%;
    border-collapse: collapse;
}

.productos-table th {
    background: var(--primary);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.productos-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--gray-light);
}

.productos-table tr:hover {
    background: #f8f9fa;
}

.loading-row,
.empty-row {
    text-align: center;
    padding: 40px !important;
    color: var(--gray);
}

.loading-row i,
.empty-row i {
    font-size: 1.5rem;
    margin-bottom: 10px;
    display: block;
}

.estado-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.estado-ok {
    background: #d1fae5;
    color: #065f46;
}

.estado-medio {
    background: #fef3c7;
    color: #92400e;
}

.estado-bajo {
    background: #fed7aa;
    color: #9a3412;
}

.estado-agotado {
    background: #fee2e2;
    color: #991b1b;
}

.action-buttons {
    display: flex;
    gap: 5px;
}

/* Detalle de Producto */
.detalle-producto {
    background: white;
    border-radius: var(--border-radius);
    margin-top: 20px;
    box-shadow: var(--shadow);
    display: none;
}

.detalle-producto.active {
    display: block;
}

.detalle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--gray-light);
}

.detalle-content {
    padding: 20px;
}

.detalle-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile First */
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 768px) {
    .detalle-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table th,
.info-table td {
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-light);
    text-align: left;
}

.info-table th {
    font-weight: 600;
    color: var(--dark);
    width: 40%;
}

.stock-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile First */
    gap: 1rem;
    margin: 1rem 0;
}

@media (min-width: 576px) {
    .stock-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stock-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stock-item.stock-zero {
    background: #fee2e2;
}

.stock-item span {
    display: block;
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.stock-item strong {
    font-size: 1.5rem;
    color: var(--dark);
}

.stock-total,
.stock-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--gray-light);
}

.detalle-ficha,
.detalle-movimientos {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-light);
}

.movimientos-list {
    max-height: 200px;
    overflow-y: auto;
}

.movimiento-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--gray-light);
    font-size: 0.9rem;
}

.movimiento-item:last-child {
    border-bottom: none;
}

.movimiento-fecha {
    color: var(--gray);
    width: 100px;
}

.movimiento-tipo {
    font-weight: 600;
    color: var(--primary);
}

.movimiento-cantidad {
    font-weight: 600;
}

.movimiento-responsable {
    color: var(--gray);
}

/* ===== FORMULARIOS ===== */
.form-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow);
    margin: 20px;
}

.styled-form {
    max-width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-light);
}

.ficha-tecnica,
.info-receta {
    background: #f8f9fa;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-top: 20px;
    border-left: 4px solid var(--primary);
    display: none;
}

.ficha-tecnica.active,
.info-receta.active {
    display: block;
}

.ficha-tecnica h4,
.info-receta h4 {
    margin-bottom: 15px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.ficha-info,
.receta-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.receta-alert {
    background: #fef3c7;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== PÁGINA DE REPORTES ===== */
.reportes-container {
    padding: 20px;
}

.reportes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.reporte-card {
    background: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    gap: 20px;
    align-items: flex-start;
    transition: var(--transition);
}

.reporte-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.reporte-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.reporte-content {
    flex: 1;
}

.reporte-content h3 {
    margin-bottom: 10px;
    color: var(--dark);
}

.reporte-content p {
    color: var(--gray);
    margin-bottom: 15px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.opciones-reporte {
    background: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.opciones-reporte h3 {
    margin-bottom: 20px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.opciones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.opcion-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.opcion-group label {
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.opciones-actions {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--gray-light);
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--gray-light);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 20px;
    border-top: 1px solid var(--gray-light);
}

/* ===== ANIMACIONES ===== */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    /* Previously handled sidebar hiding here, now default */

    .top-bar {
        flex-direction: column;
        gap: 1.25rem;
        align-items: flex-start;
    }

    .top-controls {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .card-controls {
        width: 100%;
        justify-content: space-between;
    }

    .form-container {
        margin: 10px;
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: column;
        gap: 5px;
    }

    .detalle-grid {
        grid-template-columns: 1fr;
    }

    .stock-grid {
        grid-template-columns: 1fr;
    }

    .movimiento-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .movimiento-fecha {
        width: auto;
    }

    .detalle-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== MENU TOGGLE PARA MOBILE ===== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow);
}

@media (max-width: 992px) {
    .menu-toggle {
        display: block;
    }
}

/* ===== MODALES DE DETALLES ===== */
.modal-detalles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        background: rgba(0, 0, 0, 0);
    }

    to {
        opacity: 1;
        background: rgba(0, 0, 0, 0.7);
    }
}

.modal-detalles-content {
    background: white;
    border-radius: 15px;
    width: 100%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-detalles .modal-header {
    padding: 25px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.modal-detalles .modal-body {
    padding: 25px;
}

/* Scrollbar personalizado para modales */
.modal-detalles-content::-webkit-scrollbar {
    width: 8px;
}

.modal-detalles-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-detalles-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.modal-detalles-content::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Estilos para las imágenes de productos */
.img-thumbnail-tabla {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 10px;
    vertical-align: middle;
    border: 1px solid var(--gray-light);
}

.contenedor-img-detalle {
    width: 100%;
    max-height: 300px;
    overflow: hidden;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    background: #f8f9fa;
    display: flex;
    justify-content: center;
    align-items: center;
}

.img-detalle-full {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.img-detalle-full:hover {
    transform: scale(1.05);
}

/* ============================================
   MODAL DE DETALLE DE PRODUCTO - NUEVO DISEÑO
   ============================================ */

/* Overlay del modal */
.modal-detalle-producto {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1055;
    backdrop-filter: blur(4px);
}

/* Caja principal del modal */
.modal-detalle-box {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header del modal */
.modal-detalle-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 20px 24px;
}

.modal-detalle-header .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.producto-titulo {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
}

.producto-codigo {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-cerrar-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.btn-cerrar-modal:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Contenido principal (dos columnas) */
.modal-detalle-content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Columna izquierda */
.detalle-izquierda {
    width: 35%;
    padding: 24px;
    background: #f8fafc;
    border-right: 1px solid var(--gray-light);
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.imagen-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.producto-imagen {
    max-width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: 8px;
}

.estado-container {
    text-align: center;
}

.badge-estado {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
}

.badge-estado.activo {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #16a34a;
    border: 1px solid #86efac;
}

.badge-estado.inactivo {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #dc2626;
    border: 1px solid #f87171;
}

.estado-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.badge-estado.activo .estado-dot {
    background: #16a34a;
}

.badge-estado.inactivo .estado-dot {
    background: #dc2626;
}

/* Códigos */
.codigos-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.codigo-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.codigo-label {
    font-size: 0.8rem;
    color: var(--gray);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.codigo-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark);
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    background: #ffffff;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--gray-light);
}

/* Stock resumen */
.stock-resumen {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid var(--gray-light);
    transition: all 0.3s ease;
}

.stock-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stock-item.total {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border-color: var(--primary-light);
}

.stock-item.minimo {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #fbbf24;
}

.stock-label {
    font-size: 0.85rem;
    color: var(--gray);
    font-weight: 500;
}

.stock-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--dark);
    font-family: 'Poppins', sans-serif;
}

.stock-estado {
    text-align: center;
    padding-top: 8px;
}

.badge-estado-stock {
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Columna derecha */
.detalle-derecha {
    width: 65%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Tabs */
.tabs-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-buttons {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--gray-light);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--gray);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 3px 3px 0 0;
}

.tab-btn:hover:not(.active) {
    color: var(--dark);
}

.tab-contents {
    flex: 1;
    min-height: 0;
}

.modal-detalle-box .tab-content {
    display: none;
    height: 100%;
    animation: fadeIn 0.3s ease;
}

.modal-detalle-box .tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Contenido de tabs */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-label {
    font-size: 0.85rem;
    color: var(--gray);
    font-weight: 500;
}

.info-value {
    font-size: 0.95rem;
    color: var(--dark);
    font-weight: 500;
    line-height: 1.4;
}

.precios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.precio-item {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--gray-light);
    text-align: center;
    transition: all 0.3s ease;
}

.precio-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.precio-label {
    display: block;
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 8px;
    font-weight: 500;
}

.precio-valor {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
}

.precio-compra {
    color: #10b981;
}

.precio-venta {
    color: var(--primary);
}

.precio-sugerido {
    color: #8b5cf6;
}

.precio-utilidad {
    color: #059669;
}

.actualizacion-precio {
    text-align: center;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--gray-light);
}

.actualizacion-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-right: 8px;
}

.actualizacion-fecha {
    font-size: 0.9rem;
    color: var(--dark);
    font-weight: 500;
}

/* Movimientos */
.movimientos-container {
    height: 100%;
}

.movimientos-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.movimiento-item {
    background: #ffffff;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid var(--gray-light);
    transition: all 0.3s ease;
}

.movimiento-item:hover {
    border-color: var(--primary-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.movimiento-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.movimiento-tipo {
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.movimiento-tipo.entrada {
    background: #d1fae5;
    color: #059669;
}

.movimiento-tipo.salida {
    background: #fee2e2;
    color: #dc2626;
}

.movimiento-fecha {
    font-size: 0.8rem;
    color: var(--gray);
}

.movimiento-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.movimiento-cantidad {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark);
}

.movimiento-motivo {
    font-size: 0.9rem;
    color: var(--gray);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-movimientos {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

.no-movimientos i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-movimientos p {
    font-size: 1rem;
    margin: 0;
}

/* Footer del modal */
.modal-detalle-footer {
    padding: 20px 24px;
    background: #f9fafb;
    border-top: 1px solid var(--gray-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn {
    padding: 10px 24px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
}

.btn-secundario {
    background: #e5e7eb;
    color: var(--dark);
}

.btn-secundario:hover {
    background: #d1d5db;
}

.btn-primario {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

.btn-primario:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.3);
}

/* Responsive */
@media (max-width: 992px) {
    .modal-detalle-content {
        flex-direction: column;
    }

    .detalle-izquierda,
    .detalle-derecha {
        width: 100%;
        border-right: none;
    }

    .detalle-izquierda {
        border-bottom: 1px solid var(--gray-light);
        max-height: 50vh;
    }
}

@media (max-width: 576px) {
    .modal-detalle-producto {
        padding: 12px;
    }

    .modal-detalle-box {
        max-height: 95vh;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .tab-buttons {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        min-width: 100px;
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    .modal-detalle-footer {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* ============================================
   ESTILOS PARA TABLA DE MOVIMIENTOS
   ============================================ */

/* Badge contador en tabs */
.badge-contador {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
    font-weight: 600;
}

/* Contenedor de movimientos */
.movimientos-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.movimientos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-light);
}

.movimientos-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark);
    margin: 0;
    display: flex;
    align-items: center;
}

.movimientos-filtros {
    display: flex;
    align-items: center;
    gap: 12px;
}

.movimientos-total {
    font-size: 0.85rem;
    color: var(--gray);
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 6px;
}

/* Tabla de movimientos */
.movimientos-tabla-container {
    flex: 1;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid var(--gray-light);
    background: white;
}

.movimientos-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.movimientos-tabla thead {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.movimientos-tabla th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--gray);
    border-bottom: 1px solid var(--gray-light);
    white-space: nowrap;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.movimientos-tabla td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-light);
    vertical-align: middle;
}

.movimientos-tabla tbody tr {
    transition: background-color 0.2s ease;
}

.movimientos-tabla tbody tr:hover {
    background: #f8fafc;
}

.movimientos-tabla tbody tr:last-child td {
    border-bottom: none;
}

/* Celdas personalizadas */
.fecha-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fecha-dia {
    font-weight: 500;
    color: var(--dark);
}

.fecha-hora {
    font-size: 0.75rem;
    color: var(--gray);
}

.cantidad-cell {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.cantidad-valor {
    font-weight: 700;
    color: var(--dark);
    font-size: 1rem;
}

.cantidad-unidad {
    font-size: 0.75rem;
    color: var(--gray);
}

.responsable-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Badges de tipos */
.badge-tipo {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-tipo.tipo-inyeccion {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-tipo.tipo-ajuste {
    background: #fef3c7;
    color: #d97706;
}

.badge-tipo.tipo-transferencia {
    background: #ede9fe;
    color: #7c3aed;
}

.badge-tipo.tipo-salida {
    background: #fee2e2;
    color: #dc2626;
}

.badge-tipo.tipo-entrada {
    background: #dcfce7;
    color: #16a34a;
}

.badge-tipo.tipo-produccion {
    background: #f0f9ff;
    color: #0284c7;
}

.badge-tipo.tipo-default {
    background: #f3f4f6;
    color: #4b5563;
}

/* Badges de estado */
.badge-estado-movimiento {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-estado-movimiento.estado-completado {
    background: #dcfce7;
    color: #16a34a;
}

.badge-estado-movimiento.estado-proceso {
    background: #fef3c7;
    color: #d97706;
}

.badge-estado-movimiento.estado-pendiente {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-estado-movimiento.estado-cancelado {
    background: #fee2e2;
    color: #dc2626;
}

.badge-estado-movimiento.estado-error {
    background: #fce7f3;
    color: #be185d;
}

.badge-estado-movimiento.estado-default {
    background: #f3f4f6;
    color: #4b5563;
}

/* Badge de máquina */
.maquina-badge {
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
}

/* Estado empty */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-light);
    margin: 20px 0;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h4 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--dark);
}

.empty-state p {
    font-size: 0.95rem;
    max-width: 300px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Footer de movimientos */
.movimientos-footer {
    margin-top: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--gray-light);
}

.movimientos-footer a {
    text-decoration: none;
    font-weight: 600;
}

.movimientos-footer a:hover {
    text-decoration: underline;
}

/* Estilos para texto */
.text-muted {
    color: var(--gray) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.text-danger {
    color: #dc2626 !important;
}

.text-success {
    color: #16a34a !important;
}

.text-warning {
    color: #d97706 !important;
}

.text-info {
    color: #0284c7 !important;
}

/* Responsive para tabla */
@media (max-width: 768px) {
    .movimientos-tabla-container {
        overflow-x: auto;
    }

    .movimientos-tabla {
        min-width: 800px;
    }

    .movimientos-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* Tabla de movimientos mejorada */
.movimientos-tabla {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.movimientos-tabla table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.movimientos-tabla thead {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.movimientos-tabla th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #4b5563;
    font-size: 13px;
    border-bottom: 2px solid #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.movimientos-tabla td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    color: #374151;
}

.movimientos-tabla tbody tr {
    transition: background-color 0.2s ease;
}

.movimientos-tabla tbody tr:hover {
    background: #f8fafc;
}

.movimientos-tabla small {
    display: block;
    color: #9ca3af;
    font-size: 12px;
}

.movimientos-tabla strong {
    color: #1f2937;
    font-weight: 700;
}

.text-danger {
    color: #dc2626 !important;
    font-weight: 600;
}

.text-success {
    color: #10b981 !important;
    font-weight: 600;
}

.badge-tipo {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-tipo.tipo-inyeccion {
    background: #dbeafe;
    color: #1e40af;
}

.badge-tipo.tipo-pulido {
    background: #fce7f3;
    color: #be185d;
}

.badge-tipo.tipo-venta {
    background: #dcfce7;
    color: #15803d;
}

/* ===== ESTILOS ESPECÍFICOS PARA BOTONES DE RANKING ===== */

/* Contenedor de filtros de ranking */
.ranking-filters-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: #f8fafc;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-light);
}

/* Fila de botones de tipo de ranking */
.ranking-type-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ranking-filter-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: white;
    color: var(--gray);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.ranking-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: var(--primary);
}

.ranking-filter-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.ranking-filter-btn i {
    font-size: 1.1rem;
}

.ranking-filter-btn[data-tipo="inyeccion"] i {
    color: inherit;
}

.ranking-filter-btn[data-tipo="pulido"] i {
    color: inherit;
}

/* Selector de período para ranking */
.ranking-period-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-light);
}

.ranking-period-selector label {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
    white-space: nowrap;
}

.ranking-period-selector select {
    flex: 1;
    padding: 8px 15px;
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    background: white;
    color: var(--dark);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    min-width: 150px;
}

.ranking-period-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Estadísticas de ranking */
.ranking-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.ranking-stat-item {
    background: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.ranking-stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.ranking-stat-item:nth-child(2) {
    border-left-color: var(--success);
}

.ranking-stat-item:nth-child(3) {
    border-left-color: var(--warning);
}

.ranking-stat-item .stat-label {
    font-size: 0.8rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.ranking-stat-item .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
}

.ranking-stat-item .stat-subtext {
    font-size: 0.75rem;
    color: var(--gray);
    margin-top: 3px;
}

/* Badges para posición en ranking */
.ranking-position-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    margin-right: 12px;
    flex-shrink: 0;
}

.ranking-position-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    box-shadow: 0 3px 8px rgba(255, 165, 0, 0.3);
}

.ranking-position-2 {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    box-shadow: 0 3px 8px rgba(160, 160, 160, 0.3);
}

.ranking-position-3 {
    background: linear-gradient(135deg, #CD7F32, #A0522D);
    box-shadow: 0 3px 8px rgba(205, 127, 50, 0.3);
}

.ranking-position-other {
    background: var(--gray-light);
    color: var(--dark);
}

/* Animación para cambio de ranking */
@keyframes fadeInRanking {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ranking-container.animating {
    animation: fadeInRanking 0.4s ease;
}

/* Botón de exportar ranking */
.ranking-export-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: auto;
}

.ranking-export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    background: linear-gradient(135deg, #059669, #047857);
}

/* Responsive para botones de ranking */
@media (max-width: 768px) {
    .ranking-type-buttons {
        flex-direction: column;
    }

    .ranking-filter-btn {
        width: 100%;
    }

    .ranking-period-selector {
        flex-direction: column;
        align-items: flex-start;
    }

    .ranking-period-selector select {
        width: 100%;
    }

    .ranking-stats {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   ESTILOS PARA PNC
======================================== */

.criterio-btn {
    padding: 12px 16px;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #374151;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.criterio-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.criterio-btn.active {
    background: linear-gradient(135deg, #ef4444, #f97316);
    border-color: #ef4444;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.criterios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.tabs-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 600;
    color: #6b7280;
}

.tab-btn.active {
    color: #2563eb;
    /* Tu color primario */
    border-bottom-color: #2563eb;
}

/* Para la página de mezcla */
#mezcla-page .form-container {
    margin-top: 20px;
}

#mezcla-page .kpis-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

/* Para la página de historial */
#historial-page .tabs-container {
    display: flex;
    gap: 5px;
    background: #f5f5f5;
    padding: 8px;
    border-radius: 8px;
}

#historial-page .tab-btn {
    padding: 8px 16px;
    border: none;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

#historial-page .tab-btn.active {
    background: var(--color-primary);
    color: white;
    font-weight: 600;
}

#historial-page .filtros-section {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.producto-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
}

/* ============================================
   ESTILOS PARA HISTORIAL GLOBAL - VERSIÓN MEJORADA
   ============================================ */

/* Contenedor principal */
#historial-container {
    min-height: 300px;
}

/* Tabla con scroll */
.table-responsive {
    max-height: 600px;
    overflow-y: auto;
    border-radius: 8px;
}

/* Header estilo morado degradado */
.table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table thead th {
    background-color: #4361ee !important;
    /* Azul primario directamente en el TH */
    color: white !important;
    font-weight: 600 !important;
    padding: 14px 12px !important;
    border: none !important;
    font-size: 0.875rem;
    letter-spacing: 0.3px;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.table thead th i {
    margin-right: 6px;
    opacity: 0.9;
}

/* Filas de la tabla */
.table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #e5e7eb;
}

.table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.08);
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.table tbody td {
    padding: 12px !important;
    vertical-align: middle;
}

/* Badges personalizados con colores morados */
.badge {
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

.badge.bg-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
    color: white;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.badge.bg-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white;
}

.badge.bg-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: white;
}

.badge.bg-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: white;
}

.badge.bg-info {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
    color: white;
}

.badge.bg-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%) !important;
    color: white;
}

/* Estado vacío */
.empty-state {
    padding: 3rem 0;
}

.empty-state i {
    opacity: 0.3;
    color: #6366f1;
}

/* ============================================
   PAGINACIÓN MEJORADA ESTILO MORADO
   ============================================ */
#pagination-container {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(to right, #f8f9fa, #ffffff);
    border-radius: 8px;
    border-top: 2px solid #e5e7eb;
}

.pagination {
    margin-bottom: 0;
    gap: 4px;
}

.pagination .page-item {
    margin: 0 2px;
}

.pagination .page-link {
    color: #6366f1;
    border: 1px solid #e5e7eb;
    padding: 0.5rem 0.85rem;
    transition: all 0.2s ease;
    border-radius: 6px !important;
    font-weight: 500;
    font-size: 0.875rem;
}

.pagination .page-link:hover:not(.disabled) {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-color: #6366f1;
    color: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
    border-color: #6366f1 !important;
    color: white !important;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.4);
    transform: scale(1.05);
}

.pagination .page-item.disabled .page-link {
    color: #9ca3af;
    cursor: not-allowed;
    background-color: #f9fafb;
    border-color: #e5e7eb;
}

.pagination .page-link i {
    font-size: 0.75rem;
}

/* Header de tabla con búsqueda */
.table-header {
    background: linear-gradient(to right, #faf5ff, #f5f3ff);
    padding: 1.25rem;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid #e9d5ff;
    margin-bottom: 0;
}

.table-header h5 {
    margin-bottom: 0.25rem;
    color: #6366f1;
    font-weight: 700;
}

.table-header h5 i {
    margin-right: 8px;
}

.table-header small {
    color: #8b5cf6;
    font-weight: 500;
}

.table-header .input-group {
    max-width: 320px;
}

.table-header .input-group-text {
    background-color: white;
    border-right: none;
    border-color: #d1d5db;
    color: #6366f1;
}

.table-header input {
    border-left: none;
    border-color: #d1d5db;
}

.table-header input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

/* Textos pequeños más legibles */
.table small {
    font-size: 0.85rem;
    color: #6b7280;
}

/* Tabla alternada suave */
.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(99, 102, 241, 0.02);
}

/* Scroll personalizado morado */
.table-responsive::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 5px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 5px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

/* Mejora de filtros en historial */
.filtros-container .form-control:focus,
.filtros-container .form-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    outline: none;
}

/* Botón de filtrar mejorado */
.filtros-container .btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
}

.filtros-container .btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.4);
}

.filtros-container .btn-primary:active {
    transform: translateY(0);
}

/* Responsive mejoras */
@media (max-width: 768px) {
    .table-header {
        padding: 1rem;
    }

    .table-header .row {
        gap: 0.75rem;
    }

    .table-header .input-group {
        max-width: 100%;
    }

    .table-responsive {
        max-height: 450px;
    }

    .pagination .page-link {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    #pagination-container {
        padding: 0.75rem;
    }
}

/* Animación de carga */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table tbody tr {
    animation: fadeIn 0.3s ease;
}

/* Badge de cantidad con fondo morado claro */
.badge.bg-info.text-dark {
    background: linear-gradient(135deg, #ddd6fe 0%, #c7d2fe 100%) !important;
    color: #5b21b6 !important;
    font-weight: 700;
}

/* Corrección de lista de paginación */
#pagination-container ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

#pagination-container li {
    list-style: none !important;
    display: inline-block !important;
}

/* Asegurar que los estilos de Bootstrap se apliquen */
#pagination-container .pagination {
    display: flex !important;
    list-style: none !important;
    padding-left: 0 !important;
}

#pagination-container .page-item {
    list-style: none !important;
    display: list-item !important;
}

/* Números de página más destacados */
.pagination .page-item:not(.disabled) .page-link {
    cursor: pointer !important;
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25) !important;
    outline: none !important;
}

/* Botones anterior/siguiente más visibles */
.pagination .page-link:has(i) {
    font-weight: 600;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* ============================================
   NOTIFICACIONES TOAST
   ============================================ */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

#notifications-container {
    pointer-events: none;
}

#notifications-container .notification {
    pointer-events: all;
}

.notification button:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}

/* ===== ESTILOS PARA BOTONES DE FILTRO DE INVENTARIO ===== */
.filtros-rapidos-section {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

#filtros-inventario {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#filtros-inventario .btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 50px;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
}

#filtros-inventario .btn.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-color: #4f46e5;
    color: white;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

#filtros-inventario .btn.btn-light {
    background: white;
    color: #495057;
}

#filtros-inventario .btn:hover:not(.active) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#filtros-inventario .btn i {
    margin-right: 5px;
    font-size: 13px;
}

/* Estilos específicos para los iconos de estado */
.text-danger {
    color: #dc3545 !important;
}

.text-warning {
    color: #ffc107 !important;
}

.text-success {
    color: #28a745 !important;
}

.text-dark {
    color: #343a40 !important;
}

/* Ajustes responsive */
@media (max-width: 768px) {
    .filtros-rapidos-section .d-flex {
        flex-direction: column;
        gap: 10px;
    }

    #filtros-inventario {
        justify-content: center;
    }

    .flex-grow-1 {
        max-width: 100% !important;
    }
}

/* Estilos para el buscador */
.search-box {
    position: relative;
    width: 100%;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    z-index: 2;
}

.search-box input {
    padding-left: 40px !important;
    border-radius: 8px !important;
    border: 1px solid #ced4da;
    height: 38px;
}

.search-box input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.25);
}

/* ===== TABLAS RESPONSIVAS MÓVIL ===== */
.table-container {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow);
}

.table-inventario,
.table {
    width: 100%;
    min-width: 800px;
    /* Asegura que no se amontone en pantallas pequeñas */
    border-collapse: collapse;
}

/* Escape para tablas chicas (pocas columnas) atrapadas por la regla genérica
   ".table { min-width: 800px }" de arriba -- esa regla es para tablas
   anchas tipo Inventario; una tabla de 2-3 columnas dentro de una card
   angosta (ej. "Productos en este Montaje" de Programación MES) queda
   forzada a 800px y aparece con scroll horizontal aunque el contenido real
   quepa sin problema. Mismo problema que ya se documentó para móvil en
   mobile-ux.css, pero ese arreglo solo aplica bajo @media(max-width:768px);
   este no depende del viewport. */
.table-compact {
    min-width: 0 !important;
}

.table-inventario th,
.table-inventario td {
    white-space: nowrap;
    /* Evita que el texto se rompa en varias líneas */
    padding: 12px 15px;
    text-align: left;
}

/* Columnas críticas: Código y Stock Total más visibles */
.table-inventario th:nth-child(2),
.table-inventario td:nth-child(2),
.table-inventario th:nth-child(6),
.table-inventario td:nth-child(6) {
    font-weight: 700;
    color: var(--dark);
    background-color: rgba(79, 70, 229, 0.03);
}

/* Botón de navegación móvil (Header) */
.mobile-back-container {
    display: none;
    align-items: center;
    margin-right: 15px;
}

@media (max-width: 991px) {
    .mobile-back-container.active {
        display: flex;
    }

    .table-container {
        max-height: none;
    }
}

.btn-back-mobile {
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-back-mobile:active {
    transform: scale(0.95);
}

/* ===== MODAL DE CONFIRMACIÓN ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    /* Fondo sólido más oscuro para enfocar el modal */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width: 400px;
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 25px 25px 15px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header i {
    color: var(--primary);
}

.modal-body {
    padding: 25px;
}

.modal-body p {
    margin: 0;
    font-size: 1rem;
    color: var(--gray);
    line-height: 1.6;
}

.modal-footer {
    padding: 15px 25px 25px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== BOTÓN "AÑADIR AL PEDIDO" DISTINTIVO ===== */
.btn-add-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 123, 255, 0.5) !important;
    background: #0056b3 !important;
}

.btn-add-item:active {
    transform: translateY(0);
}

/* ===== OPTIMIZACIONES MÓVILES ===== */
@media (max-width: 768px) {

    /* Botones táctiles mínimo 44px */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    .btn-icon {
        min-height: 44px;
        min-width: 44px;
    }

    /* Tabla responsive con scroll suave */
    .table-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }


    /* Inputs más grandes para móvil */
    input[type="text"],
    input[type="number"],
    select {
        min-height: 45px;
        font-size: 16px;
        /* Previene zoom en iOS */
    }

    /* Modal responsive */
    .modal-content {
        max-width: 95%;
        margin: 15px;
    }

    /* Botón añadir más prominente en móvil */
    .btn-add-item {
        font-size: 18px !important;
        padding: 14px !important;
        min-height: 50px !important;
    }
}


/* Scroll horizontal suave en tablas */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* ===== NUEVA CLASE PARA ALINEACIÓN LADO A LADO PRO (Visual Reengineering) ===== */
.row-form-aligned {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    margin-top: 25px;
    width: 100%;
}

.row-form-aligned>.form-group {
    flex: 1;
    min-width: 0;
}

/* En móvil, mantener el stack vertical si es necesario para legibilidad, 
   o ajustar gap. Si el usuario pide explícitamente lado a lado: */
@media (max-width: 600px) {
    .row-form-aligned {
        flex-direction: column;
        /* Más seguro en móviles pequeños */
        gap: 15px;
    }
}

/* =========================================
   SMART SEARCH / AUTOCOMPLETE STYLES
   ========================================= */
.form-group {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.autocomplete-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.95rem;
    transition: background 0.2s;
    color: #374151;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background-color: #e2e8f0;
    /* Darker shade of gray-blue */
    color: #0f172a;
    font-weight: 500;
}

.suggestion-item strong {
    color: var(--primary);
    font-weight: 600;
}

.suggestion-item small {
    display: block;
    color: #9ca3af;
    font-size: 0.8rem;
    margin-top: 2px;
}

/* =========================================
   MOBILE OPTIMIZATION (TOUCH TARGETS)
   ========================================= */
@media (max-width: 768px) {

    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="password"],
    input[type="email"],
    select,
    button.btn {
        min-height: 44px !important;
        font-size: 16px !important;
    }

    .form-container,
    .page {
        overflow-x: hidden;
        width: 100%;
    }
}

/* =========================================
   MOBILE CARD VIEW FOR TABLES
   ========================================= */
@media (max-width: 768px) {

    /* Force table to not be like a table */
    .table-mobile-cards,
    #tabla-items-pedido {
        display: block;
        width: 100%;
    }

    /* Hide standard headers */
    .table-mobile-cards thead,
    #tabla-items-pedido thead {
        display: none;
    }

    .table-mobile-cards tbody,
    #tabla-items-pedido tbody {
        display: block;
        width: 100%;
    }

    .table-mobile-cards tr,
    #tabla-items-pedido tr {
        display: block;
        background: white;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        margin-bottom: 20px;
        padding: 20px;
        border: 1px solid #f3f4f6;
    }

    .table-mobile-cards td,
    #tabla-items-pedido td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 10px 0;
        border: none;
        border-bottom: 1px solid #f3f4f6;
        font-size: 0.95rem;
    }

    .table-mobile-cards td:last-child,
    #tabla-items-pedido td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        /* Actions generally at end */
        padding-top: 15px;
    }

    /* Add label using data-label attribute */
    .table-mobile-cards td::before,
    #tabla-items-pedido td::before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
        color: #6b7280;
        text-transform: uppercase;
        font-size: 0.75rem;
        letter-spacing: 0.5px;
    }
}

/* EMERGENCY OVERRIDE: Restore Table View for Pedidos */
@media (max-width: 991px) {
    #tabla-items-pedido {
        display: table !important;
        width: 100% !important;
        border-collapse: collapse !important;
    }

    #tabla-items-pedido thead {
        display: table-header-group !important;
    }

    #tabla-items-pedido tbody {
        display: table-row-group !important;
    }

    #tabla-items-pedido tr {
        display: table-row !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    #tabla-items-pedido td {
        display: table-cell !important;
        text-align: left !important;
        padding: 12px 15px !important;
        border-bottom: 1px solid #dee2e6 !important;
        justify-content: normal !important;
    }

    #tabla-items-pedido td::before {
        content: none !important;
    }

    #tabla-items-pedido td:last-child {
        display: table-cell !important;
        text-align: center !important;
    }
}

/* Mobile Modal Improvements */
@media (max-width: 768px) {
    .modal-content-custom {
        width: 95% !important;
        margin: 10px auto !important;
        max-width: none !important;
        border-radius: 12px;
    }

    #detalle-producto {
        width: 100% !important;
        right: -100% !important;
    }

    #detalle-producto.active {
        right: 0 !important;
    }

    /* Mejores targets táctiles */
    .btn,
    button,
    input,
    select {
        min-height: 44px;
        touch-action: manipulation;
    }

    /* Espaciado mejorado en inputs móviles */
    .form-group {
        margin-bottom: 20px;
    }

    /* Modal PNC específico */
    #modal-detalle-pnc .modal-content-custom {
        padding: 15px;
        background: #ffffff;
        /* Explicit white background */
    }
}

/* === ESTILOS PARA EL MODAL DE EDICIÓN PREMIUM (PAOLA) === */
.edit-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
}

.section-title i {
    color: var(--primary);
    font-size: 1rem;
}

.edit-input:focus {
    border-color: var(--primary) !important;
    background-color: #f8fafc !important;
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1) !important;
    outline: none !important;
}

.modal-content {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== MODALES RESPONSIVOS (GLOBAL) ===== */
@media (max-width: 768px) {
    .custom-modal-content {
        width: 98% !important;
        max-width: none !important;
        margin: 10px !important;
        border-radius: 12px !important;
    }

    .custom-modal-content>div:nth-child(2) {
        padding: 15px !important;
    }

    #lista-productos-alistamiento {
        max-height: 60vh !important;
    }

    .card-alistamiento {
        padding: 12px !important;
    }

    .card-alistamiento .d-flex.justify-content-between {
        flex-direction: column;
        gap: 10px;
    }

    .card-alistamiento .badge {
        align-self: flex-start;
    }

    .card-alistamiento .d-flex.gap-3 {
        flex-direction: column;
        gap: 15px !important;
    }
}

/* ===== ANIMACIONES PREMIUM PARA BARRAS DE PROGRESO ===== */

/* Efecto Shimmer Mejorado (Brillo que recorre toda la barra) */
.progress-bar-shimmer {
    position: relative;
    overflow: hidden;
}

.progress-bar-shimmer::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.3) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: premium-shimmer 2s infinite ease-in-out;
    pointer-events: none;
    z-index: 10;
}

@keyframes premium-shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* ===== FRIPARTS CUSTOM BANNER ===== */
.friparts-banner {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 2rem auto;
    max-height: 250px;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    display: block;
}

.friparts-banner .banner-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
}

.friparts-banner .banner-overlay {
    position: absolute;
    bottom: 20px;
    right: 30px;
    z-index: 10;
}

.friparts-banner .banner-overlay .btn {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.friparts-banner .banner-overlay .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Ajustes mobile dentro de styles.css para asegurar consistencia */
@media (max-width: 768px) {
    .friparts-banner {
        max-height: 150px;
        margin-bottom: 1rem;
    }

    .friparts-banner .banner-overlay {
        bottom: 10px;
        right: 15px;
    }
}

/* ==========================================================================
   PREMIUM UI ENHANCEMENTS (WOW FACTOR)
   ========================================================================== */

/* 1. ANIMACIONES DE ENTRADA */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reveal {
    opacity: 0;
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Delays escalonados para efecto cascada */
.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

.delay-4 {
    animation-delay: 0.4s;
}

/* 2. EFECTOS GLASSMORPISM */
.glass-panel {
    background: var(--glass) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border) !important;
}

/* 3. MEJORAS EN BOTONES */
.btn-primary:active {
    transform: scale(0.95);
}

/* 4. SIDEBAR HOVER ANIMATION */
.menu-item a i {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.menu-item a:hover i {
    transform: scale(1.2) rotate(5deg);
}

/* 5. TABLAS CON HOVER ELEGANTE */
.table tbody tr {
    transition: var(--transition-fast);
}

.table tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.03) !important;
    transform: scale(1.002);
}

/* =========================================
   HOTFIX: MODAL SCROLLING ISSUE
   ========================================= */

/* Ensure the overlay covers screen and centers content */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.55);
    z-index: 1055;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    backdrop-filter: blur(3px);
}

/* Ensure the modal content is scrollable if it exceeds viewport height */
.modal-overlay .modal-content {
    max-height: 85vh;
    /* Leave some space */
    overflow-y: auto;
    width: 100%;
    max-width: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    /* Smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
}

/* Ensure header stays visible if possible, or just let it scroll */
.modal-overlay .modal-header {
    flex-shrink: 0;
}

/* Ensure body scrolls */
.modal-overlay .modal-body {
    overflow-y: visible;
    /* Content handles scroll */
    flex: 1 1 auto;
}

/* Specific fix for Auditoría de Stock */
#modalConteoInventario .modal-content {
    max-width: 480px;
}

/* ============================================
   ESTILOS MÓDULO FRIMETALS
   ============================================ */

.metals-page-body {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Selector de Procesos */
.metals-selector-header {
    margin-bottom: 32px;
    text-align: center;
}

.metals-process-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.metals-process-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border: 1px solid #f1f5f9;
}

.metals-process-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.metals-card-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.metals-card-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.metals-card-machines {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

/* Formulario Metals */
.metals-form {
    background: white;
    padding: 32px;
    border-radius: 20px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.metals-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-group-metals {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.label-metals {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-metals {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
}

.input-metals:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-hora-metals {
    background: #f1f5f9;
    border: none;
    color: #475569;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-hora-metals:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Autocomplete suggestions */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-top: 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: none;
}

.autocomplete-suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f8fafc;
}

/* Acciones */
.metals-form-actions {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.btn-guardar-metals {
    flex: 2;
    padding: 16px;
    border-radius: 12px;
    border: none;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-guardar-metals:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.btn-limpiar-metals {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: white;
    color: #64748b;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-limpiar-metals:hover {
    background: #f8fafc;
    color: #1e293b;
}

.btn-back-metals {
    background: none;
    border: none;
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.btn-back-metals:hover {
    color: #1e293b;
}

@media (max-width: 640px) {
    .metals-form-actions {
        flex-direction: column;
    }

    .metals-page-body {
        padding: 16px;
    }

    .metals-form {
        padding: 20px;
    }
}

/* MES pulse animation */
@keyframes mes-pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.85);
    }
}

/* ===== RBAC OVERLAY ===== */
.locked-overlay {
    position: relative;
    pointer-events: none !important;
    user-select: none;
    overflow: hidden !important;
}

.locked-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(240, 240, 240, 0.75);
    backdrop-filter: blur(2px);
    z-index: 50;
    border-radius: inherit;
    /* Respect parent border radius if any */
}

/* The warning container must catch clicks and show up above the ::after */
.locked-warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 51;
    /* Above the overlay */
    background: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    text-align: center;
    pointer-events: auto;
    /* Let them copy text if they want */
    border: 1px solid #e2e8f0;
    color: #475569;
    min-width: 300px;
}

.locked-warning h3 {
    margin-bottom: 0.5rem;
    color: #1e293b;
    font-weight: 700;
}

.locked-warning p {
    margin: 0;
    font-size: 0.95rem;
}

/* ===== BADGE ENSAMBLE (Indigo 600) ===== */
.badge-ensamble {
    background-color: #4f46e5 !important;
    color: #ffffff !important;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
}

/* Fondo indigo compatible con bg-opacity de Bootstrap */
.bg-indigo {
    --bs-bg-opacity: 1;
    background-color: rgba(79, 70, 229, var(--bs-bg-opacity)) !important;
}

/* Versión suave para timeline items */
.bg-indigo-light {
    background-color: rgba(79, 70, 229, 0.08) !important;
}

.text-indigo {
    color: #4f46e5 !important;
}

.border-indigo-subtle {
    border-color: rgba(79, 70, 229, 0.3) !important;
}

/* ===== HISTORIAL: Horario Movimiento ===== */
.horario-movimiento {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ===== HISTORIAL: Columna Producto con ellipsis ===== */
.td-producto {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}/* ========================================= */
/* V4 GLOBAL LOADER MICRO-DASHBOARD          */
/* ========================================= */
.global-loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loader-dashboard {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 30px 40px;
    width: 90%;
    max-width: 550px;
    color: #f8fafc;
}

.loader-etapa {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: 10px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.loader-etapa:last-child {
    margin-bottom: 0;
}

.l-icon {
    font-size: 1.5rem;
    margin-right: 15px;
    width: 30px;
    text-align: center;
}

.l-texto {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Estados */
.etapa-pending {
    opacity: 0.4;
    background: transparent;
}

.etapa-active {
    opacity: 1;
    background: rgba(79, 70, 229, 0.15);
    border-color: rgba(79, 70, 229, 0.3);
    color: #818cf8;
    animation: pulsoIndigo 1.5s infinite;
}

.etapa-complete {
    opacity: 1;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

@keyframes pulsoIndigo {
    0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
/* Overrides para el loader global híbrido */
.global-loader-container {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}
.loader-dashboard {
    border: 1px solid rgba(59, 130, 246, 0.4) !important;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.2) !important;
}
.gear-spin {
    display: inline-block;
    animation: spinGear 2.5s linear infinite;
}
@keyframes spinGear {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== HISTORIAL: Detalle Formateado ===== */
.detalle-formateado {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 0.85rem;
    color: #475569;
}

.detalle-formateado .badge {
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.2px;
    border-radius: 6px;
    padding: 4px 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ===== HISTORIAL: Encabezados de tabla con contraste garantizado ===== */
/* Corrige herencia de color blanco desde contenedores padre (sidebar/dark contexts) */
#historial-container thead th,
#historial-container .table thead th,
.table thead.ps-4 th,
.table thead th {
    color: #1e293b !important;           /* Texto oscuro slate-900 */
    background-color: #f1f5f9 !important; /* Fondo gris azulado suave */
    border-bottom: 2px solid #cbd5e1 !important; /* Borde inferior marcado */
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ===== PROGRAMACIÓN DE PULIDO: chips de operaria en "Asignar tarea" ===== */
/* Checkbox real oculto -- el chip (label) es lo que se ve y se clickea. */
.operaria-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.operaria-chip:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}
.operaria-chip input {
    display: none;
}
.operaria-chip.chip-activa {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.25);
}
.operaria-chip .chip-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    font-size: 0.55rem;
    color: transparent;
    flex-shrink: 0;
}
.operaria-chip.chip-activa .chip-check {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

/* ===== PROGRAMACIÓN DE PULIDO: tarjetas del tablero de la cola ===== */
.prog-card {
    transition: box-shadow 0.15s, transform 0.1s;
}
.prog-card[draggable="true"]:hover {
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}
