﻿/**
 * SISTEMA DE REGISTRO CLÍNICO DE PACIENTES - ESTILOS GLOBALES
 * Alianza Fundación ALES & IPS Restaurando Vidas
 */

:root {
  --ales-primary: #1A78C2;
  --ales-primary-hover: #1565A0;
  --ales-cyan: #00E5FF;
  --ips-secondary: #22A45D;
  --ips-green: #00E676;
  --ips-orange: #FF9100;
  --color-purple: #A855F7;
  
  --bg-app: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --border-color: rgba(0, 0, 0, 0.08);
  --text-main: #1E293B;
  --text-muted: #64748B;
  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] {
  --bg-app: #0D111A;
  --bg-card: #151D2E;
  --bg-sidebar: #121826;
  --border-color: rgba(42, 54, 79, 0.85);
  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
}

body {
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* ====================================================================
 * LAYOUT PRINCIPAL (SIDEBAR + CONTENT)
 * ==================================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1040;
}

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

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-badge-icon {
  width: 44px;
  height: 40px;
  border-radius: 10px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 4px;
}

.brand-badge-icon img, .brand-badge-icon svg {
  max-width: 100%;
  max-height: 100%;
}

.brand-text-ales { color: var(--ales-primary); font-weight: 800; font-size: 1.15rem; }
.brand-dot { color: var(--ips-secondary); font-weight: 800; }
.brand-text-ips { color: var(--ips-orange); font-weight: 800; font-size: 1.15rem; }
.brand-text-sub { color: var(--ips-secondary); font-size: 0.75rem; font-weight: 600; display: block; }

.sidebar-nav {
  padding: 1rem 0.75rem;
  flex-grow: 1;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.85rem 0.75rem 0.35rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 0.35rem;
  transition: all 0.22s ease;
}

.sidebar-link:hover {
  background-color: rgba(26, 120, 194, 0.08);
  color: var(--ales-primary);
  transform: translateX(4px);
}

[data-bs-theme="dark"] .sidebar-link:hover {
  background-color: rgba(0, 229, 255, 0.1);
  color: var(--ales-cyan);
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(26, 120, 194, 0.15) 0%, rgba(34, 164, 93, 0.1) 100%);
  color: var(--ales-primary);
  font-weight: 700;
  border-left: 4px solid var(--ales-primary);
}

[data-bs-theme="dark"] .sidebar-link.active {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.18) 0%, rgba(0, 230, 118, 0.12) 100%);
  color: var(--ales-cyan);
  border-left: 4px solid var(--ales-cyan);
}

.sidebar-link .icon-box {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  font-size: 1.25rem;
  flex-shrink: 0;
  background: rgba(26, 120, 194, 0.12);
  color: var(--ales-primary);
  transition: all 0.2s ease;
}

[data-bs-theme="dark"] .sidebar-link .icon-box {
  background: rgba(0, 229, 255, 0.15);
  color: var(--ales-cyan);
}

.sidebar-link.active .icon-box {
  background: var(--ales-primary);
  color: #FFFFFF;
}

[data-bs-theme="dark"] .sidebar-link.active .icon-box {
  background: var(--ales-cyan);
  color: #0D111A;
}

/* Colores específicos de icono */
.icon-primary { background: rgba(26, 120, 194, 0.12) !important; color: var(--ales-primary) !important; }
.icon-warning { background: rgba(255, 145, 0, 0.12) !important; color: var(--ips-orange) !important; }
.icon-success { background: rgba(34, 164, 93, 0.12) !important; color: var(--ips-secondary) !important; }
.icon-purple  { background: rgba(168, 85, 247, 0.12) !important; color: var(--color-purple) !important; }
.icon-info    { background: rgba(0, 229, 255, 0.12) !important; color: #0284C7 !important; }
.icon-rose    { background: rgba(244, 63, 94, 0.12) !important; color: #F43F5E !important; }

/* Contenido Principal */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-navbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1030;
}

.content-body {
  padding: 1.75rem;
  flex-grow: 1;
}

/* ====================================================================
 * TARJETAS Y COMPONENTES VISUALES
 * ==================================================================== */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.stat-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  height: 100%;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 36px -5px rgba(26, 120, 194, 0.2);
  border-color: rgba(26, 120, 194, 0.5);
}

[data-bs-theme="dark"] .stat-card:hover {
  box-shadow: 0 16px 36px -5px rgba(0, 229, 255, 0.25);
  border-color: rgba(0, 229, 255, 0.6);
}

.stat-avatar {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-glow {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 130px;
  height: 130px;
  opacity: 0.2;
  border-radius: 50%;
  pointer-events: none;
}

/* Page Header */
.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-hero {
  background: linear-gradient(135deg, #1A78C2 0%, #155FA0 50%, #22A45D 100%);
  color: #FFFFFF;
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 1.75rem;
  position: relative;
  overflow: hidden;
}

/* Avatar con iniciales */
.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(26, 120, 194, 0.15);
  color: var(--ales-primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  overflow: hidden;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ====================================================================
 * TOAST NOTIFICATIONS GLOBALES
 * ==================================================================== */
.toast-container-custom {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.custom-toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 420px;
  padding: 12px 18px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #FFFFFF;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: slideIn 0.3s ease forwards;
  transition: all 0.3s ease;
}

.custom-toast.toast-success { background: linear-gradient(135deg, #10B981 0%, #059669 100%); }
.custom-toast.toast-error   { background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%); }
.custom-toast.toast-warning { background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%); }
.custom-toast.toast-info    { background: linear-gradient(135deg, #0EA5E9 0%, #0284C7 100%); }

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

/* ====================================================================
 * RESPONSIVE MOBILE
 * ==================================================================== */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -280px;
  }
  .sidebar.show {
    left: 0;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
  }
  .sidebar-backdrop.show {
    display: block;
  }
}
