/* ===== LIGHT MODE (default) ===== */
:root {
  /* Backgrounds */
  --bg: #f5f7fa;
  --card: #ffffff;
  --topbar-bg: #ffffff;

  /* Text colors */
  --text: #2c3e50;
  --text-light: #5a6c7d;
  --text-muted: #8897a8;

  /* Brand colors */
  --brand: #0066cc;
  --brand-hover: #0052a3;
  --brand-light: #e6f2ff;

  /* Status colors */
  --danger: #dc3545;
  --danger-hover: #c82333;
  --success: #28a745;
  --warning: #ffc107;

  /* Borders & dividers */
  --border: #dce1e8;
  --border-light: #e8ecf1;
  --border-dark: #c5cdd8;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);

  /* Medical table colors */
  --table-header: #f8f9fb;
  --table-border: #d5dbe3;
  --abnormal-high-bg: #fff5f5;
  --abnormal-low-bg: #f0f8ff;
  --high-text: #dc3545;
  --low-text: #0066cc;

  /* Status row colors */
  --row-red: #ffeaea;
  --row-yellow: #fff8e1;
  --row-green: #e8f5e9;

  /* Box types */
  --box-medical-border: #0066cc;
  --box-medical-bg: #f0f6ff;
  --box-nutrition-border: #28a745;
  --box-nutrition-bg: #f1f9f3;
  --box-lifestyle-border: #795548;
  --box-lifestyle-bg: #faf8f6;
  --box-note-bg: #f5f7f9;
  --box-note-border: #c5cdd8;

  /* Interactive */
  --input-bg: #ffffff;
  --input-border: #d0d6df;
  --input-focus: #0066cc;

  /* Modal */
  --modal-backdrop: rgba(0, 0, 0, 0.5);
  --modal-info-bg: rgba(0, 102, 204, 0.08);
  --modal-info-border: rgba(0, 102, 204, 0.2);
  --modal-info-text: #1e3a5f;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  /* Backgrounds */
  --bg: #1a1d23;
  --card: #252930;
  --topbar-bg: #1f232a;

  /* Text colors */
  --text: #e8eaed;
  --text-light: #b8bec6;
  --text-muted: #8891a0;

  /* Brand colors */
  --brand: #4d94ff;
  --brand-hover: #6ba6ff;
  --brand-light: #1a2e4d;

  /* Status colors */
  --danger: #ff5c6c;
  --danger-hover: #ff7382;
  --success: #4caf50;
  --warning: #ffb74d;

  /* Borders & dividers */
  --border: #383e47;
  --border-light: #2f343c;
  --border-dark: #4a5159;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.2);

  /* Medical table colors */
  --table-header: #2a2f38;
  --table-border: #383e47;
  --abnormal-high-bg: #3d2426;
  --abnormal-low-bg: #1e2a3d;
  --high-text: #ff7882;
  --low-text: #6ba6ff;

  /* Status row colors */
  --row-red: #3d2426;
  --row-yellow: #3d3520;
  --row-green: #253329;

  /* Box types */
  --box-medical-border: #4d94ff;
  --box-medical-bg: #1e2936;
  --box-nutrition-border: #66bb6a;
  --box-nutrition-bg: #1f2d23;
  --box-lifestyle-border: #a1887f;
  --box-lifestyle-bg: #2d2825;
  --box-note-bg: #2a2f38;
  --box-note-border: #383e47;

  /* Interactive */
  --input-bg: #2a2f38;
  --input-border: #383e47;
  --input-focus: #4d94ff;

  /* Modal */
  --modal-backdrop: rgba(0, 0, 0, 0.7);
  --modal-info-bg: rgba(77, 148, 255, 0.12);
  --modal-info-border: rgba(77, 148, 255, 0.25);
  --modal-info-text: #c8d9f0;
}

/* ===== BASE STYLES ===== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--topbar-bg);
  height: 64px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.brand {
  font-weight: 700;
  font-size: 22px;
  color: var(--text);
  letter-spacing: 0.3px;
}

.brand em {
  font-style: normal;
  color: var(--brand);
}

/* Theme toggle button */
.theme-toggle {
  appearance: none;
  border: none;
  background: var(--bg);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s ease;
  margin-left: auto;
  border: 1px solid var(--border);
}

