/* ================================================================
   Austin Shoe Hospital — Staff Portal
   Brand: Deep charcoal + crimson red + warm white
   Fonts: Oswald (display) + Inter (UI)
   ================================================================ */

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

/* ── Brand Tokens ─────────────────────────────────────────── */
:root {
  --brand-red:       #c0141c;   /* ASH crimson red — primary */
  --brand-red-dark:  #8f0e14;   /* Pressed/hover state */
  --brand-red-light: #e63030;   /* Lighter accent, focus rings */
  --brand-charcoal:  #1a1a1a;   /* Near-black background */
  --brand-dark:      #111111;   /* Header / deepest bg */
  --brand-warm:      #f5f0eb;   /* Off-white warm text */

  /* UI surfaces — dark mode (default) */
  --bg-primary:    #1a1a1a;
  --bg-secondary:  #242424;
  --bg-card:       #2a2a2a;
  --bg-card-hover: #323232;
  --text-primary:  #f5f0eb;
  --text-secondary:#b0a8a0;
  --text-muted:    #6e6660;
  --border:        rgba(255,255,255,0.08);
  --border-hover:  rgba(192,20,28,0.5);
  --shadow:        0 2px 12px rgba(0,0,0,0.4);
  --shadow-hover:  0 6px 24px rgba(192,20,28,0.2);

  /* Layout density — Comfortable default */
  --card-pad-y:  1rem;
  --card-pad-x:  1.1rem;
  --card-gap:    0.75rem;
  --grid-min:    220px;
  --section-gap: 2rem;

  /* Transitions */
  --t-fast: 120ms ease;
  --t-mid:  220ms ease;
}

/* ── Light Mode ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg-primary:    #f5f0eb;
  --bg-secondary:  #ede7e0;
  --bg-card:       #ffffff;
  --bg-card-hover: #fff8f5;
  --text-primary:  #1a1a1a;
  --text-secondary:#4a4038;
  --text-muted:    #8a7c72;
  --border:        rgba(0,0,0,0.08);
  --border-hover:  rgba(192,20,28,0.4);
  --shadow:        0 2px 8px rgba(0,0,0,0.1);
  --shadow-hover:  0 6px 20px rgba(192,20,28,0.15);
}

/* ── Density Variants ─────────────────────────────────────── */
[data-density="compact"] {
  --card-pad-y:  0.65rem;
  --card-pad-x:  0.8rem;
  --card-gap:    0.5rem;
  --grid-min:    190px;
  --section-gap: 1.5rem;
}
[data-density="spacious"] {
  --card-pad-y:  1.4rem;
  --card-pad-x:  1.5rem;
  --card-gap:    1.1rem;
  --grid-min:    260px;
  --section-gap: 2.5rem;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 400;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  transition: background var(--t-mid), color var(--t-mid);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }

/* ── Animated Background ──────────────────────────────────── */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg-primary);
  overflow: hidden;
  pointer-events: none;
}
/* Subtle grain texture via SVG noise */
.bg-layer::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.6;
}
/* Red accent glow — bottom left */
.bg-layer::after {
  content: '';
  position: absolute;
  bottom: -10%;
  left: -5%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(192,20,28,0.08) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulse-glow 8s ease-in-out infinite alternate;
}
@keyframes pulse-glow {
  from { opacity: 0.5; transform: scale(1); }
  to   { opacity: 1;   transform: scale(1.1); }
}

/* Medical cross watermark — top right, very subtle */
.bg-cross {
  position: fixed;
  top: -8vw;
  right: -8vw;
  width: 36vw;
  height: 36vw;
  opacity: 0.03;
  pointer-events: none;
  z-index: 0;
}
.bg-cross::before,
.bg-cross::after {
  content: '';
  position: absolute;
  background: var(--brand-red);
}
.bg-cross::before {
  top: 50%; left: 30%;
  width: 40%; height: 100%;
  transform: translateY(-50%);
}
.bg-cross::after {
  left: 50%; top: 30%;
  width: 100%; height: 40%;
  transform: translateX(-50%);
}

/* ── App Shell ────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.logo-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1;
}
.logo-text .name {
  font-family: 'Oswald', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.logo-text .sub {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-red);
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
}
.greeting {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}
.clock-display {
  font-family: 'Oswald', sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  line-height: 1;
}
.date-display {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Weather widget */
.weather-widget {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}
.weather-icon { font-size: 1rem; }
.weather-temp { font-weight: 600; color: var(--text-primary); }

/* Icon buttons */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover {
  color: var(--brand-red);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}
.icon-btn svg { width: 16px; height: 16px; }

/* PWA install button */
#install-btn { display: none; }
#install-btn.visible { display: flex; }

/* ── Search Bar ───────────────────────────────────────────── */
.search-wrap {
  margin: 1.25rem 0 0.75rem;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-icon svg { width: 16px; height: 16px; display: block; }

#search {
  width: 100%;
  padding: 0.7rem 2.5rem 0.7rem 2.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
#search::placeholder { color: var(--text-muted); }
#search:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(192,20,28,0.15);
}

