/* ============================================
   ERP MULTI-EMPRESA - Estilos Globales
   ============================================ */

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

a { text-decoration: none; color: #4361ee; }
a:hover { color: #3a56d4; }

/* ===== Login ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4361ee 0%, #7209b7 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo { font-size: 3rem; margin-bottom: 10px; }

.login-header h1 {
    font-size: 1.5rem;
    color: #1a1a2e;
}

.login-header p {
    color: #6c757d;
    font-size: 0.9rem;
    margin-top: 5px;
}

.login-form .form-group { margin-bottom: 20px; }

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
}

.login-form input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s;
    outline: none;
}

.login-form input:focus {
    border-color: #4361ee;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    font-size: 0.85rem;
    color: #6c757d;
}

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 250px;
    background: #1a1a2e;
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.sidebar-header .empresa-nombre {
    font-size: 0.8rem;
    color: #a0a0b8;
}

.sidebar-user {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #4361ee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
}

.sidebar-user .user-info .name {
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-user .user-info .role {
    font-size: 0.75rem;
    color: #a0a0b8;
}

.nav-section {
    padding: 15px 20px 5px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6c6c8a;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #c0c0d0;
    transition: all 0.3s;
    gap: 10px;
    font-size: 0.9rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.nav-item.active {
    background: #4361ee;
    color: #fff;
}

.nav-item .icon { font-size: 1.2rem; width: 24px; text-align: center; }

/* ===== Main Content ===== */
.main-content {
    margin-left: 250px;
    flex: 1;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 99;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle-sidebar {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #333;
}

.page-title { font-size: 1.3rem; font-weight: 600; }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar-right .empresa-badge {
    background: #e8f4ff;
    color: #4361ee;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-logout {
    background: none;
    border: 1px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #666;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: #fee;
    border-color: #faa;
    color: #d00;
}

.content-area {
    padding: 30px;
}

/* ===== Cards ===== */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 25px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.card-header h3 { font-size: 1.1rem; }

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: #e8f4ff; }
.stat-icon.green { background: #e8f8e8; }
.stat-icon.orange { background: #fff3e0; }
.stat-icon.purple { background: #f3e8ff; }

.stat-info .stat-number {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-info .stat-label {
    font-size: 0.85rem;
    color: #6c757d;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
}

table tr:hover {
    background: #f8f9ff;
}

table .actions {
    display: flex;
    gap: 8px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary { background: #4361ee; color: #fff; }
.btn-primary:hover { background: #3a56d4; }

.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }

.btn-success { background: #2dce89; color: #fff; }
.btn-success:hover { background: #26b978; }

.btn-danger { background: #f5365c; color: #fff; }
.btn-danger:hover { background: #d62d4f; }

.btn-warning { background: #fb6340; color: #fff; }
.btn-warning:hover { background: #e05a3a; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.3s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4361ee;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error { background: #fee; color: #c33; border: 1px solid #fcc; }
.alert-success { background: #e8f8e8; color: #2a8; border: 1px solid #bfb; }
.alert-info { background: #e8f4ff; color: #36a; border: 1px solid #bdf; }

/* ===== Grid Modules ===== */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.module-card {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: all 0.3s;
}

.module-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.module-icon {
    font-size: 2rem;
    margin-bottom: 15px;
}

.module-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.module-card p {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 15px;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
}

/* ===== Excel-like Table for BOM Components ===== */
.bom-excel-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9rem;
}

.bom-excel-table thead {
    background: #217346;
    color: #fff;
}

.bom-excel-table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border: 1px solid #1e6b3d;
}

.bom-excel-table td {
    padding: 6px 8px;
    border: 1px solid #d0d0d0;
    background: #fff;
}

.bom-excel-table tbody tr:hover td {
    background: #f5f5f5;
}

.bom-excel-table input,
.bom-excel-table select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 0.9rem;
    font-family: inherit;
}

.bom-excel-table input:focus,
.bom-excel-table select:focus {
    outline: 2px solid #217346;
    outline-offset: -2px;
}

.bom-excel-table .btn-remove-row {
    background: #ff4444;
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bom-excel-table .btn-remove-row:hover {
    background: #cc0000;
}

.bom-excel-container {
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid #d0d0d0;
    border-radius: 4px;
}

.bom-excel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.bom-excel-toolbar .btn {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* ===== Excel-style Table for Data Tables (Productos, Facturas, etc) ===== */
table.excel-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 0.85rem !important;
    border: 1px solid #c0c0c0 !important;
}

table.excel-table thead {
    background: #4472c4 !important;
    color: #fff !important;
}

table.excel-table thead th {
    padding: 10px 12px !important;
    text-align: left !important;
    font-weight: 600 !important;
    border: 1px solid #3762a3 !important;
    white-space: nowrap !important;
    color: #fff !important;
    background: #4472c4 !important;
}

table.excel-table tbody td {
    padding: 8px 12px !important;
    border: 1px solid #d0d0d0 !important;
    background: #fff !important;
}

table.excel-table tbody tr:nth-child(even) td {
    background: #f8f9fb !important;
}

table.excel-table tbody tr:hover td {
    background: #e8f0fe !important;
}

table.excel-table tbody td.actions {
    white-space: nowrap !important;
}

table.excel-table .badge {
    display: inline-block !important;
    padding: 3px 10px !important;
    border-radius: 12px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle-sidebar {
        display: block;
    }
    
    .content-area {
        padding: 20px 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        padding: 12px 15px;
    }
    
    .page-title {
        font-size: 1rem;
    }
}