/* ============================================================================
   UX/UI GLASSMORPHISM & AMBIENT GLOW — UNIDAD CLÍNICA VIRTUD v7
   Paleta oficial: #141418 / #2e2e2e (carbón), #d5c46d (oro mostaza), #e6e6e6
   ============================================================================ */

:root {
  --cv-bg: #f1f2f5;
  --cv-surface: #ffffff;
  --cv-dark: #2e2e2e;
  --cv-darker: #141418;
  --cv-gold: #d5c46d;
  --cv-gold-bright: #eadb8c;
  --cv-gold-dark: #b4a047;
  --cv-gold-soft: #faf6e6;
}

body {
  background-color: var(--cv-bg);
  color: var(--cv-dark);
  letter-spacing: -0.01em;
}

@keyframes cvFadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

main > section:not(.hidden),
#personalized-welcome-banner:not(.hidden) {
  animation: cvFadeSlide 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================================
   1. PANTALLA DE INICIO DE SESIÓN — DARK GLASSMORPHISM + ORBES LUMINOSOS
   ============================================================================ */
#login-view {
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, #242117 0%, #141418 55%, #0e0e11 100%) !important;
}

/* Orbes de iluminación ambiental en paleta Clínica Virtud */
#login-view::before,
#login-view::after {
  content: "";
  position: absolute;
  border-radius: 9999px;
  filter: blur(85px);
  pointer-events: none;
  z-index: 0;
}

#login-view::before {
  width: 340px;
  height: 340px;
  top: 12%;
  left: calc(50% - 310px);
  background: radial-gradient(circle, rgba(213, 196, 109, 0.55) 0%, rgba(180, 160, 71, 0.12) 70%, transparent 100%);
}

#login-view::after {
  width: 320px;
  height: 320px;
  bottom: 10%;
  right: calc(50% - 310px);
  background: radial-gradient(circle, rgba(230, 230, 230, 0.28) 0%, rgba(213, 196, 109, 0.22) 55%, transparent 100%);
}

/* Tarjeta Glassmorphism translúcida */
#login-view > div {
  position: relative;
  z-index: 1;
  background: rgba(34, 34, 38, 0.52) !important;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(213, 196, 109, 0.32) !important;
  box-shadow: 0 28px 60px -15px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.14) !important;
  border-radius: 1.5rem !important;
}

#login-view > div > div:first-child {
  background: transparent !important;
  border-bottom: 1px solid rgba(213, 196, 109, 0.2) !important;
  text-align: center;
  padding-top: 2rem !important;
  padding-bottom: 1.25rem !important;
}

#login-view > div > div:first-child > div {
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

#login-view > div > div:first-child img {
  width: 74px !important;
  height: 74px !important;
  box-shadow: 0 0 28px rgba(213, 196, 109, 0.45);
  border: 1.5px solid rgba(213, 196, 109, 0.75) !important;
}

#login-view label {
  color: rgba(235, 235, 240, 0.88) !important;
  letter-spacing: 0.08em;
}

#login-view input {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(213, 196, 109, 0.35) !important;
  color: #ffffff !important;
  border-radius: 0.85rem !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#login-view input::placeholder {
  color: rgba(215, 215, 222, 0.5) !important;
}

#login-view input:focus {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: var(--cv-gold-bright) !important;
  box-shadow: 0 0 0 3px rgba(213, 196, 109, 0.28), 0 0 16px rgba(213, 196, 109, 0.2) !important;
}

#login-view button[type="submit"] {
  background: linear-gradient(135deg, #d5c46d 0%, #eadb8c 50%, #b4a047 100%) !important;
  color: #18181b !important;
  border: none !important;
  border-radius: 0.9rem !important;
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
  box-shadow: 0 10px 26px -6px rgba(213, 196, 109, 0.55) !important;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

#login-view button[type="submit"]:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 14px 30px -6px rgba(213, 196, 109, 0.7) !important;
}

#login-view p.text-center {
  color: rgba(210, 210, 220, 0.6) !important;
}

/* ============================================================================
   2. BARRA LATERAL IZQUIERDA GLASSMORPHISM + MODO MINIMIZADO (SOLO ÍCONOS)
   ============================================================================ */