.search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: none;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-card);
}
.search-clear:hover { color: var(--brand-red); }
.search-clear.visible { display: flex; }
.search-clear svg { width: 14px; height: 14px; }

/* ── Category Nav Pills ───────────────────────────────────── */
#cat-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
#cat-nav.hidden { display: none; }
.cat-pill {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
}
.cat-pill:hover,
.cat-pill.active {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #fff;
}

/* ── Recently Used ────────────────────────────────────────── */
#recent-section {
  margin-bottom: var(--section-gap);
}
#recent-section.hidden { display: none; }

/* ── Category Sections ────────────────────────────────────── */
.category-section {
  margin-bottom: var(--section-gap);
}
.category-section.hidden { display: none; }

.category-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  user-select: none;
}
.cat-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cat-accent-bar {
  height: 2px;
  flex: 1;
  border-radius: 2px;
  opacity: 0.6;
}
.cat-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
}
.cat-chevron {
  color: var(--text-muted);
  transition: transform var(--t-fast);
  flex-shrink: 0;
}
.cat-chevron svg { width: 14px; height: 14px; display: block; }
.category-section.collapsed .cat-chevron { transform: rotate(-90deg); }
.category-section.collapsed .cat-grid { display: none; }

/* ── Card Grid ────────────────────────────────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min), 1fr));
  gap: var(--card-gap);
}

/* ── Bookmark Cards ───────────────────────────────────────── */
.bookmark-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: var(--card-pad-y) var(--card-pad-x);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cat-color, var(--brand-red));
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast);
  position: relative;
  overflow: hidden;
}
.bookmark-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}
.bookmark-card:focus-visible {
  outline: 2px solid var(--brand-red-light);
  outline-offset: 2px;
}

/* Favicon */
.card-favicon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: contain;
  background: var(--bg-secondary);
}
.card-favicon-fallback {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--cat-color, var(--brand-red));
}

.card-info {
  min-width: 0;
  flex: 1;
}
.card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.card-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* First-result highlight during search */
.bookmark-card.search-first {
  border-color: var(--brand-red) !important;
  box-shadow: 0 0 0 2px rgba(192,20,28,0.2) !important;
}

/* ── Recently Used Section ────────────────────────────────── */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--card-gap);
}
.recent-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid rgba(192,20,28,0.2);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all var(--t-fast);
}
.recent-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--brand-red);
}
.recent-name {
  font-size: 0.8rem;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── No Results ───────────────────────────────────────────── */
#no-results {
  display: none;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
#no-results.visible { display: block; }
#no-results svg { width: 40px; height: 40px; margin-bottom: 1rem; opacity: 0.4; }
#no-results p { font-size: 0.9rem; }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  letter-spacing: 0.04em;
}
.site-footer a { color: var(--brand-red); }
.site-footer a:hover { text-decoration: underline; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-family: 'Oswald', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: var(--text-muted);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
.modal-close:hover { color: var(--brand-red); background: var(--bg-card); }
.modal-close svg { width: 16px; height: 16px; }

/* Settings */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 0.88rem; font-weight: 500; }
.setting-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 42px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.toggle input:checked + .toggle-track { background: var(--brand-red); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform var(--t-fast);
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* Text input in settings */
.setting-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  width: 160px;
  outline: none;
}
.setting-input:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 2px rgba(192,20,28,0.15);
}

/* Density selector */
.density-btns {
  display: flex;
  gap: 0.4rem;
}
.density-btn {
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
}
.density-btn.active,
.density-btn:hover {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: white;
}

/* Import/Export */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--brand-red);
  background: rgba(192,20,28,0.05);
  color: var(--text-primary);
}
.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn-primary {
  background: var(--brand-red);
  color: white;
  border-radius: 7px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast);
}
.btn-primary:hover { background: var(--brand-red-dark); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
.btn-secondary:hover { border-color: var(--brand-red); color: var(--brand-red); }

/* Shortcuts modal */
.shortcut-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.5rem;
  font-size: 0.85rem;
}
.kbd {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.15rem 0.5rem;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  text-align: center;
  justify-self: start;
  align-self: center;
}

/* ── Toast Notifications ──────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toast-in 200ms ease, toast-out 200ms ease 2.5s forwards;
  pointer-events: all;
  max-width: 340px;
  text-align: center;
}
.toast.success { border-left: 3px solid #4caf50; }
.toast.error   { border-left: 3px solid var(--brand-red); }
.toast.info    { border-left: 3px solid #5bb8d4; }
@keyframes toast-in  { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; transform: translateY(-8px); } }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-red); }

/* ── Focus Visible ────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--brand-red-light);
  outline-offset: 2px;
}

/* ── Reduced Motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .header-center { display: none; }
  .site-header { gap: 0.5rem; }
  .logo-text .name { font-size: 1rem; }
  .greeting { display: none; }
}
@media (max-width: 400px) {
  #app { padding: 0 0.75rem 2rem; }
  .weather-widget .weather-desc { display: none; }
}
