:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f8fc;
  color: #17212b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4fc 100%);
}

html[dir="rtl"] {
  direction: rtl;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

img {
  max-width: 100%;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: rgba(255, 255, 255, 0.9);
  position: sticky;
  top: 0;
  border-bottom: 1px solid #e3e9f2;
  backdrop-filter: blur(10px);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.lang-switcher select {
  cursor: pointer;
  border: 1px solid #d4dae5;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  background: #ffffff;
  color: #17212b;
}

.brand {
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.03em;
}

.site-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.nav-link {
  color: #4b5f79;
  text-decoration: none;
  padding: 0.65rem 0.75rem;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: #e6f0ff;
  color: #1741a0;
}

.nav-link.nav-patient {
  background: #1e60ff;
  color: #ffffff;
  font-weight: 700;
}

.nav-link.nav-patient:hover {
  background: #1741a0;
  color: #ffffff;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 2rem;
  align-items: start;
  padding: 3rem 2rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-copy h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.25rem, 4vw, 3.8rem);
  line-height: 1.05;
}

.hero-copy p {
  max-width: 650px;
  margin: 0 0 1.75rem;
  color: #45546b;
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1.6rem;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  background: #1e60ff;
  color: #fff;
}

.button.secondary {
  background: #f1f5ff;
  color: #1e60ff;
}

.hero-card,
.feature,
.form-panel {
  background: #ffffff;
  border: 1px solid #e3e9f2;
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 24px 80px rgba(18, 45, 77, 0.08);
}

.hero-card h2 {
  margin-top: 0;
}

.hero-card ul {
  padding-left: 1.25rem;
  margin: 1rem 0 0;
  color: #4b5f79;
  line-height: 1.75;
}

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  max-width: 1200px;
  margin: 0 auto 2rem;
  padding: 0 2rem;
}

.feature h3 {
  margin-top: 0;
}

.page-container {
  max-width: 860px;
  margin: 0 auto 3rem;
  padding: 0 2rem;
}

.form-panel {
  margin-top: 2rem;
}

.form-panel h1 {
  margin-top: 0;
  font-size: 2rem;
}

.consult-form,
.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.consult-form label,
.login-form label {
  font-weight: 600;
  color: #233147;
}

.consult-form input,
.consult-form textarea,
.login-form input {
  width: 100%;
  border: 1px solid #d4dae5;
  border-radius: 16px;
  padding: 0.95rem 1rem;
  font-size: 1rem;
  background: #fefefe;
}

.consult-form textarea {
  resize: vertical;
  min-height: 180px;
}

