/**
 * ERP EMERGAS - Estilos Principales
 */

/* ============================================
   Variables CSS - Colores Corporativos EMERGAS
   ============================================ */
:root {
    /* Colores corporativos del logo */
    --primary-color: #4FC3F7; /* Celeste */
    --secondary-color: #66BB6A; /* Verde */
    --accent-color: #FF7043; /* Naranja/Rojo */
    
    /* Colores funcionales basados en corporativos */
    --success-color: #66BB6A; /* Verde */
    --danger-color: #FF7043; /* Naranja/Rojo */
    --warning-color: #FFA726; /* Naranja claro */
    --info-color: #4FC3F7; /* Celeste */
    
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-dark: #1f2937;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --sidebar-width: 260px;
    --topbar-height: 60px;
    
    --transition-speed: 0.3s;
}

/* ============================================
   Reset y Base
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--secondary-color);
}

/* ============================================
   Layout Principal
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    overflow-y: auto;
    transition: all var(--transition-speed);
    z-index: 1000;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 110px;
}

.sidebar-logo {
    width: 100%;
    max-width: 200px;
    height: auto;
    object-fit: contain;
    display: block;
}

.sidebar-logo-text {
    width: 100%;
    text-align: center;
}

.sidebar-nav {
    padding: 10px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    transition: all var(--transition-speed);
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(79, 195, 247, 0.2) 0%, rgba(102, 187, 106, 0.1) 100%);
    color: white;
    border-left: 3px solid var(--primary-color);
}

.sidebar-nav .nav-link i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.nav-section-title {
    padding: 15px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.nav-section ul {
    margin-bottom: 15px;
}

.nav-section a {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 40px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.nav-section a:hover {
    background: linear-gradient(90deg, rgba(79, 195, 247, 0.15) 0%, rgba(102, 187, 106, 0.1) 100%);
    color: white;
    border-left: 3px solid var(--secondary-color);
}

.nav-section a i {
    margin-right: 10px;
    width: 18px;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed);
}

.main-content.expanded {
    margin-left: 70px;
}

.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 12px;
    font-size: 20px;
    color: var(--text-primary);
    border-radius: 6px;
    transition: background-color var(--transition-speed);
}

.sidebar-toggle:hover {
    background-color: var(--bg-secondary);
}

.topbar-title h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color var(--transition-speed);
    color: var(--text-primary);
}

.dropdown-toggle:hover {
    background-color: var(--bg-secondary);
}

.btn-user {
    font-size: 14px;
    font-weight: 500;
}

.btn-user i:first-child {
    font-size: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-user i:last-child {
    font-size: 12px;
    transition: transform var(--transition-speed);
}

.dropdown.active .btn-user i:last-child {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    margin-top: 8px;
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s, transform 0.2s;
}

.dropdown.active .dropdown-menu {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-primary);
    transition: background-color var(--transition-speed);
    font-size: 14px;
}

.dropdown-menu a:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
}

.dropdown-menu a i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 5px 0;
}

.page-content {
    flex: 1;
    padding: 30px;
}

.page-footer {
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 20px 30px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   Dashboard
   ============================================ */
.dashboard-container {
    max-width: 1400px;
}

.welcome-section {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
}

.welcome-section h1 {
    font-size: 28px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

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

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
}

/* Colores corporativos del logo - sin degradados */
.kpi-icon.bg-success { background-color: var(--secondary-color); } /* Verde #66BB6A */
.kpi-icon.bg-danger { background-color: var(--accent-color); } /* Rojo/Naranja #FF7043 */
.kpi-icon.bg-info { background-color: var(--primary-color); } /* Celeste #4FC3F7 */
.kpi-icon.bg-warning { background-color: var(--accent-color); } /* Rojo/Naranja #FF7043 */
.kpi-icon.bg-primary { background-color: var(--primary-color); } /* Celeste #4FC3F7 */
.kpi-icon.bg-secondary { background-color: #6b7280; } /* Gris neutro */

.kpi-content h3 {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 5px;
}

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

/* ============================================
   Login Page
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4FC3F7 0%, #66BB6A 50%, #FF7043 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-box {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

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

.login-logo {
    width: 100%;
    max-width: 300px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    object-fit: contain;
}

.login-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

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

.login-form {
    margin-top: 25px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.2);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-block {
    width: 100%;
}

.login-footer {
    margin-top: 25px;
    text-align: center;
    font-size: 13px;
}

.login-footer .version {
    color: var(--text-light);
    margin-top: 15px;
}

/* ============================================
   Alerts - Posicionadas arriba a la derecha
   ============================================ */
.alert {
    position: fixed;
    top: 80px;
    right: 30px;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
    font-size: 14px;
    font-weight: 500;
}

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

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 2px solid #10b981;
    border-left: 5px solid #10b981;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 2px solid #ef4444;
    border-left: 5px solid #ef4444;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 2px solid #f59e0b;
    border-left: 5px solid #f59e0b;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 2px solid #3b82f6;
    border-left: 5px solid #3b82f6;
}

.alert i {
    font-size: 20px;
}

/* ============================================
   Tables
   ============================================ */
.table-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background-color: var(--bg-secondary);
}

.table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

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

.table tbody tr:hover {
    background-color: var(--bg-secondary);
}

/* ============================================
   Badges - IMPORTANTE PARA ESTADOS
   ============================================ */
.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background-color: #e5e7eb;
    color: #6b7280;
}

/* ============================================
   Buttons
   ============================================ */
.btn-success {
    background-color: var(--success-color);
    color: white;
}

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

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    padding: 6px 10px;
}

/* ============================================
   Progress Bars
   ============================================ */
.progress-bar {
    height: 8px;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 3px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 50%, var(--accent-color) 100%);
    transition: width 0.3s;
}

/* ============================================
   Overlay para móviles
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--transition-speed);
}

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

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .main-content.expanded {
        margin-left: 0 !important;
    }
    
    .topbar-title h1 {
        font-size: 18px;
    }
    
    .topbar {
        padding: 0 15px;
    }
    
    .topbar-user span {
        display: none;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .page-content {
        padding: 20px 15px;
    }
    
    .alert {
        right: 15px;
        left: 15px;
        min-width: auto;
    }
}

/* ============================================
   Utilidades
   ============================================ */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

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

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

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-20 {
    padding: 20px;
}

/* Asegurar que los badges sean siempre visibles */
span.badge {
    display: inline-block !important;
    visibility: visible !important;
}
