/* Sistema de Citas Médicas v3 */
:root {
  --brand: #0f766e;
  --sidebar-w: 248px;
  --bg: #f3f5f8;
  --card-radius: 14px;
}
html, body { background: var(--bg); }
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .95rem; color: #1f2937; }
a { color: var(--brand); }
.btn-primary, .btn-primary:disabled { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: color-mix(in srgb, var(--brand) 85%, #000); border-color: color-mix(in srgb, var(--brand) 85%, #000); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.text-brand { color: var(--brand) !important; }
.bg-brand { background: var(--brand) !important; color: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 20%, transparent); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.nav-pills .nav-link.active { background: var(--brand); }
.page-link { color: var(--brand); }
.active > .page-link, .page-link.active { background: var(--brand); border-color: var(--brand); }

/* Estructura */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #000));
  color: #fff; display: flex; flex-direction: column; padding: 1rem .75rem;
}
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; } }
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 70%, #000)); color: #fff; } }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: .25rem .5rem 1rem; }
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; line-height: 1.15; }
.brand i { font-size: 1.6rem; }
.brand img { height: 46px; width: auto; max-width: 70px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; image-rendering: -webkit-optimize-contrast; }
.btn-new { font-weight: 600; color: var(--brand) !important; margin: 0 .25rem 1rem; border-radius: 10px; }
.sidebar .nav-link { color: rgba(255,255,255,.85); border-radius: 10px; padding: .55rem .75rem; display: flex; gap: .7rem; align-items: center; margin-bottom: 2px; }
.sidebar .nav-link i { font-size: 1.1rem; opacity: .9; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.95); color: var(--brand); font-weight: 600; }
.sidebar-foot { margin-top: auto; opacity: .6; padding: 1rem .5rem 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid #e5e7eb; display: flex; align-items: center; padding: .65rem 1.25rem; gap: .5rem; }
.page-title { font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { position: relative; width: 320px; }
.search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.search input { padding-left: 2.2rem; border-radius: 999px; background: #f3f4f6; border-color: transparent; }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.content { padding: 1.25rem; }
@media (min-width: 1200px) { .content { padding: 1.5rem 2rem; } }

/* Tarjetas */
.card { border: 0; border-radius: var(--card-radius); box-shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08); }
.card-header { background: transparent; border-bottom: 1px solid #eef0f3; font-weight: 600; padding: .9rem 1.1rem; }
.stat { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem; }
.stat .ico { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat .num { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat .lbl { color: #6b7280; font-size: .85rem; }
.ico-teal { background: #ccfbf1; color: #0f766e; } .ico-blue { background: #dbeafe; color: #1d4ed8; }
.ico-amber { background: #fef3c7; color: #b45309; } .ico-rose { background: #ffe4e6; color: #be123c; }
.ico-violet { background: #ede9fe; color: #6d28d9; } .ico-green { background: #dcfce7; color: #15803d; }

.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: #6b7280; font-weight: 600; background: #f9fafb; }
.table-hover tbody tr { cursor: default; }
.row-link { cursor: pointer; }
.empty { text-align: center; color: #9ca3af; padding: 2.5rem 1rem; }
.empty i { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: .3rem; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; font-weight: 700; margin: 1.25rem 0 .75rem; }
.badge { font-weight: 600; }

/* Lista de citas compacta */
.appt-item { display: flex; gap: .85rem; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid #f1f3f5; text-decoration: none; color: inherit; }
.appt-item:hover { background: #f9fafb; }
.appt-item:last-child { border-bottom: 0; }
.appt-time { font-weight: 700; min-width: 52px; color: var(--brand); }
.appt-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Tablero de seguimiento */
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.board-col { background: #eef1f5; border-radius: 14px; padding: .75rem; min-height: 200px; }
.board-col h6 { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin: .25rem .25rem .75rem; }
.board-card { background: #fff; border-radius: 10px; padding: .7rem .8rem; margin-bottom: .6rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); border-left: 4px solid #ccc; }
.board-card .name { font-weight: 600; }
.board-card .meta { font-size: .8rem; color: #6b7280; }

/* Calendario */
.fc { --fc-border-color: #e5e7eb; --fc-today-bg-color: color-mix(in srgb, var(--brand) 8%, #fff); font-size: .88rem; }
.fc .fc-button-primary { background: var(--brand); border-color: var(--brand); }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: color-mix(in srgb, var(--brand) 75%, #000); border-color: transparent; }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 700; text-transform: capitalize; }
.fc-event { cursor: pointer; border: 0; padding: 1px 3px; }
@media (max-width: 576px) { .fc .fc-toolbar { flex-direction: column; gap: .5rem; } }

/* Ficha de la cita */
.patient-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.patient-head .big-avatar { width: 56px; height: 56px; border-radius: 16px; background: color-mix(in srgb, var(--brand) 15%, #fff); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 800; }
.nav-tabs-clean { border-bottom: 1px solid #e5e7eb; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav-tabs-clean .nav-link { border: 0; color: #6b7280; font-weight: 500; white-space: nowrap; padding: .7rem 1rem; border-bottom: 2px solid transparent; }
.nav-tabs-clean .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.kv dt { font-size: .78rem; color: #6b7280; font-weight: 500; }
.kv dd { margin-bottom: .6rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid #e5e7eb; margin-left: .4rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.alert-allergy { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }

/* Público */
body.public { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 12%, #fff) 0, var(--bg) 320px); }
.public-head { background: var(--brand); color: #fff; padding: .8rem 0; }
.auth-card { max-width: 420px; margin: 0 auto; }
.step-pill { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #e5e7eb; font-weight: 700; color: #6b7280; }
.step-pill.on { background: var(--brand); color: #fff; }
.choice { border: 2px solid #e5e7eb; border-radius: 12px; padding: .85rem 1rem; cursor: pointer; transition: .15s; background: #fff; height: 100%; }
.choice:hover { border-color: color-mix(in srgb, var(--brand) 50%, #fff); }
.choice.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, #fff); }
.slot { border: 1px solid #d1d5db; background: #fff; border-radius: 8px; padding: .4rem .2rem; text-align: center; cursor: pointer; font-weight: 600; font-size: .9rem; }
.slot:hover { border-color: var(--brand); }
.slot.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: .5rem; }

.ts-wrapper.form-control, .ts-wrapper.form-select { padding: 0; }
.ts-control { border-radius: .375rem; padding: .45rem .75rem; }
@media print { .sidebar, .topbar, .no-print { display: none !important; } .content { padding: 0; } }
