/* Estilos adicionales para el Sistema ERP */

/* Scrollbar personalizado para sidebar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #1a252f;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #34495e;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #3498db;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease-in;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.card-header {
    background: white;
    border-bottom: 2px solid #f0f0f0;
    font-weight: 600;
}

/* Botones mejorados */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Tablas mejoradas */
.table {
    background: white;
}

.table thead th {
    background: #f8f9fa;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

.table-hover tbody tr:hover {
    background-color: #f1f3f5;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* Badges mejorados */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
    border-radius: 4px;
}

/* Modales mejorados */
.modal-content {
    border-radius: 10px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    border-bottom: 2px solid #f0f0f0;
    background: #f8f9fa;
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ======================================== */

/* Tarjetas de estadísticas responsive */
.stat-card {
    border-radius: 10px;
    padding: 1.5rem;
    color: white;
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    font-size: 3rem;
    margin-right: 1rem;
    opacity: 0.8;
}

.stat-info h4 {
    margin: 0;
    font-size: 2rem;
    font-weight: bold;
}

.stat-info p {
    margin: 0;
    font-size: 0.9rem;
}

/* Menú hamburguesa para móvil */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    background: #2c3e50;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
}

.menu-toggle:hover {
    background: #34495e;
}

/* Overlay para cerrar menú en móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}

/* ========================================
   MEDIA QUERIES - TABLETS
   ======================================== */
@media (max-width: 992px) {
    /* Tarjetas de estadísticas en tablets */
    .stat-info h4 {
        font-size: 1.5rem;
    }

    .stat-icon {
        font-size: 2.5rem;
    }

    /* Modales más pequeños */
    .modal-dialog {
        max-width: 90%;
        margin: 1.75rem auto;
    }

    .modal-xl {
        max-width: 95%;
    }

    /* Tablas con scroll horizontal */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   MEDIA QUERIES - MÓVILES
   ======================================== */
@media (max-width: 768px) {
    /* Mostrar botón de menú */
    .menu-toggle {
        display: block;
    }

    /* Sidebar oculto por defecto en móvil */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* Ajustar contenido principal */
    .main-content {
        margin-left: 0 !important;
        padding: 1rem;
        width: 100%;
    }

    /* Header más compacto */
    .top-bar {
        padding: 0.5rem 1rem;
        margin-left: 0 !important;
    }

    .page-title {
        font-size: 1.25rem;
        margin-left: 3rem;
    }

    /* Encabezados de página responsive */
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .d-flex.justify-content-between .btn {
        width: 100%;
    }

    /* Tarjetas de estadísticas apiladas */
    .stat-card {
        padding: 1rem;
    }

    .stat-info h4 {
        font-size: 1.25rem;
    }

    .stat-icon {
        font-size: 2rem;
    }

    /* Botones de acción más grandes */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .btn:hover {
        transform: none; /* Deshabilitar efecto hover en móvil */
    }

    /* Botones pequeños en tablas */
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
        min-width: 40px;
        min-height: 40px;
    }

    /* Tablas responsive */
    .table {
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
    }

    /* Columnas de acciones siempre visibles */
    .table th:last-child,
    .table td:last-child {
        position: sticky;
        right: 0;
        background: white;
        box-shadow: -2px 0 4px rgba(0,0,0,0.1);
    }

    /* Ocultar columnas menos importantes en móvil */
    .table .d-none-mobile {
        display: none;
    }

    /* Modales más adaptables en móvil */
    .modal-dialog {
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }

    .modal-content {
        border-radius: 0;
        height: 100vh;
        overflow-y: auto;
    }

    .modal-body {
        padding: 1rem;
        flex: 1;
        overflow-y: auto;
    }

    .modal-xl {
        max-width: 100%;
    }

    /* Formularios más espaciados */
    .form-label {
        font-weight: 600;
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }

    .form-control,
    .form-select {
        font-size: 16px; /* Evita zoom en iOS */
        padding: 0.5rem;
    }

    /* Alertas más compactas */
    .alert {
        font-size: 0.875rem;
        padding: 0.75rem;
    }

    /* Cards sin bordes en móvil */
    .card {
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    .card-header h5 {
        font-size: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Ajustar inputs de búsqueda */
    .input-group {
        flex-wrap: nowrap;
    }
}

/* ========================================
   MEDIA QUERIES - MÓVILES PEQUEÑOS
   ======================================== */
@media (max-width: 576px) {
    /* Texto más pequeño */
    h3 {
        font-size: 1.1rem;
    }

    /* Encabezado de página más compacto */
    .d-flex.justify-content-between h3 {
        font-size: 1rem;
    }

    /* Botones en bloque */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }

    /* Tarjetas aún más compactas */
    .stat-card {
        flex-direction: row; /* Mantener horizontal pero compacto */
        padding: 0.75rem;
    }

    .stat-icon {
        font-size: 1.75rem;
        margin-right: 0.75rem;
    }

    .stat-info h4 {
        font-size: 1.1rem;
    }

    .stat-info p {
        font-size: 0.8rem;
    }

    /* Sidebar header en móvil pequeño */
    .sidebar-header h4 {
        font-size: 1rem;
    }

    /* Navegación más compacta */
    .nav-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .nav-item i {
        font-size: 0.9rem;
    }

    .nav-section {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }

    /* Footer de modales apilado */
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
        padding: 1rem;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }

    /* Tablas más compactas */
    .table {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.375rem 0.2rem;
    }

    .btn-sm {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
        min-width: 36px;
        min-height: 36px;
    }

    /* Cards más compactos */
    .card {
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    .card-header {
        padding: 0.5rem 0.75rem;
    }

    /* Ajustar inputs */
    .form-control,
    .form-select {
        padding: 0.375rem 0.5rem;
    }

    /* Badges más pequeños */
    .badge {
        font-size: 0.7rem;
        padding: 0.25em 0.5em;
    }
}

/* ========================================
   UTILIDADES RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }

    .show-desktop {
        display: block !important;
    }
}

/* Touch-friendly buttons */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-item,
    .table-hover tbody tr {
        min-height: 44px; /* Tamaño mínimo para touch */
    }
}

/* Landscape mode en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 200px;
        left: -200px;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-icon {
        font-size: 1.5rem;
    }

    .stat-info h4 {
        font-size: 1rem;
    }
}

/* ========================================
   ESTILOS ADICIONALES
   ======================================== */

.modal-footer {
    border-top: 2px solid #f0f0f0;
    background: #f8f9fa;
    padding: 1rem 1.5rem;
}

/* Inputs mejorados */
.form-control,
.form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

/* Loading spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Alertas personalizadas */
.alert {
    border-radius: 8px;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Iconos en botones */
.btn i {
    margin-right: 0.25rem;
}

.btn-sm i {
    margin-right: 0.15rem;
}

/* Mejoras en el layout de login */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.login-card {
    animation: fadeIn 0.5s ease-in;
}

/* Mejoras visuales para estados */
.bg-success {
    background-color: #28a745 !important;
}

.bg-warning {
    background-color: #ffc107 !important;
}

.bg-danger {
    background-color: #dc3545 !important;
}

.bg-info {
    background-color: #17a2b8 !important;
}

.bg-primary {
    background-color: #007bff !important;
}

/* Texto en badges */
.badge.bg-warning {
    color: #212529;
}

/* Sombras suaves */
.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* Dashboard chart */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 320px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.kpi-subtitle {
    font-size: 0.85rem;
    color: #6c757d;
}

.kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
}

.kpi-positive {
    background: rgba(40, 167, 69, 0.15);
    color: #198754;
}

.kpi-negative {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.kpi-neutral {
    background: rgba(108, 117, 125, 0.15);
    color: #6c757d;
}

@media (max-width: 768px) {
    .chart-container {
        min-height: 260px;
    }

    .kpi-value {
        font-size: 1.25rem;
    }
}

/* Asegurar que las transiciones no interfieran en inputs */
.form-control,
.form-select,
input,
textarea {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

/* Fix para botones hover en desktop */
@media (min-width: 769px) {
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }

    .stat-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    }
}

/* Arreglar sticky columns en tablas móvil */
@media (max-width: 768px) {
    .table thead th:last-child {
        position: sticky;
        right: 0;
        background: #f8f9fa;
        z-index: 10;
    }
}