.consult-clinic-info {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.clinic-name {
  padding: 0.95rem 1rem;
  border: 1px solid #d4dae5;
  border-radius: 16px;
  background: #f8fafc;
  color: #1c2442;
}

.browse-panel .form-panel {
  margin-top: 2rem;
}

.clinic-list {
  display: grid;
  gap: 1rem;
  margin-top: 1.75rem;
}

.clinic-card {
  background: #ffffff;
  border: 1px solid #e3e9f2;
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: 0 24px 60px rgba(18, 45, 77, 0.08);
}

.clinic-card h3 {
  margin-top: 0;
}

.doctor-register-action {
  margin: 1rem 0 0;
}

.doctor-dashboard {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
}

.doctor-panel {
  background: #ffffff;
  border: 1px solid #e3e9f2;
  border-radius: 24px;
  padding: 1.75rem;
}

.doctor-panel h2 {
  margin-top: 0;
}

.panel-actions {
  margin-top: 1rem;
}

.button[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

.button.small {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.form-message {
  margin-top: 1rem;
  color: #1a5f31;
  font-weight: 600;
}

.login-panel {
  padding: 2rem 0;
}

.small-note {
  margin: 0.75rem 0 0;
  color: #576578;
}

.site-footer {
  text-align: center;
  padding: 1.5rem 2rem 2rem;
  color: #5f738d;
}

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

  .features {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

html[dir="rtl"] .site-header {
  text-align: right;
}

html[dir="rtl"] .site-nav {
  justify-content: flex-end;
}

html[dir="rtl"] .hero,
html[dir="rtl"] .page-container {
  text-align: right;
}

html[dir="rtl"] .hero-card ul {
  padding-right: 1.25rem;
  padding-left: 0;
}

html[dir="rtl"] .feature,
html[dir="rtl"] .form-panel {
  text-align: right;
}

.clinic-logo {
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: #f8fafc;
  padding: 0.5rem;
}

.doctor-selection {
  margin-bottom: 1rem;
}

.doctor-selection select {
  width: 100%;
  border: 1px solid #d4dae5;
  border-radius: 16px;
  padding: 0.95rem 1rem;
  font-size: 1rem;
  background: #fefefe;
}

.registration-type {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.registration-type label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.register-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.register-form label {
  font-weight: 600;
  color: #233147;
}

.register-form input,
.register-form textarea,
.register-form select {
  width: 100%;
  border: 1px solid #d4dae5;
  border-radius: 16px;
  padding: 0.95rem 1rem;
  font-size: 1rem;
  background: #fefefe;
}

.register-form textarea {
  resize: vertical;
  min-height: 100px;
}

.register-form input[type="file"] {
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  cursor: pointer;
}

.clinic-dashboard {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
}

.clinic-panel {
  background: #ffffff;
  border: 1px solid #e3e9f2;
  border-radius: 24px;
  padding: 1.75rem;
}

.clinic-panel h2 {
  margin-top: 0;
}

/* ── Codes card (clinic registration success) ── */
.codes-card {
  background: #f0f6ff;
  border: 1px solid #b8d0ff;
  border-radius: 20px;
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.codes-card h3 {
  margin-top: 0;
  color: #1741a0;
}

.code-display {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.code-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid #cfdeff;
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
}

.code-label {
  font-weight: 700;
  color: #233147;
  min-width: 130px;
  flex-shrink: 0;
}

.code-value {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: #1e60ff;
  font-weight: 700;
  flex: 1;
}

.copy-btn {
  background: #e6f0ff;
  color: #1741a0;
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: #cfdeff;
}

/* ── Dashboard tabs ── */
.tab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #f1f5ff;
  color: #4b5f79;
  border: 1px solid #d4dae5;
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  background: #ddeaff;
  color: #1741a0;
}

.tab-btn.active {
  background: #1e60ff;
  color: #fff;
  border-color: #1e60ff;
}

/* Tab panels are shown/hidden by JS inline styles; no default hiding needed here */

/* ── Badge (pending staff count) ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e84040;
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
}

/* ── Consult table ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid #e3e9f2;
}

.consult-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.consult-table th {
  background: #f1f5ff;
  color: #233147;
  font-weight: 700;
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
}

.consult-table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid #eef2f8;
  vertical-align: top;
}

.consult-table tr:hover td {
  background: #f8fbff;
}

.highlighted-row td {
  background: #fffbea !important;
}

html[dir="rtl"] .consult-table th,
html[dir="rtl"] .consult-table td {
  text-align: right;
}

/* ── Status badges ── */
.status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pending {
  background: #fff3cd;
  color: #856404;
}

.status-reviewed {
  background: #d1ecf1;
  color: #0c5460;
}

.status-replied {
  background: #d4edda;
  color: #155724;
}

/* ── Eligibility badge ── */
.eligibility-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.eligibility-badge.free {
  background: #d4edda;
  color: #155724;
}

.eligibility-badge.paid {
  background: #fff3cd;
  color: #856404;
}

.eligibility-badge.pending {
  background: #f1f5ff;
  color: #4b5f79;
}

/* ── Reply input inside table ── */
.existing-reply {
  background: #f0f6ff;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  color: #233147;
  margin-bottom: 0.5rem;
}

.reply-input {
  width: 100%;
  border: 1px solid #d4dae5;
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
  background: #fefefe;
}

.reply-submit-btn {
  margin-top: 0.4rem;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  border-radius: 999px;
  background: #1e60ff;
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
}

.reply-submit-btn:hover {
  background: #1741a0;
}

/* ── Attachment download button ── */
.btn-attachment {
  display: inline-block;
  background: #f1f5ff;
  color: #1741a0;
  border: 1px solid #cfdeff;
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  transition: background 0.2s;
}

.btn-attachment:hover {
  background: #ddeaff;
}

/* ── Pending notice (unapproved staff) ── */
.pending-notice {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  color: #856404;
  font-weight: 600;
  margin-top: 1rem;
}

/* ── Portal actions ── */
.portal-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* ── Dashboard panel ── */
.dashboard-panel {
  background: #ffffff;
  border: 1px solid #e3e9f2;
  border-radius: 24px;
  padding: 2rem;
  margin-top: 1.5rem;
  box-shadow: 0 24px 80px rgba(18, 45, 77, 0.06);
}

.dashboard-panel h2 {
  margin-top: 0;
  font-size: 1.4rem;
}

/* ── Patient registration radio group ── */
.clinic-question-fieldset {
  border: 1px solid #d4dae5;
  border-radius: 16px;
  padding: 1rem 1.25rem;
  margin: 0;
}

.clinic-question-fieldset legend {
  font-weight: 600;
  color: #233147;
  padding: 0 0.4rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.35rem 0;
}

.radio-label input[type="radio"] {
  accent-color: #1e60ff;
  width: 1.1rem;
  height: 1.1rem;
}

/* ── Login prompt on consult page ── */
.login-prompt-box {
  background: #f0f6ff;
  border: 1px solid #b8d0ff;
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  margin-top: 1.5rem;
}

.login-prompt-box h2 {
  margin-top: 0;
  color: #1741a0;
}

.login-prompt-box p {
  color: #45546b;
  margin-bottom: 1.5rem;
}

.login-prompt-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Register action link ── */
.register-action {
  margin-top: 1.25rem;
}

/* ── Eligibility notice on consult page ── */
#eligibilityNotice {
  margin-bottom: 1rem;
}

/* ── RTL dashboard table ── */
html[dir="rtl"] .tab-bar {
  justify-content: flex-end;
}

html[dir="rtl"] .code-label {
  text-align: right;
}

html[dir="rtl"] .code-item {
  flex-direction: row-reverse;
}

/* ── Portal header ── */
.portal-header {
  position: relative;
}

.welcome-msg {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 700;
  color: #1741a0;
  font-size: 1rem;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Profile strip (phone edit) ── */
.profile-strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 1.25rem;
  background: #f8fbff;
  border: 1px solid #e3e9f2;
  border-radius: 14px;
  padding: 0.75rem 1rem;
}

.profile-label {
  font-weight: 600;
  color: #233147;
  font-size: 0.9rem;
  white-space: nowrap;
}

.profile-input {
  border: 1px solid #d4dae5;
  border-radius: 10px;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  background: #fff;
  width: 180px;
}

.profile-msg {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a5f31;
}

/* ── Consult detail modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 45, 77, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-box {
  background: #ffffff;
  border-radius: 24px;
  padding: 2rem 2rem 1.5rem;
  max-width: 620px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 32px 80px rgba(18, 45, 77, 0.18);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: #f1f5ff;
  border: none;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  cursor: pointer;
  color: #4b5f79;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #e0eaff;
}

.modal-section {
  margin-bottom: 1.25rem;
}

.modal-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7fa0;
}

.modal-section p {
  margin: 0;
  color: #17212b;
  line-height: 1.6;
}

.modal-reply-box {
  background: #f0f6ff;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: #233147;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #eef2f8;
}

/* ── Addressed-to badge in dashboards ── */
.to-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.to-badge.to-specific {
  background: #ddeaff;
  color: #1741a0;
}

.to-badge.to-general {
  background: #f1f5ff;
  color: #6b7fa0;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .code-item {
    flex-wrap: wrap;
  }

  .tab-btn {
    font-size: 0.85rem;
    padding: 0.55rem 1rem;
  }

  .consult-table th,
  .consult-table td {
    padding: 0.6rem 0.75rem;
  }

  .portal-actions {
    flex-direction: column;
  }
}
