/* ═══════════════════════════════════════════════════════════════
    MediFind — Hoja de estilos compartida
    Fuentes: DM Sans (cuerpo) + DM Serif Display (títulos)
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Serif+Display&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --purple-dark:   #1e0a5c;
  --purple-mid:    #2b0a78;
  --purple-light:  #4c1d95;
  --purple-soft:   #ede9fe;
  --purple-glow:   rgba(76, 29, 149, 0.15);
  --accent:        #7c3aed;
  --accent-light:  #a78bfa;
  --white:         #ffffff;
  --gray-50:       #f8fafc;
  --gray-100:      #f1f5f9;
  --gray-200:      #e2e8f0;
  --gray-400:      #94a3b8;
  --gray-600:      #475569;
  --gray-900:      #0f172a;
  --red:           #ef4444;
  --shadow-sm:     0 2px 8px rgba(0,0,0,.06);
  --shadow-md:     0 8px 24px rgba(30,10,92,.10);
  --shadow-lg:     0 20px 50px rgba(30,10,92,.15);
  --shadow-xl:     0 30px 70px rgba(30,10,92,.20);
  --radius-sm:     8px;
  --radius-md:     14px;
  --radius-lg:     22px;
  --radius-xl:     30px;
  --transition:    .25s cubic-bezier(.4,0,.2,1);
}

/* ── Reinicio y base ──────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
}

/* ── Animaciones de fotograma clave ───────────────────────────────────── */
@keyframes fadeUp {
  from { opacity:0; transform:translateY(24px); }
  to   { opacity:1; transform:translateY(0); }
}

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

@keyframes slideInLeft {
  from { opacity:0; transform:translateX(-30px); }
  to   { opacity:1; transform:translateX(0); }
}

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

@keyframes scaleIn {
  from { opacity:0; transform:scale(.94); }
  to   { opacity:1; transform:scale(1); }
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(124,58,237,.35); }
  70%  { box-shadow: 0 0 0 10px rgba(124,58,237,0); }
  100% { box-shadow: 0 0 0 0 rgba(124,58,237,0); }
}

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* ── Diseño base ───────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════════
    BARRA LATERAL
══════════════════════════════════════════════════════════════ */
.sidebar {
  width: 220px;
  background: linear-gradient(170deg, var(--purple-dark) 0%, var(--purple-light) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  animation: slideInLeft .5s var(--transition) both;
}

/* orbe decorativo detrás de la barra lateral */
.sidebar::before {
  content: '';
  position: absolute;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(167,139,250,.18) 0%, transparent 70%);
  top: -60px; left: -60px;
  pointer-events: none;
}

.sidebar-logo {
  padding: 0;
  flex-shrink: 0;
}
.sidebar-logo img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: opacity var(--transition);
}
.sidebar-logo img:hover { opacity: .85; }

.sidebar .menu {
  flex: 1;
  padding: 12px 0;
}

.sidebar .menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px;
  text-decoration: none;
  color: rgba(255,255,255,.75);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), padding-left var(--transition);
  position: relative;
}

.sidebar .menu a::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent-light);
  border-radius: 0 3px 3px 0;
  transform: scaleY(0);
  transition: transform var(--transition);
}

.sidebar .menu a:hover,
.sidebar .menu a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  padding-left: 26px;
}

.sidebar .menu a:hover::before,
.sidebar .menu a.active::before {
  transform: scaleY(1);
}

.sidebar .menu a svg {
  flex-shrink: 0;
  opacity: .8;
}
.sidebar .menu a:hover svg,
.sidebar .menu a.active svg { opacity: 1; }

.sidebar-footer {
  padding: 20px 22px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-footer a {
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logout-btn { color: rgba(255,255,255,.65); }
.logout-btn:hover { color: #fff; }
.delete-btn { color: #fca5a5; }
.delete-btn:hover { color: #f87171; }

/* ══════════════════════════════════════════════════════════════
    BARRA SUPERIOR
══════════════════════════════════════════════════════════════ */
.topbar {
  height: 64px;
  background: var(--white);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0 32px;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  animation: fadeIn .4s ease both;
}

.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--purple-soft);
  padding: 7px 16px 7px 8px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 600;
  color: var(--purple-mid);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.topbar .user-chip:hover {
  background: #ddd6fe;
  transform: translateY(-1px);
}
.topbar .user-chip .avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--purple-mid), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
}

.topbar .bell-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--gray-100);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600);
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.topbar .bell-btn:hover {
  background: var(--purple-soft);
  color: var(--purple-mid);
  transform: rotate(12deg);
}

