/* ============================================================
   MÉTODO VS® — Sistema Clínico | CSS Principal
   Palette: #1D9E75 (green), #fff (white), #f5f7fa (bg)
   ============================================================ */

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

:root {
  --green:       #1D9E75;
  --green-dark:  #178a65;
  --green-light: #e8f7f1;
  --green-bg:    #f0faf5;
  --sidebar-w:   240px;
  --topbar-h:    56px;
  --red:         #e53e3e;
  --red-light:   #fff5f5;
  --yellow:      #d69e2e;
  --yellow-light:#fffff0;
  --blue:        #3182ce;
  --blue-light:  #ebf8ff;
  --text:        #2d3748;
  --text-muted:  #718096;
  --border:      #e2e8f0;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f5f7fa;
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
}

.sidebar-brand .brand-icon { font-size: 1.5rem; }

.sidebar-brand .brand-text strong {
  display: block;
  font-size: .95rem;
  color: var(--green);
  line-height: 1.2;
}

.sidebar-brand .brand-text span {
  font-size: .75rem;
  color: var(--text-muted);
}

.sidebar-nav { padding: .75rem 0; flex: 1; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .75rem 1.25rem .25rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1.25rem;
  font-size: .875rem;
  color: var(--text);
  border-radius: 0;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.sidebar-nav a:hover { background: var(--green-light); color: var(--green); }

.sidebar-nav a.active {
  background: var(--green-bg);
  color: var(--green);
  font-weight: 600;
  border-right: 3px solid var(--green);
}

.sidebar-nav a .nav-icon { font-size: 1rem; width: 1.25rem; text-align: center; }

.sidebar-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-muted);
}

.sidebar-footer a {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem 0;
  text-decoration: none;
  font-size: .8rem;
}

.sidebar-footer a:hover { color: var(--red); }

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: .75rem; }

.hamburger {
  display: none;
  background: none;
  border: none;
  padding: .35rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}

.hamburger:hover { background: var(--green-light); color: var(--green); }

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-right { display: flex; align-items: center; gap: 1rem; }

.user-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
}

/* ─── Main content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 1.75rem 2rem;
  flex: 1;
  min-width: 0;
}

/* ─── Overlay (mobile sidebar) ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
}

.sidebar-overlay.active { display: block; }

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

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

.card-header h3, .card-header h4 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.card-body { padding: 1.25rem; }
.card-body.p0 { padding: 0; }

/* ─── Metric cards ───────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.metric-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.metric-icon.green  { background: var(--green-light); }
.metric-icon.blue   { background: var(--blue-light); }
.metric-icon.yellow { background: var(--yellow-light); }
.metric-icon.red    { background: var(--red-light); }

.metric-body strong {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.metric-body span {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .2rem;
  display: block;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  text-align: left;
  padding: .65rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  white-space: nowrap;
}

tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafeff; }

.text-center { text-align: center; }
.text-right  { text-align: right; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-sm { font-size: .65rem; padding: .15rem .5rem; }

.badge-green  { background: var(--green-light); color: var(--green-dark); }
.badge-red    { background: var(--red-light);   color: var(--red); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.badge-blue   { background: var(--blue-light);  color: var(--blue); }
.badge-gray   { background: #f7fafc; color: #718096; border: 1px solid var(--border); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); text-decoration: none; color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--green);
  border-color: var(--green);
}
.btn-outline:hover { background: var(--green-light); text-decoration: none; }

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover { background: #c53030; text-decoration: none; color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: #f7fafc; color: var(--text); text-decoration: none; }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-xs { padding: .2rem .55rem; font-size: .72rem; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

.form-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 0;
}

.form-row .form-group { margin-bottom: 0; }

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #555;
  margin-bottom: .35rem;
}

.form-control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .85rem;
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29,158,117,.12);
}

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control { cursor: pointer; }

.form-control::placeholder { color: #a0aec0; }

.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.form-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  align-items: center;
}

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.alert-success { background: var(--green-bg); border: 1px solid #9ae6c9; color: var(--green-dark); }
.alert-error   { background: var(--red-light); border: 1px solid #feb2b2; color: var(--red); }
.alert-warning { background: var(--yellow-light); border: 1px solid #f6e05e; color: var(--yellow); }
.alert-info    { background: var(--blue-light); border: 1px solid #90cdf4; color: var(--blue); }

/* ─── Toolbar ────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.toolbar-group { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ─── Search form ────────────────────────────────────────────── */
.search-form { display: flex; gap: .5rem; flex-wrap: wrap; }

