:root {
  --bg: #f7f9fb;
  --card-bg: #ffffff;
  --border: #e5eaef;
  --text: #16222b;
  --text-muted: #64748b;
  --accent: #0d9488;
  --accent-dark: #0a6f66;
  --accent-bg: rgba(13, 148, 136, 0.1);
  --purple: #7c6fe8;
  --purple-dark: #6355d6;
  --purple-bg: rgba(124, 111, 232, 0.1);
  --danger: #d64545;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(16, 42, 51, 0.06), 0 1px 2px rgba(16, 42, 51, 0.04);
}

* {
  box-sizing: border-box;
}

/* The [hidden] attribute is how every screen/form in this app is shown or
   hidden from JS. Several elements below (e.g. .auth-form, .layout) set
   their own unconditional `display`, which — being an author rule at equal
   specificity — beats the browser's default `[hidden] { display: none }`.
   This single !important rule makes [hidden] always win, everywhere, so
   this bug class can't resurface as the app grows. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  /* Solid app background with a fine, evenly-spaced dot grid tiled on top —
     pure CSS via a radial-gradient (no image file/data-URI). Each 24x24px
     tile gets one small dot at its center; repeated, that reads as a clean,
     regular graph-paper-style grid. Applied once here so the dashboard,
     profile page, and auth screens all share the exact same background —
     the opaque white .topbar and card backgrounds sit above it and hide it
     completely, so it only ever shows through the open page areas behind
     the cards. */
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(13, 148, 136, 0.09) 1.5px, transparent 1.5px);
  background-repeat: repeat;
  background-size: 24px 24px;
  color: var(--text);
}

.topbar {
  padding: 18px clamp(16px, 5vw, 48px);
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.topbar-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.topbar-left {
  grid-column: 1;
  justify-self: start;
}

.topbar-center {
  grid-column: 2;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 900px) {
  .topbar-row {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .topbar-left,
  .topbar-center,
  .topbar-right {
    justify-self: center;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.layout {
  padding: clamp(16px, 4vw, 32px);
  max-width: 1500px;
  margin: 0 auto;
}

.notes-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.notes-column {
  display: flex;
  flex-direction: column;
}

@media (max-width: 820px) {
  .notes-columns {
    grid-template-columns: 1fr;
  }
}

.pill-btn {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.2s ease, opacity 0.15s ease;
}

.pill-btn:hover:not(:disabled) {
  transform: scale(1.02);
}

.pill-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.pill-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon svg {
  display: block;
}

.record-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.35);
}

.record-btn.is-recording {
  animation: pulse-soft 1.6s infinite;
}

.record-btn:disabled.is-recording {
  animation: none;
}

/* Secondary top-bar / header actions (Стоп, Нов запис, Копирай всичко) all
   share the same compact white/outline look from the mockup — only the
   primary "Запис" action stays filled teal. */
.outline-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.outline-btn:hover:not(:disabled) {
  background: #f8fafb;
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-soft {
  0% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.25); }
  70% { box-shadow: 0 0 0 10px rgba(13, 148, 136, 0); }
  100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

.timer {
  margin: 6px 0 0;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-muted);
}

.secondary-btn {
  background: #eef3f4;
  color: var(--accent-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn:hover {
  background: #e2ebec;
}

.error-box {
  margin-top: 14px;
  background: #fdecec;
  color: var(--danger);
  border: 1px solid #f4c6c6;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
}

.fields-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.fields-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fields-header h2 {
  margin: 0;
  font-size: 19px;
}

.fields-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Field cards ---------- */

.field {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.field-label-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.field label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* Colored icon badges: teal for the left column, purple for the right —
   matching the mockup's two-tone system. .icon-text is for the "ICD" /
   "Rx" badges, which use a short text glyph instead of an SVG. */
.field-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.field-icon.teal {
  background: var(--accent-bg);
  color: var(--accent);
}

.field-icon.purple {
  background: var(--purple-bg);
  color: var(--purple);
}

.field-icon.icon-text {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-style: normal;
}

.fields-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.copy-btn:hover {
  background: #f8fafb;
  color: var(--text);
}

.field textarea {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 4px 2px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  overflow-y: hidden; /* auto-grow (script.js) resizes to fit content instead of scrolling internally */
  color: var(--text);
  min-height: 48px;
}

.field textarea:focus {
  outline: none;
  background: rgba(13, 148, 136, 0.04);
  border-radius: 6px;
}


/* ---------- Profile menu (top right) ---------- */

.topbar-right {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-menu {
  position: relative;
  flex-shrink: 0;
}

.profile-menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  cursor: pointer;
  font-family: inherit;
}

.profile-menu-btn:hover {
  background: #f0f4f5;
}

.profile-menu-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-menu-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}

.profile-menu-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.profile-menu-specialty {
  font-size: 11px;
  color: var(--text-muted);
}

.profile-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 140px;
  overflow: hidden;
  z-index: 20;
}

.profile-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.profile-menu-dropdown button:hover {
  background: #f0f4f5;
}

#logoutBtn {
  color: var(--danger);
}

/* ---------- Centered auth / profile screens ---------- */

.centered-screen {
  max-width: 480px;
  min-height: calc(100vh - 120px);
  margin: 0 auto;
  padding: clamp(24px, 6vw, 48px) 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* The profile form has noticeably more fields than the auth screens — give
   it a wider, more comfortable column instead of sharing the 480px login
   width. */
#profileScreen.centered-screen {
  max-width: 640px;
}

.auth-card,
.profile-card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h2,
.profile-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.auth-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.auth-form,
.profile-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.auth-form label,
.profile-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
  text-align: left;
}

.auth-form input,
.profile-form input,
.profile-form select {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.auth-form input:focus,
.profile-form input:focus,
.profile-form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  text-align: center;
  text-decoration: underline;
}

.auth-message {
  margin-top: 14px;
  background: #eaf6ee;
  color: #1e7a3a;
  border: 1px solid #c7e9d0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
}

.auth-switch {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.consent-row {
  flex-direction: row !important;
  align-items: flex-start !important;
  gap: 10px !important;
  font-weight: 400 !important;
  color: var(--text) !important;
  font-size: 13px !important;
}

.consent-row input {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.profile-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.profile-form-actions .record-btn {
  flex: 1;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-error {
  font-size: 12px;
  font-weight: 400;
  color: var(--danger);
}

/* ---------- Searchable specialty combobox ---------- */

.combobox {
  position: relative;
}

.combobox input[type="text"] {
  width: 100%;
}

.combobox-listbox {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
  z-index: 30;
}

.combobox-group-label {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.combobox-option {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
}

.combobox-option:hover,
.combobox-option.is-highlighted {
  background: var(--accent-bg);
  color: var(--accent-dark);
}

.combobox-empty {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Password checklist + strength meter ---------- */

.pw-meta {
  margin-top: -6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pw-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.pw-check {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.pw-check::before {
  content: "○";
  font-size: 9px;
}

.pw-check.met {
  color: #1e7a3a;
}

.pw-check.met::before {
  content: "✓";
}

.pw-strength-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.pw-strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.2s ease, background 0.2s ease;
  background: var(--danger);
}

.pw-strength-fill.weak {
  background: var(--danger);
}

.pw-strength-fill.medium {
  background: #d68a00;
}

.pw-strength-fill.strong {
  background: #1e7a3a;
}

.pw-strength-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Signup success screen ---------- */

.auth-success {
  text-align: center;
}

.auth-success-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #eaf6ee;
  color: #1e7a3a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.auth-success h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.auth-success-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 20px;
}
