/* =====================================================================
   Estilos del sistema - AgendaVirtual
   Complementan a Bootstrap 5. Paleta "agenda": índigo + pizarra.
   ===================================================================== */
:root {
  --marca:        #4f46e5;   /* índigo */
  --marca-oscuro: #4338ca;
  --pizarra:      #1f2937;   /* sidebar oscuro */
  --pizarra-2:    #111827;
  --texto-tenue:  #9ca3af;
}

body {
  background-color: #f3f4f6;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---- Botón de marca -------------------------------------------------*/
.btn-marca {
  background-color: var(--marca);
  border-color: var(--marca);
  color: #fff;
}
.btn-marca:hover,
.btn-marca:focus {
  background-color: var(--marca-oscuro);
  border-color: var(--marca-oscuro);
  color: #fff;
}
.text-marca { color: var(--marca) !important; }
a { color: var(--marca-oscuro); }

/* ==== LOGIN ==========================================================*/
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--pizarra-2), var(--pizarra));
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.login-header {
  background: var(--marca);
  color: #fff;
  padding: 1.75rem 1.5rem;
  text-align: center;
}
.login-header i { font-size: 2.4rem; }

/* ==== LAYOUT (sidebar + contenido) ==================================*/
.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 258px;
  background: linear-gradient(180deg, #202b3b 0%, var(--pizarra) 55%, var(--pizarra-2) 100%);
  color: #e5e7eb;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1030;
  transition: transform .25s ease;
  box-shadow: 2px 0 16px rgba(0, 0, 0, .18);
}
.sidebar-brand {
  padding: 1.1rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  display: flex;
  align-items: center;
  gap: .7rem;
}
.sidebar-brand .brand-logo {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--marca), var(--marca-oscuro));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.35rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
}
.sidebar-brand .brand-text {
  display: flex; flex-direction: column; line-height: 1.15;
  font-weight: 700; font-size: 1.05rem; color: #fff;
}
.sidebar-brand .brand-text small {
  font-size: .68rem; font-weight: 500; letter-spacing: .3px;
  color: var(--texto-tenue); text-transform: uppercase;
}
.sidebar-nav { padding: .6rem .55rem; flex: 1; overflow-y: auto; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-group { margin-bottom: .15rem; }
.nav-group + .nav-group { margin-top: .1rem; }

/* Ítems (enlaces) del menú -> pill redondeado */
.sidebar-nav .nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 1px .1rem;
  padding: .58rem .7rem;
  border-radius: 9px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: .93rem;
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav .nav-item i { width: 20px; text-align: center; font-size: 1.02rem; color: var(--texto-tenue); transition: color .15s ease; }
.sidebar-nav .nav-item:hover i { color: #e5e7eb; }
.sidebar-nav .nav-item.activo {
  background: linear-gradient(90deg, rgba(79, 70, 229, .28), rgba(79, 70, 229, .12));
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .32);
}
.sidebar-nav .nav-item.activo i { color: #a5b4fc; }
/* Acento a la izquierda del ítem activo */
.sidebar-nav .nav-item.activo::before {
  content: "";
  position: absolute; left: -.1rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 3px; background: var(--marca);
}

/* Sub-ítems: indentados con guía vertical */
.sidebar-nav .nav-item.sub { margin-left: 1.55rem; padding-left: .8rem; font-size: .9rem; }
.sidebar-nav .nav-item.sub::after {
  content: "";
  position: absolute; left: -.35rem; top: 0; bottom: 0;
  width: 1.5px; background: rgba(255, 255, 255, .09);
}
.sidebar-nav .nav-item.sub:hover::after { background: rgba(255, 255, 255, .18); }
.sidebar-nav .nav-item.sub.activo::after { background: var(--marca); }
.sidebar-nav .nav-item.sub.activo::before { display: none; }

/* Encabezado de un grupo (botón que colapsa) */
.nav-group-title {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: .35rem .1rem .1rem;
  padding: .4rem .7rem;
  border-radius: 8px;
  background: transparent;
  border: 0;
  color: #8a97a8;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.nav-group-title:hover { color: #e5e7eb; background: rgba(255, 255, 255, .03); }
.nav-group-title i:first-child { width: 20px; text-align: center; font-size: .9rem; color: #a5b4fc; opacity: .85; }
.nav-group-title .chevron {
  margin-left: auto;
  font-size: .7rem;
  opacity: .7;
  transition: transform .25s ease;
}
.nav-group-title.collapsed .chevron { transform: rotate(-90deg); }
.sidebar-foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: .8rem;
  color: var(--texto-tenue);
}

.contenido {
  margin-left: 250px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 600; }
.main { padding: 1.5rem; }

/* ---- Tarjetas de resumen (dashboard) --------------------------------*/
.stat-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}
.stat-card .icono {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.stat-card .valor { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat-card .etiqueta { color: #6b7280; font-size: .85rem; }

.card { border: none; border-radius: 12px; box-shadow: 0 2px 10px rgba(0, 0, 0, .05); }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; color: #6b7280; }

/* ---- Badges de estado de las citas ---------------------------------*/
.badge-pendiente  { background: #f59e0b !important; }
.badge-confirmada { background: #2563eb !important; }
.badge-completada { background: #16a34a !important; }
.badge-cancelada  { background: #6b7280 !important; }

/* ==== CALENDARIO =====================================================*/
/* Tokens locales del calendario (se adaptan a claro/oscuro). */
.cal-card { --cal-linea: #eef0f3; --cal-celda: #fff; --cal-celda2: #f9fafb; --cal-borde: #e9ebf0; --cal-tenue: #9ca3af; }
[data-bs-theme="dark"] .cal-card { --cal-linea: #2b303b; --cal-celda: #1e222b; --cal-celda2: #191d24; --cal-borde: #2b303b; --cal-tenue: #7b8494; }

/* --- Barra de control --- */
.cal-toolbar {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem;
  background: var(--bs-body-bg, #fff); border: 1px solid var(--cal-borde, #e9ebf0);
  border-radius: 12px; padding: .6rem .85rem; box-shadow: 0 2px 10px rgba(0,0,0,.05);
}
[data-bs-theme="dark"] .cal-toolbar { background: #1e222b; border-color: #2b303b; }
.cal-titulo { font-size: 1.25rem; letter-spacing: -.01em; }
.cal-vistas .btn { border-color: var(--cal-borde); color: var(--bs-secondary-color, #6b7280); font-weight: 600; font-size: .85rem; }
.cal-vistas .btn.active { background: var(--marca); border-color: var(--marca); color: #fff; }

/* --- Rejilla del mes --- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow {
  text-align: center; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--cal-tenue); padding: .2rem 0 .4rem;
}
.cal-cell {
  background: var(--cal-celda); border: 1px solid var(--cal-borde); border-radius: 10px;
  min-height: 104px; padding: .35rem .4rem; cursor: pointer;
  transition: box-shadow .12s ease, border-color .12s ease, transform .08s ease;
  display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.cal-cell:hover { border-color: var(--marca); box-shadow: 0 4px 14px rgba(79,70,229,.16); transform: translateY(-1px); }
.cal-cell.fuera { background: var(--cal-celda2); opacity: .5; cursor: default; }
.cal-cell.fuera:hover { border-color: var(--cal-borde); box-shadow: none; transform: none; }
.cal-cell.cerrado { background: repeating-linear-gradient(45deg, var(--cal-celda2), var(--cal-celda2) 6px, transparent 6px, transparent 12px); }
.cal-cell.hoy { border-color: var(--marca); box-shadow: inset 0 0 0 2px rgba(79,70,229,.35); }
.cal-daynum { font-size: .82rem; font-weight: 600; color: var(--bs-body-color, #374151); align-self: flex-end; }
.cal-cell.hoy .cal-daynum {
  color: #fff; background: var(--marca); border-radius: 999px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center; font-size: .74rem;
}
.cal-chip {
  display: flex; align-items: center; gap: 4px; font-size: .68rem; line-height: 1.25;
  padding: 2px 6px; border-radius: 6px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-chip .pt { font-weight: 700; opacity: .85; }
.cal-chip.cancelada { opacity: .55; text-decoration: line-through; }
.cal-more { font-size: .66rem; color: var(--cal-tenue); font-weight: 600; padding-left: 2px; }

/* --- Vista de tiempo (semana / día) --- */
.tg-wrap { overflow-x: auto; }
.tg { display: grid; min-width: 560px; }
.tg.dia { min-width: 0; }
.tg-corner { position: sticky; left: 0; z-index: 3; background: var(--bs-body-bg, #fff); border-bottom: 1px solid var(--cal-borde); }
.tg-dayhead {
  text-align: center; padding: .45rem 0; border-bottom: 1px solid var(--cal-borde); border-left: 1px solid var(--cal-borde);
  font-size: .8rem; color: var(--bs-secondary-color, #6b7280);
}
.tg-dayhead .dnum { font-size: 1.15rem; font-weight: 700; color: var(--bs-body-color, #1f2937); display: inline-flex;
  align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 999px; }
.tg-dayhead.hoy .dnum { background: var(--marca); color: #fff; }
.tg-dayhead.cerrado { color: var(--cal-tenue); }
.tg-hours { position: sticky; left: 0; z-index: 2; background: var(--bs-body-bg, #fff); }
.tg-hour { height: var(--hh); font-size: .68rem; color: var(--cal-tenue); text-align: right; padding-right: 6px; transform: translateY(-6px); }
.tg-col {
  position: relative; border-left: 1px solid var(--cal-borde);
  background-image: repeating-linear-gradient(to bottom, var(--cal-linea) 0, var(--cal-linea) 1px, transparent 1px, transparent var(--hh));
}
.tg-col.cerrada { background-color: var(--cal-celda2); }
.tg-col.hoy { background-color: rgba(79,70,229,.04); }
.tg-now { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 4; pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 999px; background: #ef4444; }
.tg-cita {
  position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 3px 6px; overflow: hidden;
  color: #fff; font-size: .72rem; line-height: 1.15; cursor: pointer; border-left: 3px solid rgba(0,0,0,.25);
  box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: filter .1s ease;
}
.tg-cita:hover { filter: brightness(1.06); }
.tg-cita .h { font-weight: 700; opacity: .9; }
.tg-cita.cancelada { opacity: .5; text-decoration: line-through; }

/* Tarjeta de cita (modal de día) */
.cita-card {
  border-left: 4px solid var(--marca);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: .5rem .65rem;
  margin-bottom: .35rem;
  cursor: pointer;
  transition: box-shadow .12s ease;
}
.cita-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.08); }

/* ==== EXPEDIENTE / AFICHE DEL CLIENTE ================================*/
.afiche {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .08);
  background: #fff;
}
.afiche-top {
  background: linear-gradient(120deg, var(--marca), #7c3aed 60%, #6d28d9);
  color: #fff;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.15rem;
  flex-wrap: wrap;
}
.afiche-avatar {
  width: 84px; height: 84px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  border: 3px solid rgba(255, 255, 255, .55);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase;
}
.afiche-ident { flex: 1; min-width: 200px; }
.afiche-ident h3 { margin: 0; font-weight: 700; }
.afiche-ident .meta { font-size: .9rem; opacity: .92; margin-top: .2rem; }
.afiche-ident .meta i { width: 18px; }
.afiche-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px;
  background: #eef0f3;
}
.afiche-stat { background: #fff; padding: .9rem 1rem; text-align: center; }
.afiche-stat .n { font-size: 1.4rem; font-weight: 700; color: var(--marca); line-height: 1; }
.afiche-stat .l { font-size: .75rem; color: #6b7280; margin-top: .25rem; }

/* Línea de tiempo simple para bitácora/consultas */
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: .35rem; top: .2rem; bottom: .2rem; width: 2px; background: #e5e7eb; }
.tl-item { position: relative; padding: 0 0 1rem .3rem; }
.tl-item::before {
  content: ""; position: absolute; left: -1.12rem; top: .25rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--marca); box-shadow: 0 0 0 3px #fff;
}
.tl-fecha { font-size: .72rem; color: #9ca3af; text-transform: uppercase; letter-spacing: .3px; }
.informe-card { border: 1px solid #e5e7eb; border-radius: 10px; padding: .8rem 1rem; margin-top: .25rem; background: #fff; transition: box-shadow .12s ease; }
.informe-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.06); }

/* Tarjeta de documento */
.doc-card { border: 1px solid #e5e7eb; border-radius: 10px; padding: .75rem; display: flex; align-items: center; gap: .75rem; height: 100%; }
.doc-ico { width: 42px; height: 42px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: #fff; flex-shrink: 0; }

/* ---- Responsive: sidebar colapsable en móvil ------------------------*/
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 1025;
}
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.abierto { transform: translateX(0); }
  .contenido { margin-left: 0; }
  .sidebar-backdrop.visible { display: block; }
  .cal-cell { min-height: 66px; }
}

/* ==== MODO OSCURO (usa data-bs-theme de Bootstrap 5.3) ==============*/
[data-bs-theme="dark"] body { background: #15181e; }
[data-bs-theme="dark"] .topbar { background: #1e222b; border-bottom-color: #2b303b; }
[data-bs-theme="dark"] .topbar h1 { color: #e5e7eb; }
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .stat-card { background: #1e222b; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
[data-bs-theme="dark"] .stat-card .etiqueta,
[data-bs-theme="dark"] .table thead th { color: #9ca3af; }
[data-bs-theme="dark"] .informe-card,
[data-bs-theme="dark"] .doc-card,
[data-bs-theme="dark"] .cita-card,
[data-bs-theme="dark"] .cal-cell { background: #1e222b; border-color: #2b303b; }
[data-bs-theme="dark"] .cal-dow { color: #9ca3af; }
[data-bs-theme="dark"] .cal-cell.fuera { background: #171a20; }

/* ---- Impresión / PDF -----------------------------------------------*/
.solo-print { display: none; }
@media print {
  @page { margin: 1.2cm; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .contenido { margin-left: 0; }
  .main { padding: 0; }
  body { background: #fff; font-size: 11px; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .solo-print { display: block !important; }
  .card { box-shadow: none !important; border: 1px solid #d1d5db !important; break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }
  tr, td, th { page-break-inside: avoid; }
  table { font-size: 10px !important; }
}

/* ==== Arrastrar y soltar citas (reprogramar) ==================== */
.tg-cita { cursor: grab; }
.tg-cita:active { cursor: grabbing; }
.tg-col.drop { background: rgba(79,70,229,.10); outline: 2px dashed var(--marca); outline-offset: -2px; }

/* ==== Agenda del profesional (línea de tiempo del día) ============ */
.ag-head { display:flex; flex-wrap:wrap; align-items:center; gap:.75rem 1rem; margin-bottom:.75rem; }
.ag-daynav { display:flex; align-items:center; gap:.4rem; }
.ag-fecha-larga { font-weight:700; text-transform:capitalize; font-size:1.05rem; flex:1 1 auto; min-width:180px; color:var(--bs-emphasis-color,#1f2937); }
.ag-filtro { display:flex; align-items:center; gap:.5rem; }
.ag-resumen { display:flex; flex-wrap:wrap; gap:.5rem; margin-bottom:1rem; }
.ag-chip { display:inline-flex; align-items:center; gap:.4rem; background:var(--bs-secondary-bg,#f1f5f9); color:var(--bs-secondary-color,#475569);
  border:1px solid var(--bs-border-color,#e5e7eb); border-radius:999px; padding:.3rem .8rem; font-size:.85rem; font-weight:600; }
.ag-chip .bi { color:var(--marca); }

.ag-timeline { border:1px solid var(--bs-border-color,#e5e7eb); border-radius:16px; overflow:hidden; background:var(--bs-body-bg,#fff); }
.ag-grid { display:grid; grid-template-columns:64px 1fr; }
.ag-grid.cerrado .ag-lienzo { background:repeating-linear-gradient(45deg, transparent, transparent 12px, rgba(100,116,139,.05) 12px, rgba(100,116,139,.05) 24px); }
.ag-rail { position:relative; border-right:1px solid var(--bs-border-color,#e5e7eb); }
.ag-hora { display:flex; align-items:flex-start; justify-content:flex-end; padding:.25rem .5rem 0 0; font-size:.72rem; color:var(--bs-secondary-color,#94a3b8);
  box-sizing:border-box; }
.ag-lienzo { position:relative; }
.ag-line { position:absolute; left:0; right:0; border-top:1px dashed var(--bs-border-color,#eef0f3); }

.ag-cita { position:absolute; border-radius:12px; background:var(--bs-body-bg,#fff);
  border:1px solid var(--bs-border-color,#e5e7eb); border-left:5px solid var(--acc,#4f46e5);
  box-shadow:0 4px 14px rgba(2,6,23,.08); overflow:hidden; cursor:grab; transition:box-shadow .12s, transform .08s; }
.ag-cita:hover { box-shadow:0 8px 22px rgba(2,6,23,.14); transform:translateY(-1px); }
.ag-cita:active { cursor:grabbing; }
.ag-cita.cancelada { opacity:.55; text-decoration:line-through; }
.ag-cita-in { display:flex; gap:.6rem; padding:.5rem .6rem; height:100%; }
.ag-avatar { flex:0 0 auto; width:36px; height:36px; border-radius:50%; color:#fff; font-weight:700; font-size:.85rem;
  display:flex; align-items:center; justify-content:center; }
.ag-cita-body { min-width:0; flex:1 1 auto; }
.ag-cita-top { display:flex; align-items:center; justify-content:space-between; gap:.4rem; }
.ag-hora-txt { font-weight:700; font-size:.8rem; color:var(--marca); }
.ag-cliente { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ag-meta { font-size:.78rem; color:var(--bs-secondary-color,#6b7280); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ag-acc { display:flex; gap:.3rem; margin-top:.35rem; }
.ag-acc .btn { padding:.15rem .45rem; font-size:.8rem; }

.ag-now { position:absolute; left:0; right:0; height:2px; background:#ef4444; z-index:5; }
.ag-now span { position:absolute; left:-5px; top:-4px; width:10px; height:10px; border-radius:50%; background:#ef4444; }
.ag-vacio { position:absolute; top:0; left:0; right:0; text-align:center; padding:2.5rem 1rem; color:var(--bs-secondary-color,#94a3b8); }

@media (max-width:560px){
  .ag-grid { grid-template-columns:44px 1fr; }
  .ag-avatar { display:none; }
  .ag-acc .btn { padding:.1rem .4rem; }
}

/* ---- Centro de avisos (campana) ---- */
.notif-item:hover { background: var(--bs-tertiary-bg, #f1f5f9); }
.notif-nuevo { background: rgba(79, 70, 229, .07); }
.notif-nuevo:hover { background: rgba(79, 70, 229, .12); }