.search-input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .85rem;
  font-size: .85rem;
  outline: none;
  min-width: 200px;
  font-family: inherit;
  transition: border-color .15s;
}

.search-input:focus { border-color: var(--green); }

/* ─── Patient card / ficha header ───────────────────────────── */
.patient-header {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.patient-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}

.patient-meta h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .35rem;
}

.patient-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .82rem;
  color: var(--text-muted);
}

.patient-meta-row span { display: flex; align-items: center; gap: .25rem; }

.patient-actions {
  margin-left: auto;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ─── Treatment timeline ────────────────────────────────────── */
.timeline { list-style: none; position: relative; padding-left: 1.5rem; }

.timeline::before {
  content: '';
  position: absolute;
  left: .5rem;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.125rem;
  top: .4rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--green);
}

.timeline-date {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .2rem;
}

.timeline-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
}

.timeline-body {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .2rem;
  line-height: 1.5;
}

/* ─── Document grid ──────────────────────────────────────────── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
}

.docs-grid-lg { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.doc-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  transition: box-shadow .15s;
  display: flex;
  flex-direction: column;
}

.doc-item:hover { box-shadow: var(--shadow-md); }

.doc-thumb {
  height: 100px;
  overflow: hidden;
  background: #f7fafc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.doc-thumb.doc-pdf { font-size: 2rem; }

.doc-name {
  font-size: .78rem;
  font-weight: 600;
  padding: .4rem .6rem .1rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-patient {
  font-size: .72rem;
  color: var(--green);
  padding: 0 .6rem .2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.doc-patient:hover { text-decoration: underline; }

.doc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem .6rem .5rem;
  flex-wrap: wrap;
  gap: .25rem;
}

/* ─── Pre-consultation forms list ────────────────────────────── */
.form-list { list-style: none; }

.form-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem .85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: .5rem;
  font-size: .85rem;
  gap: .75rem;
  flex-wrap: wrap;
}

.form-list-item:hover { background: #fafeff; }

.form-link-copy {
  font-size: .75rem;
  background: var(--green-light);
  color: var(--green);
  border: none;
  border-radius: 6px;
  padding: .25rem .65rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s;
}

.form-link-copy:hover { background: #c9eedd; }

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px; height: 32px;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  transition: background .15s, border-color .15s;
  padding: 0 .5rem;
}

.page-link:hover { background: var(--green-light); border-color: var(--green); color: var(--green); text-decoration: none; }

.page-link.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.page-link.disabled { opacity: .4; pointer-events: none; }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: .9rem;
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ─── Utility ─────────────────────────────────────────────────── */
.text-xs    { font-size: .75rem; }
.text-sm    { font-size: .875rem; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-bold  { font-weight: 700; }
.mt-0  { margin-top: 0; }
.mb-0  { margin-bottom: 0; }
.mt-1  { margin-top: .5rem; }
.mb-1  { margin-bottom: .5rem; }
.mt-2  { margin-top: 1rem; }
.mb-2  { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }

/* ─── Section title ──────────────────────────────────────────── */
.section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--green);
  margin: 1.5rem 0 .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--green-light);
}

/* ─── Info grid (detail rows) ────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.info-item label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .15rem;
}

.info-item p {
  font-size: .875rem;
  color: var(--text);
  margin: 0;
}

/* ─── Cita (appointment) status badges ──────────────────────── */
.estado-programada  { background: var(--blue-light);   color: var(--blue); }
.estado-confirmada  { background: var(--green-light);  color: var(--green-dark); }
.estado-realizada   { background: #f0fff4;              color: #276749; }
.estado-cancelada   { background: var(--red-light);    color: var(--red); }
.estado-no_asistio  { background: var(--yellow-light); color: var(--yellow); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }

  .topbar { left: 0; }

  .hamburger { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 1.25rem 1rem;
  }

  .metrics-grid { grid-template-columns: repeat(2, 1fr); }

  .patient-header { flex-direction: column; }

  .patient-actions { margin-left: 0; }

  .form-row { grid-template-columns: 1fr; }

  thead { display: none; }
  tbody tr { display: block; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; padding: .5rem; }
  tbody td { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed var(--border); padding: .4rem .6rem; font-size: .82rem; }
  tbody td:last-child { border-bottom: none; }
  tbody td::before { content: attr(data-label); font-weight: 700; font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-right: .5rem; flex-shrink: 0; }
  tbody tr:hover td { background: transparent; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn { justify-content: center; }

  .search-form { flex-direction: column; }
  .search-input { min-width: unset; width: 100%; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .docs-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Print ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .toolbar .btn, .form-actions, .btn { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
