/* ============================================================
   「吃药了」主样式 - 现代简约 + 渐变
   ============================================================ */

:root {
  --primary: #3B82F6;
  --primary-2: #06B6D4;
  --gradient: linear-gradient(135deg, #3B82F6 0%, #06B6D4 100%);
  --gradient-2: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  --gradient-warm: linear-gradient(135deg, #F59E0B 0%, #EF4444 100%);

  --bg: #F8FAFC;
  --bg-2: #F1F5F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  --text: #1E293B;
  --text-2: #475569;
  --text-3: #94A3B8;

  --success: #10B981;
  --warn: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .04);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(59,130,246,.10), transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(6,182,212,.10), transparent 40%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-2); }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.3; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
p  { margin: 0 0 .6em; }
.muted { color: var(--text-2); }
.hint  { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.ta-right { text-align: right; }

/* ====== Layout ====== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}
.app-main { min-height: calc(100vh - 130px); padding: 24px 0 60px; }

/* ====== Header ====== */
.app-header {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.brand-icon { font-size: 24px; }
.brand-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.main-nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  transition: all .15s;
}
.nav-link:hover { background: var(--bg-2); color: var(--text); }
.nav-link.active {
  color: var(--primary);
  background: rgba(59,130,246,.10);
}
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 14px; color: var(--text-2); }

/* ====== Footer ====== */
.app-footer {
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,.5);
  padding: 18px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.app-footer .dot { margin: 0 6px; }

/* ====== Card ====== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-head {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}
.card-title { margin: 0 0 4px; }
.card-sub { color: var(--text-2); font-size: 13px; margin: 0; }

/* ====== Auth Pages ====== */
.auth-wrap {
  min-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px 28px;
}
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-icon {
  font-size: 48px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--gradient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(59,130,246,.3);
}
.auth-foot {
  text-align: center;
  margin-top: 18px;
  color: var(--text-2);
  font-size: 14px;
}

/* ====== Form ====== */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.form-row-span-2 { grid-column: span 2; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } .form-row-span-2 { grid-column: span 1; } }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.form-error {
  background: #FEF2F2;
  color: #B91C1C;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 8px 0 14px;
  font-size: 14px;
  border: 1px solid #FECACA;
}

.input {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: all .15s;
  font-family: inherit;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.input-sm { padding: 6px 10px; font-size: 14px; }

select.input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 80px; }

.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-sm  { padding: 5px 12px; font-size: 13px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--gradient);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(59,130,246,.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(59,130,246,.35); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239,68,68,.3);
}
.btn-danger-ghost:hover { background: rgba(239,68,68,.08); border-color: var(--danger); }

/* ====== Color Picker ====== */
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s;
}
.color-dot:hover { transform: scale(1.1); }
.color-dot input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.color-dot:has(input:checked) {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text);
}

/* ====== Weekday Picker ====== */
.weekday-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.weekday-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.weekday-chip input { display: none; }
.weekday-chip:has(input:checked) {
  background: var(--gradient);
  color: #fff;
  border-color: transparent;
}

/* ====== Alert ====== */
.alert {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  align-items: flex-start;
}
.alert-icon { font-size: 22px; line-height: 1; }
.alert-body { flex: 1; }
.alert-body strong { display: inline-block; margin-bottom: 6px; }
.alert-danger {
  background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
  color: #991B1B;
  border: 1px solid #FECACA;
  box-shadow: 0 4px 12px rgba(239,68,68,.10);
}
.alert-success {
  background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
  color: #065F46;
  border: 1px solid #A7F3D0;
}
.missed-list { list-style: none; padding: 0; margin: 8px 0 0; }
.missed-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  flex-wrap: wrap;
}
.missed-name { font-weight: 600; }
.missed-times { display: flex; gap: 4px; flex-wrap: wrap; }
.time-chip {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.6);
  font-weight: 600;
}
.time-due { background: var(--danger); color: #fff; }
.time-future { background: var(--bg-2); color: var(--text-2); }
.missed-progress { margin-left: auto; font-size: 13px; color: #B91C1C; }

/* ====== Flash ====== */
.flash {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid;
}
.flash-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.flash-error   { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.flash-info    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }

/* ====== Hero ====== */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.hero-title { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.hero-sub { color: var(--text-2); margin: 0; }
.hero-stats { display: flex; gap: 12px; }
.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 22px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  min-width: 80px;
}
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-warn .stat-num { color: var(--danger); }
.stat-warn { background: linear-gradient(135deg, #FEF2F2 0%, #FFFFFF 100%); border-color: #FECACA; }
.stat-ok .stat-num { color: var(--success); }
.stat-ok { background: linear-gradient(135deg, #ECFDF5 0%, #FFFFFF 100%); border-color: #A7F3D0; }

/* ====== Medicine Grid (Homepage) ====== */
.med-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.med-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  position: relative;
  transition: all .2s;
  overflow: hidden;
  --med-color: var(--primary);
}
.med-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--med-color);
}
.med-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--med-color);
}
.med-card:active { transform: translateY(0); }
.med-card.med-clicked {
  animation: medPop .55s cubic-bezier(.4, 1.4, .5, 1);
}
@keyframes medPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(59,130,246,.2), var(--shadow-lg); }
  100% { transform: scale(1); }
}
.med-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 10px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.med-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.med-dose { color: var(--text-2); font-size: 13px; }
.med-today { margin-top: 8px; font-size: 12px; color: var(--text-3); }
.med-today strong { color: var(--med-color); font-size: 14px; }

