/* ===== VARIABLES CSS ===== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --info-color: #22d3ee;
    --background: #0f172a;
    --surface: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
}

/* ===== RESET Y BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    transition: var(--transition);
    line-height: 1.6;
}

/* ===== UTILIDADES ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== BOTONES ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

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

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

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

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== FORMULARIOS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
    min-height: 44px;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.error, .form-select.error, .form-textarea.error {
    border-color: var(--danger-color);
}

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

.input-group {
    position: relative;
}

.input-group .form-input {
    padding-right: 50px;
}

.input-group-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.input-group-btn:hover {
    color: var(--primary-color);
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.card-icon {
    font-size: 2.5rem;
    padding: 15px;
    border-radius: var(--radius);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    min-height: 70px;
}

.card-icon.primary { background: var(--primary-color); }
.card-icon.success { background: var(--success-color); }
.card-icon.danger { background: var(--danger-color); }
.card-icon.warning { background: var(--warning-color); }
.card-icon.info { background: var(--info-color); }

.card-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== GRID SYSTEMS ===== */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ===== MODALES ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    animation: slideUp 0.3s ease;
}

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

.modal-title {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: var(--radius);
    transition: var(--transition);
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--danger-color);
    color: white;
}

/* ===== TABLAS ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th,
.table td {
    padding: 15px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: var(--background);
}

.table .status {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.status.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.status.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

/* ===== NAVEGACIÃƒâ€œN ===== */
.nav-menu {
    list-style: none;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-color);
    color: white;
}

.nav-icon {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

/* ===== NOTIFICACIONES ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    max-width: 400px;
    animation: slideInRight 0.5s ease;
}

.notification.error {
    background: var(--danger-color);
}

.notification.warning {
    background: var(--warning-color);
}

.notification.info {
    background: var(--info-color);
}

/* ===== LOADING STATES ===== */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===== ESTADOS ESPECIALES ===== */
.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

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

.text-right {
    text-align: right;
}

.text-success {
    color: var(--success-color);
}

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

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

.text-muted {
    color: var(--text-secondary);
}

/* ===== ANIMACIONES ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ===== LOGIN ESPECÃƒÂFICO ===== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 450px;
    animation: slideUp 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.user-selection {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.user-btn {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    width: 100%;
    min-height: 100px;
}

.user-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.user-btn.selected {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
}

.user-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.user-title {
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.user-desc {
    font-size: 0.9rem;
    opacity: 0.8;
}

.password-section {
    animation: fadeIn 0.5s ease;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--primary-color);
}

.login-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 15px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
}

.login-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.demo-info {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius);
    padding: 15px;
    margin: 20px 0;
    text-align: center;
    font-size: 0.9rem;
}

.demo-info code {
    background: rgba(37, 99, 235, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger-color);
    animation: pulse 2s infinite;
}

.status-indicator.online {
    background: var(--success-color);
}

.status-indicator.offline {
    background: var(--warning-color);
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-btn {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.theme-btn:hover {
    transform: scale(1.1);
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== PWA INSTALL ===== */
.install-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 20px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    font-weight: 600;
    z-index: 1000;
}

.install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 25px 50px -12px rgba(16, 185, 129, 0.25);
}

/* ===== NAVIGATION TABS ===== */
.nav-tabs {
    display: flex;
	justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-tab {
    background: transparent;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-tab:hover {
    background: var(--background);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ===== TABLE RESPONSIVE ===== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== SYNC QUEUE ===== */
.sync-queue {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--warning-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.sync-badge {
    background: white;
    color: var(--warning-color);
    padding: 0.25rem 0.5rem;
    border-radius: 50%;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

/* ===== MODAL LARGE ===== */
.modal-large {
    max-width: 1200px;
}

/* ===== LOAD ITEMS ===== */
.load-items {
    max-height: 300px;
    overflow-y: auto;
    margin: 1rem 0;
}

.load-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.load-total {
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-top: 1rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.total-row:last-child {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--success-color);
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 1rem;
}

/* ===== SPINNING ANIMATION ===== */
.spinning {
    animation: spin 1s linear infinite;
}

/* ===== BUTTON SMALL ===== */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* ===== RESPONSIVE TABS ===== */
@media (max-width: 768px) {
    .nav-tabs {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-tab {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        flex: 0 0 calc(33.333% - 0.5rem);
        text-align: center;
    }
}


/* Estilos para detalle de ventas expandible */
.expandible-trigger:hover {
    background-color: rgba(102, 126, 234, 0.1);
    border-radius: 4px;
}

.detalle-venta-item {
    display: flex;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: #495057;
}

.detalle-venta-item:not(:last-child) {
    border-bottom: 1px solid #e9ecef;
}