@media (min-width: 1024px) {
  #app-shell.cv-sidebar-mode {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
  }

  #app-shell.cv-sidebar-mode > header {
    width: 264px;
    min-height: 100vh;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden;
    border-bottom: none;
    border-right: 1px solid rgba(213, 196, 109, 0.3);
    background: linear-gradient(180deg, #16161a 0%, #222226 52%, #2c281c 100%);
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.16);
    flex-shrink: 0;
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Orbe de iluminación ambiental dentro de la barra lateral */
  #app-shell.cv-sidebar-mode > header::before {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    top: -50px;
    left: -60px;
    border-radius: 9999px;
    background: radial-gradient(circle, rgba(213, 196, 109, 0.34) 0%, transparent 70%);
    filter: blur(40px);
    pointer-events: none;
  }

  #app-shell.cv-sidebar-mode > header::after {
    content: "";
    position: absolute;
    width: 200px;
    height: 200px;
    bottom: 40px;
    right: -70px;
    border-radius: 9999px;
    background: radial-gradient(circle, rgba(230, 230, 230, 0.16) 0%, rgba(213, 196, 109, 0.14) 55%, transparent 75%);
    filter: blur(45px);
    pointer-events: none;
  }

  #app-shell.cv-sidebar-mode > header > div:first-child {
    position: relative;
    z-index: 1;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    height: 100%;
    padding: 1.25rem 0.9rem;
    gap: 1.25rem;
  }

  #app-shell.cv-sidebar-mode #desktop-nav {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    flex: 1;
  }

  #app-shell.cv-sidebar-mode #desktop-nav button {
    justify-content: flex-start;
    padding: 0.68rem 0.85rem;
    border-radius: 0.85rem;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    backdrop-filter: blur(8px);
    border: 1px solid transparent;
    transition: all 0.18s ease;
  }

  #app-shell.cv-sidebar-mode #desktop-nav button:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(213, 196, 109, 0.25);
    box-shadow: 0 0 14px rgba(213, 196, 109, 0.14);
  }

  #app-shell.cv-sidebar-mode #desktop-nav button.bg-virtud-gold {
    background: linear-gradient(135deg, #d5c46d 0%, #eadb8c 55%, #b4a047 100%) !important;
    color: #16161a !important;
    box-shadow: 0 6px 20px -4px rgba(213, 196, 109, 0.55);
  }

  #app-shell.cv-sidebar-mode > header > div:first-child > div:last-child {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 0.9rem;
    justify-content: space-between;
    width: 100%;
  }

  /* ESTADO MINIMIZADO (SOLO ÍCONOS) */
  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header {
    width: 78px;
  }

  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header > div:first-child {
    align-items: center;
    padding: 1.25rem 0.55rem;
  }

  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header .cv-hide-when-collapsed,
  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header .truncate,
  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header #current-user-name,
  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header #current-user-role,
  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header #btn-logout span {
    display: none !important;
  }

  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed #desktop-nav button {
    justify-content: center;
    padding: 0.72rem;
    width: 48px;
    margin: 0 auto;
  }

  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed #desktop-nav button .cv-nav-label {
    display: none !important;
  }

  #app-shell.cv-sidebar-mode.cv-sidebar-collapsed > header > div:first-child > div:last-child {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  #app-shell.cv-sidebar-mode > main {
    flex: 1;
    max-width: 100%;
    padding: 1.75rem 2.25rem;
  }
}

/* Glassmorphic modal backdrops */
#new-patient-modal,
#new-appt-modal,
#share-patient-modal,
#new-collab-modal,
#reset-pass-modal,
#edit-collab-modal,
#delete-patient-modal,
#print-modal {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Elevated interactive cards */
#patients-grid article {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

#patients-grid article:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -8px rgba(24, 24, 27, 0.12);
}

/* Session Restore Loading Overlay */
#cv-session-loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #242117 0%, #141418 65%);
  color: #ffffff;
}

#cv-session-loader.hidden { display: none; }

@keyframes cvSpin { to { transform: rotate(360deg); } }

.cv-spinner {
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  border: 3px solid rgba(213, 196, 109, 0.25);
  border-top-color: #eadb8c;
  box-shadow: 0 0 18px rgba(213, 196, 109, 0.35);
  animation: cvSpin 0.8s linear infinite;
}

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(110, 110, 110, 0.35); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(110, 110, 110, 0.55); }
