/* =============================================
   ESTILOS GLOBALES - Sistema POS Offline
   ============================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* Colores principales */
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Grises */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Gradientes */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-info: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Bordes */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transiciones - RÁPIDAS para POS */
    --transition-fast: 0s;
    --transition: 0.1s ease;
    --transition-slow: 0.15s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gradient-primary);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.5;
}

/* =============================================
   SIDEBAR - Menú lateral
   ============================================= */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 25px 20px;
    background: rgba(0, 0, 0, 0.2);
    text-align: center;
}

.sidebar-logo {
    font-size: 28px;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sidebar-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 15px;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: all var(--transition);
    font-weight: 500;
    border-left: 4px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(5px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left-color: var(--success);
    font-weight: 600;
}

.nav-icon {
    font-size: 22px;
    width: 28px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.offline-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: rgba(16, 185, 129, 0.2);
    border-radius: var(--radius);
    color: #6ee7b7;
    font-size: 13px;
    font-weight: 600;
}

.offline-badge::before {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Botón hamburguesa */
.hamburger-btn {
    position: fixed;
    left: 20px;
    top: 20px;
    width: 50px;
    height: 50px;
    background: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: all var(--transition);
}

.hamburger-btn:hover {
    box-shadow: var(--shadow-xl);
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =============================================
   HEADER
   ============================================= */

.header {
    background: var(--gradient-primary);
    color: white;
    padding: 30px 25px;
    padding-left: 90px;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.header p {
    font-size: 15px;
    opacity: 0.9;
}

/* =============================================
   CONTENEDOR PRINCIPAL
   ============================================= */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 25px;
}

/* =============================================
   TARJETAS
   ============================================= */

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 25px;
}

/* =============================================
   ESTADÍSTICAS
   ============================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.stat-card.primary::before {
    background: var(--gradient-primary);
}

.stat-card.success::before {
    background: var(--gradient-success);
}

.stat-card.warning::before {
    background: var(--gradient-warning);
}

.stat-card.info::before {
    background: var(--gradient-info);
}

.stat-card.danger::before {
    background: var(--gradient-danger);
}

.stat-icon {
    font-size: 40px;
    margin-bottom: 15px;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-value {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
}

.stat-card.primary .stat-value {
    color: var(--primary);
}

.stat-card.success .stat-value {
    color: var(--success);
}

.stat-card.warning .stat-value {
    color: var(--warning);
}

.stat-card.info .stat-value {
    color: var(--info);
}

.stat-card.danger .stat-value {
    color: var(--danger);
}

/* =============================================
   FORMULARIOS
   ============================================= */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control.large {
    padding: 18px 20px;
    font-size: 18px;
    font-family: 'Courier New', monospace;
}

/* =============================================
   BOTONES
   ============================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.6);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.6);
}

.btn-outline {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    box-shadow: none;
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

.btn-lg {
    padding: 18px 32px;
    font-size: 18px;
}

.btn-sm {
    padding: 10px 16px;
    font-size: 13px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 18px;
}

.btn-block {
    width: 100%;
}

/* =============================================
   TABLAS
   ============================================= */

.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: var(--gray-50);
}

.table-actions {
    display: flex;
    gap: 8px;
}

/* =============================================
   BADGES
   ============================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-primary {
    background: #e0e7ff;
    color: #3730a3;
}

/* =============================================
   MODALES
   ============================================= */

.modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-content.large {
    max-width: 700px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: var(--gradient-primary);
    color: white;
    padding: 25px;
    text-align: center;
}

.modal-header h2 {
    font-size: 22px;
    margin-bottom: 5px;
}

.modal-header p {
    font-size: 14px;
    opacity: 0.9;
}

.modal-body {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 30px;
    background: var(--gray-50);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 20px;
    transition: all var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =============================================
   ALERTAS / NOTIFICACIONES
   ============================================= */

.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn var(--transition);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10002;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideInRight var(--transition);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast.info {
    border-left: 4px solid var(--info);
}

/* =============================================
   ESTADOS VACÍOS
   ============================================= */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-icon {
    font-size: 80px;
    opacity: 0.3;
    margin-bottom: 20px;
}

.empty-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 10px;
}

.empty-text {
    font-size: 14px;
    color: var(--gray-500);
}

/* =============================================
   UTILIDADES
   ============================================= */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-muted {
    color: var(--gray-500);
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 8px;
}

.gap-2 {
    gap: 16px;
}

.gap-3 {
    gap: 24px;
}

.hidden {
    display: none !important;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
    .header {
        padding: 20px 15px;
        padding-left: 80px;
    }

    .header h1 {
        font-size: 22px;
    }

    .container {
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 28px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

/* =============================================
   IMPRESIÓN
   ============================================= */

@media print {

    .sidebar,
    .hamburger-btn,
    .sidebar-overlay,
    .no-print {
        display: none !important;
    }

    body {
        background: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* =============================================
   MEJORAS MÓVILES (PHONE FIXES)
   ============================================= */
@media (max-width: 768px) {

    /* 1. INVENTARIO: Filtros e Inputs uno encima del otro */
    .bulk-actions,
    .inventory-header,
    .filter-section {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .filter-select,
    .search-box,
    .view-toggle,
    .view-btn,
    .btn-config {
        width: 100% !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    /* 2. MENU DROPDOWN (Categorías): Que no se corte */
    select.filter-select {
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }

    /* 3. CONFIGURACIÓN: El botón ON/OFF no debe aplastarse */
    .toggle-group {
        display: flex !important;
        flex-direction: row !important;
        /* Mantener en línea... */
        justify-content: space-between !important;
        align-items: center !important;
        padding: 15px 5px !important;
    }

    .toggle-switch {
        flex-shrink: 0 !important;
        /* ...pero PROHIBIDO aplastarse */
        margin-left: 10px;
    }

    .toggle-label {
        font-size: 14px !important;
        padding-right: 10px;
    }

    /* 4. DASHBOARDS: Estadísticas en 2 columnas (no 1 gigante) */
    .stats-grid,
    .inventory-stats {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .stat-card,
    .inventory-stat {
        padding: 15px !important;
    }

    .stat-value,
    .inventory-stat-value {
        font-size: 24px !important;
    }

    /* 5. GENERAL */
    .container {
        padding: 10px !important;
    }

    h1 {
        font-size: 20px !important;
    }
}