.theme-toggle:hover {
  background: var(--brand-light);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* ===== LAYOUT ===== */
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

.feed {
  width: 100%;
  max-width: 680px;
  margin: 24px auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.card h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.card .media {
  width: 100%;
  display: block;
  background: var(--border);
  aspect-ratio: 16/9;
  object-fit: cover;
}

.card .body {
  padding: 20px;
  color: var(--text);
  line-height: 1.6;
  overflow-x: auto;
}

.card .body header,
.modal .modal-body header {
  margin-bottom: 20px;
}

.card .body header h1,
.modal .modal-body header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.card .body .meta,
.modal .modal-body .meta {
  color: var(--text-light);
  font-size: 0.95rem;
}

.card .body section,
.modal .modal-body section {
  margin-top: 20px;
}

.card .body footer,
.modal .modal-body footer {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-light);
}

/* ===== TABLES ===== */
.card .body table,
.modal .modal-body table {
  border-collapse: collapse;
  width: 100%;
  max-width: 900px;
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
}

.card .body thead th,
.modal .modal-body thead th {
  background: var(--table-header);
  font-weight: 600;
}

.card .body th,
.modal .modal-body th,
.card .body td,
.modal .modal-body td {
  border: 1px solid var(--table-border);
  padding: 10px 12px;
  text-align: left;
  font-size: 0.95rem;
}

.card .body caption,
.modal .modal-body caption {
  caption-side: top;
  text-align: left;
  font-weight: 600;
  padding-bottom: 10px;
  color: var(--text);
}

/* Table highlights */
.card .body tr.abnormal-high > td,
.modal .modal-body tr.abnormal-high > td,
.card .body td.abnormal-high,
.modal .modal-body td.abnormal-high {
  background: var(--abnormal-high-bg);
}

.card .body tr.abnormal-low > td,
.modal .modal-body tr.abnormal-low > td,
.card .body td.abnormal-low,
.modal .modal-body td.abnormal-low {
  background: var(--abnormal-low-bg);
}

.modal .modal-body tr.piros > td,
.card .body tr.piros > td {
  background: var(--row-red);
}

.modal .modal-body tr.sarga > td,
.card .body tr.sarga > td {
  background: var(--row-yellow);
}

.modal .modal-body tr.zold > td,
.card .body tr.zold > td {
  background: var(--row-green);
}

.card .body td.abn,
.modal .modal-body td.abn {
  width: 8%;
  text-align: center;
  font-weight: 600;
}

.card .body td.units,
.modal .modal-body td.units,
.card .body td.ref,
.modal .modal-body td.ref {
  width: 20%;
  color: var(--text-light);
}

.card .body .high,
.modal .modal-body .high {
  color: var(--high-text);
  font-weight: 600;
}

.card .body .low,
.modal .modal-body .low {
  color: var(--low-text);
  font-weight: 600;
}

/* ===== CONTENT BOXES ===== */
.card .body .note,
.modal .modal-body .note {
  background: var(--box-note-bg);
  padding: 12px 16px;
  border-left: 4px solid var(--box-note-border);
  border-radius: 6px;
  margin: 12px 0;
}

.card .body ul,
.modal .modal-body ul {
  margin: 10px 0 0 24px;
  padding-left: 0;
}

.card .body .actions,
.modal .modal-body .actions {
  margin-top: 12px;
}

.modal .modal-body .box.orvosi,
.card .body .box.orvosi {
  border-left: 4px solid var(--box-medical-border);
  padding: 12px 16px;
  background: var(--box-medical-bg);
  border-radius: 6px;
  margin: 12px 0;
}

.modal .modal-body .box.taplalkozas,
.card .body .box.taplalkozas {
  border-left: 4px solid var(--box-nutrition-border);
  padding: 12px 16px;
  background: var(--box-nutrition-bg);
  border-radius: 6px;
  margin: 12px 0;
}

.modal .modal-body .box.eletmod,
.card .body .box.eletmod {
  border-left: 4px solid var(--box-lifestyle-border);
  padding: 12px 16px;
  background: var(--box-lifestyle-bg);
  border-radius: 6px;
  margin: 12px 0;
}

/* ===== ACTIONS & BUTTONS ===== */
.actions {
  padding: 0 20px 20px;
}

.btn {
  display: inline-block;
  background: var(--brand);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  user-select: none;
}

.btn:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.btn-ghost:hover {
  background: var(--brand-light);
}

.btn-logout {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-logout:hover {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.btn-logout:active {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-close {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.btn-close:hover {
  background: var(--border-light);
  color: var(--text);
}

/* Social Login Buttons */
.btn--social {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn--social:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn--social:active {
  transform: translateY(0);
}

.btn--google {
  background: #ffffff;
  color: #3c4043;
  border-color: #dadce0;
}

.btn--google:hover {
  background: #f8f9fa;
  border-color: #c6c6c6;
}

[data-theme="dark"] .btn--google {
  background: #f8f9fa;
  color: #3c4043;
  border-color: #dadce0;
}

[data-theme="dark"] .btn--google:hover {
  background: #e8eaed;
}

.btn--apple {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
}

.btn--apple:hover {
  background: #1a1a1a;
  border-color: #1a1a1a;
}

[data-theme="dark"] .btn--apple {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

[data-theme="dark"] .btn--apple:hover {
  background: #f0f0f0;
}

.checkmark {
  color: var(--success);
  margin-left: 8px;
  font-size: 32px;
  font-weight: bold;
}

/* ===== SEARCH BAR ===== */
.searchbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 auto 16px;
  max-width: 680px;
}

.searchbar input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  outline: none;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.2s ease;
}

.searchbar input[type="search"]:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--brand-light);
}

.searchbar input[type="search"]::placeholder {
  color: var(--text-muted);
}

.searchbar .btn-clear {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: all 0.2s ease;
}

.searchbar .btn-clear:hover {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand);
}

.search-info {
  max-width: 680px;
  margin: 0 auto 12px;
  color: var(--text-muted);
  font-size: 14px;
}

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

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(92vw, 720px);
  max-height: 90vh;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: popIn 0.25s ease-out;
}

/* Force light theme for HTML content modals (from backend) */
.modal--light-content {
  --bg: #f5f7fa;
  --card: #ffffff;
  --topbar-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #5a6c7d;
  --text-muted: #8897a8;
  --brand: #0066cc;
  --brand-hover: #0052a3;
  --brand-light: #e6f2ff;
  --danger: #dc3545;
  --danger-hover: #c82333;
  --success: #28a745;
  --warning: #ffc107;
  --border: #dce1e8;
  --border-light: #e8ecf1;
  --border-dark: #c5cdd8;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);
  --table-header: #f8f9fb;
  --table-border: #d5dbe3;
  --abnormal-high-bg: #fff5f5;
  --abnormal-low-bg: #f0f8ff;
  --high-text: #dc3545;
  --low-text: #0066cc;
  --row-red: #ffeaea;
  --row-yellow: #fff8e1;
  --row-green: #e8f5e9;
  --box-medical-border: #0066cc;
  --box-medical-bg: #f0f6ff;
  --box-nutrition-border: #28a745;
  --box-nutrition-bg: #f1f9f3;
  --box-lifestyle-border: #795548;
  --box-lifestyle-bg: #faf8f6;
  --box-note-bg: #f5f7f9;
  --box-note-border: #c5cdd8;
  --input-bg: #ffffff;
  --input-border: #d0d6df;
  --input-focus: #0066cc;
  --modal-backdrop: rgba(0, 0, 0, 0.5);
  --modal-info-bg: rgba(0, 102, 204, 0.08);
  --modal-info-border: rgba(0, 102, 204, 0.2);
  --modal-info-text: #1e3a5f;
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.modal .modal-body {
  padding: 20px;
  overflow: auto;
  color: var(--text);
  line-height: 1.6;
}

.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.modal-info {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--modal-info-border);
  background: var(--modal-info-bg);
  color: var(--modal-info-text);
  margin-bottom: 20px;
}

.modal-info__icon {
  font-size: 24px;
  line-height: 1;
  color: var(--brand);
  flex-shrink: 0;
}

.modal-info__content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-info__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--modal-info-text);
}

