/* =========================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
   ========================================= */
:root {
    --guinda-primary: #9E1A3C;
    --guinda-dark: #6B0F2A;
    --guinda-light: #c2274f;
    --oro-primary: #BC955C;
    --oro-light: #d4b281;
    --bg-app: #f0f2f5;
    --bg-card: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border-soft: #e1e8ed;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f1c40f;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 16px rgba(0,0,0,0.08);
    --radius-lg: 16px;
    --radius-md: 10px;
}

* { box-sizing: border-box; }

body { 
    font-family: 'Montserrat', sans-serif; 
    background-color: var(--bg-app); 
    color: var(--text-main);
    margin: 0; 
    overflow-x: hidden;
}

/* Scrollbar Personalizado */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-app); }
::-webkit-scrollbar-thumb { background: var(--oro-primary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--guinda-primary); }

/* =========================================
   LOGIN
   ========================================= */
.login-body {
    background: linear-gradient(135deg, var(--guinda-dark) 0%, var(--guinda-primary) 100%);
    display: flex; align-items: center; justify-content: center; height: 100vh;
}

.login-contenedor {
    background: var(--bg-card); padding: 40px; border-radius: var(--radius-lg); width: 100%; max-width: 400px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.4); text-align: center;
}

.login-header h1 { color: var(--guinda-primary); font-weight: 800; margin-bottom: 5px; }

/* =========================================
   ESTRUCTURA PRINCIPAL (LAYOUT)
   ========================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Menú Lateral (Sidebar) --- */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--guinda-dark) 0%, #4a091c 100%);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    z-index: 20;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* LOGO INSTITUCIONAL (CÍRCULO BLANCO) */
.logo-circle {
    background: #ffffff;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    margin: 0 auto 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    padding: 15px;
}

.logo-circle img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sidebar-header h2 {
    font-size: 20px; margin: 15px 0 0; font-weight: 800; letter-spacing: 1px; color: white;
}

.sidebar-menu {
    flex: 1; padding: 20px 0; overflow-y: auto;
}

.menu-label {
    padding: 0 25px; font-size: 11px; text-transform: uppercase; color: var(--oro-primary);
    font-weight: 800; margin-bottom: 15px; letter-spacing: 1.5px; opacity: 0.8;
}

.menu-item {
    display: flex; align-items: center; padding: 14px 25px; color: rgba(255,255,255,0.7);
    text-decoration: none; font-weight: 600; font-size: 14px; transition: all 0.3s ease;
    border-left: 4px solid transparent; margin-bottom: 5px;
}

.menu-item:hover, .menu-item.active {
    background: rgba(255,255,255,0.08); color: white; border-left-color: var(--oro-primary);
}

.menu-item i { width: 30px; font-size: 18px; color: var(--oro-primary); }
.menu-item:hover i, .menu-item.active i { color: white; }

/* --- Contenido (Main Content) --- */
.main-content {
    flex: 1; display: flex; flex-direction: column; width: calc(100% - 280px);
}

.topbar {
    background: var(--bg-card); border-bottom: 1px solid var(--border-soft);
    padding: 20px 40px; display: flex; justify-content: space-between; align-items: center;
    box-shadow: var(--shadow-sm); z-index: 10;
}

.topbar h3 { margin: 0; color: var(--guinda-primary); font-weight: 800; font-size: 22px; }

.content-wrapper { padding: 40px; overflow-y: auto; }

/* =========================================
   COMPONENTES UI (Tarjetas, Botones, Inputs)
   ========================================= */
.tarjeta {
    background: var(--bg-card); border-radius: var(--radius-lg); padding: 30px; 
    box-shadow: var(--shadow-md); border-top: 4px solid var(--guinda-primary);
    margin-bottom: 30px; transition: transform 0.3s ease;
}
.tarjeta:hover { transform: translateY(-2px); }

.tarjeta-header {
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 2px solid var(--bg-app); padding-bottom: 15px; margin-bottom: 25px;
}
.tarjeta-header h3 { margin: 0; color: var(--guinda-primary); font-size: 18px; }