/* ====== Today Records ====== */
.record-list { list-style: none; padding: 0; margin: 0; }
.record-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--border);
}
.record-item:last-child { border-bottom: none; }
.record-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.record-time { font-weight: 600; font-family: 'SF Mono', Consolas, monospace; font-size: 14px; min-width: 50px; }
.record-name { font-weight: 500; }
.record-qty { color: var(--text-2); font-size: 14px; }
.record-note { color: var(--text-3); font-size: 13px; flex: 1; }
.record-edit { color: var(--text-3); text-decoration: none; padding: 2px 6px; }
.record-edit:hover { color: var(--primary); }

/* ====== Table ====== */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg-2);
  font-size: 13px;
}
.table tbody tr:hover { background: var(--bg-2); }
.row-archived { opacity: .5; }
.dot-color { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.cell-note { color: var(--text-2); font-size: 13px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 500;
}
.tag-ok { background: #ECFDF5; color: #065F46; }
.tag-warn { background: #FEF3C7; color: #92400E; }
.tag-mute { background: var(--bg-2); color: var(--text-2); }
.tag-primary { background: rgba(59,130,246,.12); color: var(--primary); }

/* ====== Filter Bar ====== */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
}
.filter-item label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }

/* ====== Pagination ====== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}
.page-info { color: var(--text-2); font-size: 14px; }

/* ====== Reminder List ====== */
.reminder-list { display: flex; flex-direction: column; gap: 10px; }
.reminder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.reminder-item.reminder-off { opacity: .5; }
.reminder-name { font-weight: 600; min-width: 100px; }
.reminder-time {
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  min-width: 60px;
}
.reminder-days { display: flex; gap: 4px; }
.day-chip {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
}
.day-on  { background: var(--gradient); color: #fff; }
.day-off { background: var(--surface); color: var(--text-3); border: 1px solid var(--border); }
.reminder-actions { margin-left: auto; display: flex; gap: 6px; }

/* ====== Admin Stat ====== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.stat-card {
  padding: 20px;
  background: var(--gradient);
  color: #fff;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 6px 20px rgba(59,130,246,.25);
}
.stat-card:nth-child(2) { background: var(--gradient-2); box-shadow: 0 6px 20px rgba(99,102,241,.25); }
.stat-card:nth-child(3) { background: linear-gradient(135deg, #10B981 0%, #06B6D4 100%); box-shadow: 0 6px 20px rgba(16,185,129,.25); }
.stat-card:nth-child(4) { background: var(--gradient-warm); box-shadow: 0 6px 20px rgba(245,158,11,.25); }
.stat-card-num { font-size: 32px; font-weight: 700; }
.stat-card-label { font-size: 13px; opacity: .9; }
.stat-card-sub { font-size: 12px; opacity: .75; margin-top: 2px; }

/* ====== Empty ====== */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-2);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty p { margin-bottom: 16px; }
.empty-sm { padding: 30px 10px; }
.empty-sm .empty-icon { font-size: 32px; }

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 41, 59, .95);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 999;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-success { background: linear-gradient(135deg, #10B981, #059669); }
.toast.toast-error   { background: linear-gradient(135deg, #EF4444, #DC2626); }

/* ====== Modal ====== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 90%;
  max-width: 420px;
  z-index: 1;
}

/* ====== Responsive ====== */
@media (max-width: 720px) {
  .container { padding: 0 14px; }
  .header-inner { gap: 10px; flex-wrap: wrap; height: auto; padding: 10px 0; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; }
  .nav-link { white-space: nowrap; }
  .card { padding: 18px 14px; }
  h1 { font-size: 24px; }
  .hero-title { font-size: 22px; }
  .med-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .med-card { padding: 14px 8px; }
  .med-icon { width: 46px; height: 46px; font-size: 22px; }
  .table th, .table td { padding: 8px 6px; font-size: 13px; }
  .reminder-time { font-size: 16px; }
}
