@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-base:        #f4f6f8;
  --bg-surface:     #ffffff;
  --bg-elevated:    #eef1f4;
  --border:         #d6dce2;

  --text-primary:   #1a2230;
  --text-secondary: #4a5568;
  --text-muted:     #7a8595;

  --accent:         #0b6e4f;
  --accent-hover:   #095a41;
  --accent-glow:    #0b6e4f22;

  --blue:           #1d4ed8;
  --red:            #c0392b;
  --red-bg:         #fdecea;
  --green-bg:       #e8f6ef;
  --orange:         #b45309;

  --radius: 12px;
  --radius-full: 9999px;
  --shadow: 0 2px 10px rgba(20, 30, 40, 0.08);
  --shadow-sm: 0 1px 3px rgba(20, 30, 40, 0.15);
  --shadow-md: 0 6px 20px rgba(20, 30, 40, 0.10);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 19px;
  line-height: 1.5;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ---- Topbar ---- */
.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar .brand {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 17px;
  color: var(--text-secondary);
}
.topbar-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px;
}
.nav-tab {
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.nav-tab:hover { background: var(--bg-surface); color: var(--text-primary); }
.nav-tab.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar-nav { order: 3; width: 100%; justify-content: center; }
  .topbar-nav { order: 3; width: 100%; justify-content: flex-start; }
}

/* ---- Botones grandes y claros ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 28px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 19px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  min-height: 56px;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 2px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 2px solid #f3c8c3; }
.btn-danger:hover { background: #fbdbd6; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 10px 18px; font-size: 16px; min-height: 42px; }

/* ---- Formularios ---- */
.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.form-label {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 19px;
  transition: all 0.15s ease;
  outline: none;
}
.form-textarea { resize: vertical; min-height: 140px; line-height: 1.6; }
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.form-input.error { border-color: var(--red); }
.form-hint { font-size: 15px; color: var(--text-muted); }
.form-error { font-size: 15px; color: var(--red); font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ---- Cards ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.card-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--bg-elevated);
}

/* ---- Login ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eaf3ef 0%, #f4f6f8 60%);
  padding: 20px;
}
.login-card {
  background: var(--bg-surface);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  text-align: center;
}
.login-card .logo {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
}
.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 18px;
  margin-bottom: 32px;
}
.login-card form { text-align: left; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 24px;
  font-size: 17px;
  color: var(--text-secondary);
}
.checkbox-row input { width: 22px; height: 22px; }

/* ---- Buscador de pacientes ---- */
.search-box {
  position: relative;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 340px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.search-results.show { display: block; }
.search-result-item {
  padding: 16px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-elevated);
  transition: background 0.1s ease;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: var(--green-bg); }
.search-result-item .nombre { font-weight: 700; font-size: 18px; }
.search-result-item .meta { font-size: 15px; color: var(--text-muted); }

/* ---- Tabla historial ---- */
.table-wrapper { width: 100%; overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 17px; background: var(--bg-surface); }
.data-table thead { background: var(--bg-elevated); }
.data-table th {
  padding: 14px 16px; text-align: left; font-weight: 700; color: var(--text-secondary);
  font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--bg-elevated); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg-elevated); cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Alertas / Toast ---- */
.alert {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px;
  border-radius: var(--radius); font-size: 17px; border-left: 4px solid; margin-bottom: 20px;
}
.alert-error { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.alert-success { background: var(--green-bg); border-color: var(--accent); color: var(--accent-hover); }

.toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  background: #fff; border-left: 5px solid var(--accent);
  color: var(--text-primary); padding: 18px 22px; border-radius: 12px;
  font-size: 17px; display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-md); min-width: 300px; max-width: 420px;
  animation: slideIn 0.25s ease;
}
.toast.error { border-left-color: var(--red); }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOutToast { to { opacity: 0; transform: translateX(30px); } }

/* ---- Layout dashboard ---- */
.actions-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-title { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.page-subtitle { font-size: 18px; color: var(--text-secondary); margin-bottom: 24px; }

.paciente-header {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;
  margin-bottom: 24px;
}
.paciente-header .info h2 { font-size: 24px; font-weight: 800; }
.paciente-header .info .meta { font-size: 17px; color: var(--text-secondary); margin-top: 4px; }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 18px;
}

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