/* ══════════════════════════════════════════════════════════════
    ÁREA DE CONTENIDO
══════════════════════════════════════════════════════════════ */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main {
  flex: 1;
  padding: 36px 40px;
  overflow-y: auto;
  animation: fadeUp .5s .15s var(--transition) both;
}

/* ══════════════════════════════════════════════════════════════
    TARJETAS
══════════════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(226,232,240,.8);
  transition: box-shadow var(--transition), transform var(--transition);
  animation: scaleIn .45s var(--transition) both;
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--purple-mid);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ══════════════════════════════════════════════════════════════
    BOTONES
══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-xl);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.15);
  opacity: 0;
  transition: opacity var(--transition);
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--purple-mid), var(--accent));
  color: var(--white);
  box-shadow: 0 4px 16px rgba(76,29,149,.35);
}
.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(76,29,149,.45);
  transform: translateY(-2px);
}

.btn-outline {
  background: var(--white);
  color: var(--purple-mid);
  border: 2px solid var(--purple-mid);
}
.btn-outline:hover {
  background: var(--purple-soft);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: white;
  box-shadow: 0 4px 16px rgba(220,38,38,.3);
}
.btn-danger:hover {
  box-shadow: 0 6px 24px rgba(220,38,38,.4);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 8px 18px;
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════════
    CAMPOS DE FORMULARIO
══════════════════════════════════════════════════════════════ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.field-group input,
.field-group textarea,
.field-group select {
  padding: 12px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}

.field-group input::placeholder { color: var(--gray-400); }

/* ══════════════════════════════════════════════════════════════
    PIE DE PÁGINA
══════════════════════════════════════════════════════════════ */
.main-footer {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  text-align: center;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  flex-shrink: 0;
}

.main-footer a {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition);
}
.main-footer a:hover { color: var(--purple-mid); }

.main-footer p {
  font-size: 12px;
  color: var(--gray-400);
  margin-left: auto;
}

/* ══════════════════════════════════════════════════════════════
    MODAL
══════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease both;
}
.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: scaleIn .25s var(--transition) both;
}
.modal-box h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--gray-900);
  margin-bottom: 10px;
}
.modal-box p {
  color: var(--gray-600);
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.6;
}
.modal-box textarea {
  width: 100%;
  height: 90px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  margin-bottom: 24px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
}
.modal-box textarea:focus { border-color: var(--accent); }
.modal-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ══════════════════════════════════════════════════════════════
    ALERTA / NOTIFICACIÓN
══════════════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: none;
  animation: fadeUp .3s ease both;
}
.alert.show { display: block; }
.alert-error   { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; }

/* ══════════════════════════════════════════════════════════════
    ANIMACIONES ESCALONADAS (hijos)
══════════════════════════════════════════════════════════════ */
.stagger > * { animation: fadeUp .45s var(--transition) both; }
.stagger > *:nth-child(1) { animation-delay: .05s; }
.stagger > *:nth-child(2) { animation-delay: .12s; }
.stagger > *:nth-child(3) { animation-delay: .19s; }
.stagger > *:nth-child(4) { animation-delay: .26s; }
.stagger > *:nth-child(5) { animation-delay: .33s; }

/* ══════════════════════════════════════════════════════════════
    AYUDAS DE CUADRÍCULA
══════════════════════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.span-2 { grid-column: 1 / -1; }

/* ══════════════════════════════════════════════════════════════
    BARRA DE DESPLAZAMIENTO
══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }



/* ══════════════════════════════════════════════════════════════
    MEJORA DEL CHAT (SCROLL Y ALTURA FIJA)
   ══════════════════════════════════════════════════════════════ */

/* Mantiene el contenedor de mensajes y el chat con un tamaño fijo */
#section-mensajes > div {
    height: calc(100vh - 200px) !important; /* Se ajusta al tamaño de la pantalla */
    min-height: 500px;
    max-height: 650px;
    overflow: hidden; /* Evita que el grid completo se estire */
}

/* El área de las burbujas es la única que debe tener scroll */
#chat-mensajes-body {
    flex: 1;
    overflow-y: auto !important;
    padding-right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* Estilo para la barra de scroll (estilo minimalista MediFind) */
#chat-mensajes-body::-webkit-scrollbar {
    width: 5px;
}

#chat-mensajes-body::-webkit-scrollbar-track {
    background: transparent;
}

#chat-mensajes-body::-webkit-scrollbar-thumb {
    background: var(--purple-soft);
    border-radius: 10px;
}

#chat-mensajes-body::-webkit-scrollbar-thumb:hover {
    background: var(--purple-light);
}