/* RX Savers Portal — standalone styles */

:root {
  --teal: #3db8a9;
  --teal-dark: #2a9d8f;
  --teal-light: #e8f7f5;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: #111;
  color: #fff;
}

.topbar-logo { height: 36px; width: auto; }
.topbar-nav { display: flex; align-items: center; gap: 16px; }
.topbar-user { font-size: 14px; color: #ccc; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-outline { background: #fff; border: 1px solid var(--teal); color: var(--teal-dark); }
.btn-outline:hover { background: var(--teal-light); }
.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #c82333; }

/* Auth page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: #2d3748;
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  text-align: center;
}

.auth-logo { height: 48px; margin-bottom: 16px; }
.auth-card h1 { margin: 0 0 8px; font-size: 24px; color: #fff; }
.auth-subtitle { color: #cbd5e1; margin: 0 0 24px; }

.auth-form { text-align: left; }
.auth-form label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #e5e7eb; }
.auth-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #374151;
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 16px;
  background: #fff;
  color: var(--text);
}
.auth-form input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(61, 184, 169, 0.25);
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* Main page */
.page { max-width: 1200px; margin: 0 auto; padding: 28px 20px 48px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 28px;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h1 { margin: 0 0 6px; font-size: 26px; font-weight: 700; }
.subtitle { margin: 0; color: var(--muted); max-width: 480px; }
.signed-in { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

.admin-hint {
  background: var(--teal-light);
  border: 1px solid rgba(61, 184, 169, 0.35);
  color: #1e5c54;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
}

.search-bar { margin-bottom: 16px; }
.search-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--muted);
}
.search-input-wrap { position: relative; }
.search-bar input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(61, 184, 169, 0.2);
}
.search-spinner {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.search-spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.results.is-loading { opacity: 0.55; transition: opacity 0.15s; }

.toolbar { margin-bottom: 16px; text-align: right; }

/* Results table */
.results { margin-top: 8px; }
.results-empty { color: var(--muted); padding: 24px; text-align: center; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table thead th {
  background: var(--teal);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:hover { background: var(--teal-light); }

.data-table td[contenteditable="true"]:focus {
  outline: 2px solid var(--teal);
  background: #fffde7;
}

.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }

.aca-cell { text-align: center; width: 100px; }
.aca-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}
.aca-yes .aca-icon {
  background: #e8f7f5;
  color: #2a9d8f;
}
.aca-no .aca-icon {
  background: #fef2f2;
  color: #b91c1c;
}

/* Modals */
.modal {
  border: none;
  padding: 0;
  max-width: 520px;
  width: calc(100% - 32px);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal::backdrop { background: rgba(0,0,0,0.45); }

.modal-inner { display: flex; flex-direction: column; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--teal);
  color: #fff;
}
.modal-header h2 { margin: 0; font-size: 18px; }
.fpl-medication {
  margin: 0 0 20px;
  padding: 14px 16px;
  background: var(--teal-light);
  border: 1px solid rgba(61, 184, 169, 0.25);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
}
.fpl-medication-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal-dark);
  margin-bottom: 6px;
}
.fpl-medication-name {
  display: block;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.9;
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-grid label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 14px;
}
.form-grid input,
.form-grid select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

@media (max-width: 640px) {
  .card { padding: 20px 16px; }
  .card-header h1 { font-size: 22px; }
}