/* Formularios */
.form-grupo { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
.form-input, .form-select {
    width: 100%; padding: 12px 15px; border: 2px solid var(--border-soft);
    border-radius: var(--radius-md); font-size: 14px; font-family: inherit;
    transition: all 0.3s ease; background: #fafafa; color: var(--text-main);
}
.form-input:focus, .form-select:focus {
    border-color: var(--oro-primary); outline: none; background: white;
    box-shadow: 0 0 0 4px rgba(188, 149, 92, 0.1);
}

/* Botones */
.btn-guinda {
    background: linear-gradient(135deg, var(--guinda-primary) 0%, var(--guinda-dark) 100%);
    color: white; border: none; padding: 12px 24px; border-radius: var(--radius-md);
    cursor: pointer; font-weight: 700; font-size: 14px; text-transform: uppercase;
    letter-spacing: 0.5px; transition: all 0.3s ease; display: inline-flex; align-items: center; gap: 8px;
    box-shadow: 0 4px 15px rgba(158, 26, 60, 0.2);
}
.btn-guinda:hover {
    transform: translateY(-2px); box-shadow: 0 6px 20px rgba(158, 26, 60, 0.4);
}
.btn-guinda:disabled { background: #ccc; cursor: not-allowed; transform: none; box-shadow: none; }

/* Tablas Premium */
.tabla-container { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-soft); }
.tabla-moderna { width: 100%; border-collapse: collapse; text-align: left; background: white; }
.tabla-moderna th {
    background: #f8f9fa; color: var(--text-muted); font-size: 12px; font-weight: 700;
    text-transform: uppercase; padding: 16px; border-bottom: 2px solid var(--border-soft);
}
.tabla-moderna td { padding: 16px; border-bottom: 1px solid var(--border-soft); font-size: 14px; font-weight: 500; }
.tabla-moderna tbody tr:hover { background: #fdfdfd; }

/* Badges (Etiquetas de estado) */
.badge { padding: 6px 12px; border-radius: 20px; font-size: 11px; font-weight: 800; letter-spacing: 0.5px; }
.badge-activo { background: rgba(39, 174, 96, 0.1); color: var(--success); }
.badge-inactivo { background: rgba(231, 76, 60, 0.1); color: var(--danger); }

/* =========================================
   VENTANAS MODALES (POPUPS)
   ========================================= */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal.active { display: flex; }
.modal-content { background: white; padding: 30px; border-radius: var(--radius-lg); width: 100%; max-width: 500px; position: relative; box-shadow: 0 15px 30px rgba(0,0,0,0.3); animation: slideIn 0.3s ease-out; }
.close-modal { position: absolute; right: 20px; top: 20px; font-size: 24px; cursor: pointer; color: #999; transition: 0.3s; }
.close-modal:hover { color: var(--danger); }
@keyframes slideIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* =========================================
   CHAT IA WIDGET
   ========================================= */
#chat-widget { position: fixed; bottom: 30px; right: 30px; z-index: 9999; }
#chat-btn { background: var(--oro-primary); color: white; width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; box-shadow: 0 5px 15px rgba(0,0,0,0.3); transition: 0.3s; }
#chat-btn:hover { transform: scale(1.1); }
#chat-panel { display: none; width: 350px; height: 450px; background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); position: absolute; bottom: 80px; right: 0; flex-direction: column; overflow: hidden; border: 1px solid var(--border-soft); }
#chat-header { background: var(--guinda-primary); color: white; padding: 15px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; }
#chat-body { flex: 1; padding: 15px; overflow-y: auto; background: #f9f9f9; display: flex; flex-direction: column; gap: 10px; }
#chat-input-area { display: flex; padding: 10px; border-top: 1px solid var(--border-soft); background: white; }
#chat-input-area input { flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 20px; outline: none; font-family: inherit; }
#chat-input-area button { background: var(--oro-primary); color: white; border: none; width: 40px; height: 40px; border-radius: 50%; margin-left: 10px; cursor: pointer; transition: 0.3s; }
#chat-input-area button:hover { background: #a6814c; }
.msg { max-width: 80%; padding: 10px 15px; border-radius: 15px; font-size: 13px; line-height: 1.4; }
.msg-ia { background: white; border: 1px solid #ddd; align-self: flex-start; border-bottom-left-radius: 2px; }
.msg-user { background: var(--guinda-primary); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }

/* =========================================
   NOTIFICACIONES TOAST
   ========================================= */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: white; border-left: 5px solid var(--guinda-primary); padding: 15px 25px; border-radius: 8px; box-shadow: var(--shadow-md); color: var(--text-main); font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 10px; animation: slideInRight 0.3s forwards; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }