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

:root {
    /* Colores principales */
    --primary: #ff6b35;
    --primary-dark: #e55a2a;
    --secondary: #004e89;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    
    /* Grises */
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --border: #e0e0e0;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    
    /* Sombras */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    
    /* Tipografía */
    --font-main: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

body {
    font-family: var(--font-main);
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LOGIN
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.4s ease-out;
}

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

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

.login-title {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 5px;
}

.login-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 600;
}

.login-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-footer code {
    background: #f4f4f4;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--primary);
}

.text-small {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

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

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    font-family: var(--font-main);
    transition: all 0.2s;
    background: var(--bg-card);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
}

.form-group input[readonly] {
    background: #f8f9fa;
    cursor: not-allowed;
}

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

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

/* ============================================
   BOTONES
   ============================================ */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    background: #ecf0f1;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #d5dbdb;
}

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

.btn-success:hover {
    background: #27ae60;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions button {
    flex: 1;
}

/* ============================================
   HEADER Y NAVEGACIÓN
   ============================================ */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

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

.header-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    display: none;
}

.btn-menu,
.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
    transition: transform 0.2s;
}

.btn-menu:active,
.btn-close:active {
    transform: scale(0.9);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    transition: left 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

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

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 800;
}

.sidebar-menu {
    list-style: none;
    padding: 12px;
}

.sidebar-menu li {
    margin-bottom: 8px;
}

.sidebar-menu a {
    display: block;
    padding: 14px 16px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s;
}

.sidebar-menu a:hover {
    background: var(--bg-main);
}

.sidebar-menu a.active {
    background: var(--primary);
    color: white;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

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

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */
.main-content {
    flex: 1;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ============================================
   TARJETAS
   ============================================ */
.inventory-form,
.filters-card,
.recent-records {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.recent-records h2,
.filters-card h2 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* ============================================
   INFORMACIÓN DE ARTÍCULO
   ============================================ */
.articulo-info {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    border-left: 4px solid var(--primary);
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

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

.info-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   REGISTROS RECIENTES
   ============================================ */
.records-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.record-item {
    background: var(--bg-main);
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid var(--primary);
}

.record-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.record-code {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary);
    font-size: 14px;
}

.record-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.record-details {
    font-size: 14px;
    color: var(--text-secondary);
}

.record-cantidad {
    margin-top: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   ESTADÍSTICAS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--primary);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============================================
   FILTROS
   ============================================ */
.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* ============================================
   TABS
   ============================================ */
.tabs-container {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    padding: 12px 20px;
    border: none;
    background: var(--bg-main);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

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

.tab-content {
    display: none;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: var(--bg-main);
}

.data-table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: var(--bg-main);
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* ============================================
   MODALES
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.3s ease-out;
}

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

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 800;
}

.modal-content form {
    padding: 24px;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    animation: toastSlideUp 0.3s ease-out;
    max-width: 90%;
    text-align: center;
    font-weight: 600;
}

.toast.hidden {
    display: none;
}

.toast.success {
    background: var(--success);
}

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

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ============================================
   UTILIDADES
   ============================================ */
.hidden {
    display: none !important;
}

.error-message {
    background: #fee;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
    font-weight: 600;
    border-left: 4px solid var(--danger);
}

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

.section-header h2 {
    font-size: 18px;
    font-weight: 800;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (min-width: 768px) {
    .user-name {
        display: block;
    }
    
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-actions button {
        flex: initial;
        min-width: 150px;
    }
}

/* ============================================
   RESPONSIVE - DESKTOP
   ============================================ */
@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .filters-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .info-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   IMPORTACIÓN DE ARTÍCULOS
   ============================================ */
.import-section {
    max-width: 700px;
    margin: 0 auto;
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.6;
}

.alert-info {
    background: #e3f2fd;
    color: #0d47a1;
    border-left: 4px solid #2196f3;
}

.alert p {
    margin: 8px 0;
}

.alert strong {
    font-weight: 700;
}

.import-progress {
    margin: 24px 0;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

#progressText {
    text-align: center;
    font-size: 14px;
    color: #666;
    font-weight: 600;
}

.import-result {
    margin-top: 24px;
    padding: 20px;
    border-radius: 8px;
    font-size: 14px;
}

.import-result.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #4caf50;
}

.import-result.error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #f44336;
}

.import-result h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.import-result ul {
    margin: 8px 0;
    padding-left: 20px;
}

.import-result li {
    margin: 4px 0;
}

input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="file"]:hover {
    border-color: var(--primary);
    background: #f0f7ff;
}

input[type="file"]:focus {
    outline: none;
    border-color: var(--primary);
}