.modal-info__text {
  margin: 0;
  color: var(--modal-info-text);
  opacity: 0.9;
}

/* ===== FORMS ===== */
.form-grid {
  display: grid;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.form-group label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="email"] {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  outline: none;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.2s ease;
}

.form-group input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--brand-light);
}

.form-group input[type="file"] {
  height: auto;
  padding: 12px 16px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.2s ease;
}

.file-hint {
  font-size: 12px;
  color: var(--brand);
  margin-top: -4px;
}

.file-preview {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-preview img {
  width: 96px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.file-icon {
  width: 96px;
  height: 54px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--danger);
  font-weight: 700;
  font-size: 12px;
}

.file-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
}

.file-add {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.file-add:hover {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand);
}

.file-meta {
  font-size: 13px;
  color: var(--text-light);
}

.file-remove {
  appearance: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: transparent;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.file-remove:hover {
  background: var(--danger);
  color: #ffffff;
}

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

.error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
}

/* ===== LOADING & UTILITIES ===== */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: 15px;
}

.is-hidden {
  display: none !important;
}

.media.ph {
  background: linear-gradient(90deg, var(--border-light), var(--border), var(--border-light));
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 720px) {
  .wrap {
    padding: 16px;
  }

  .feed {
    gap: 16px;
    margin: 16px auto;
  }

  .card h2 {
    font-size: 17px;
  }

  .topbar {
    padding: 0 16px;
    height: 56px;
  }

  .brand {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .searchbar {
    gap: 8px;
  }

  .searchbar input[type="search"] {
    min-width: 0;
  }

  .searchbar .btn-clear {
    padding: 0 12px;
    font-size: 14px;
  }

  .file-icon,
  .file-preview img {
    width: 120px;
    height: 68px;
  }

  .modal {
    width: 96vw;
    max-height: 94vh;
    border-radius: 12px;
  }
}
