.module-card {
  direction: rtl;
}

.module-list {
  padding-right: 18px;
}

.module-dialogue {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}

.dialogue-row {
  background: rgba(61, 90, 241, 0.05);
  border-radius: 10px;
  padding: 8px 10px;
}

.dialogue-role {
  font-weight: 700;
  margin-left: 6px;
}

.module-note {
  background: rgba(61, 90, 241, 0.08);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}

.module-question {
  font-weight: 700;
}

.module-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.module-option-btn {
  width: 100%;
  text-align: right;
}

.module-option-disabled {
  opacity: 0.8;
}

.module-feedback {
  margin-top: 8px;
  font-weight: 600;
}

.module-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.step-nav-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  width: 100%;
}
.step-nav-row .arrow-btn {
  flex: 0 0 auto;
}

.arrow-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.arrow-btn:disabled,
.arrow-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.arrow-btn:not(:disabled):hover {
  background: var(--primary-dark);
}
:root {
  color-scheme: light dark;
  --bg-gradient: linear-gradient(135deg, #f6f8fb 0%, #dfe9f3 100%);
  --card-bg: rgba(255, 255, 255, 0.9);
  --border-radius: 18px;
  --shadow-soft: 0 20px 40px rgba(15, 30, 80, 0.16);
  --primary: #3d5af1;
  --primary-dark: #2c3aa6;
  --text: #1f2430;
  --text-light: #4c5a77;
  --muted: #6b7694;
  --user-bubble: #3d5af1;
  --assistant-bubble: rgba(255, 255, 255, 0.88);
  --scrollbar: rgba(72, 103, 192, 0.25);
  --border: rgba(61, 90, 241, 0.14);
  font-family: "Assistant", "Inter", "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  direction: rtl;
}

.app-shell {
  width: min(960px, 95vw);
  min-height: min(820px, 97vh);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-soft);
  padding: 28px;
}

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

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-subtitle {
  margin: 6px 0 0;
  color: var(--text-light);
  font-size: 0.95rem;
  text-align: right;
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.session-badge {
  padding: 10px 14px;
  background: rgba(61, 90, 241, 0.12);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  min-width: 150px;
  text-align: center;
}
.layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  height: 100%;
}

.layout-single {
  grid-template-columns: 1fr;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.panel.admin {
  background: rgba(255, 255, 255, 0.8);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.panel-header h2 {
  margin: 0;
}

.muted {
  color: var(--muted);
  margin: 4px 0;
}

.step-pill {
  padding: 6px 12px;
  background: rgba(61, 90, 241, 0.1);
  border-radius: 10px;
  font-weight: 600;
  color: var(--primary-dark);
  min-width: 120px;
  text-align: center;
}

.step-container {
  background: rgba(61, 90, 241, 0.03);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 14px;
  min-height: 200px;
}

.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
}


.step-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 12px rgba(15, 30, 80, 0.06);
}

.step-card h3 {
  margin: 0 0 6px 0;
}

.question {
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.question:last-child {
  border-bottom: none;
}


.question textarea,
.question input[type="text"],
.question input[type="number"],
.question input[type="email"],
.question input[type="tel"] {
  width: 100%;
  max-width: 600px;
  box-sizing: border-box;
  border: 1px solid rgba(61, 90, 241, 0.25);
  border-radius: 14px;
  padding: 12px 14px;
  resize: vertical;
  font-size: 1rem;
  line-height: 1.4;
  box-shadow: inset 0 1px 4px rgba(15, 30, 80, 0.08);
  font-family: inherit;
}

.question textarea:focus,
.question input[type="text"]:focus,
.question input[type="number"]:focus,
.question input[type="email"]:focus,
.question input[type="tel"]:focus {
  outline: 2px solid rgba(61, 90, 241, 0.3);
}

.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.option-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(61, 90, 241, 0.04);
  cursor: pointer;
}

.likert-scale {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.likert-scale label {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.chat-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.persona-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(61, 90, 241, 0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.persona-ribbon {
  display: inline-flex;
  gap: 8px;
  font-weight: 700;
  color: var(--primary-dark);
}

.persona-age {
  color: var(--muted);
  font-weight: 500;
}

.timer-badge {
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(61, 90, 241, 0.1);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.timer-badge.timer-mid {
  background: rgba(255, 191, 71, 0.2);
  border-color: rgba(255, 191, 71, 0.5);
}

.timer-badge.timer-expired {
  background: rgba(227, 76, 89, 0.18);
  border-color: rgba(227, 76, 89, 0.5);
  color: #b00020;
}

.chat-window {
  overflow-y: auto;
  padding: 0 4px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  direction: rtl;
  min-height: 260px;
  max-height: 420px;
}

.persona-background {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(61, 90, 241, 0.04);
}

.persona-background-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--primary-dark);
}

.persona-background-body {
  color: var(--text-light);
  font-size: 0.95rem;
  line-height: 1.4;
}

.feedback-card {
  min-height: 200px;
}

.feedback-body {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(61, 90, 241, 0.04);
  min-height: 120px;
}

.chat-window::-webkit-scrollbar {
  width: 8px;
}

.chat-window::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  border-radius: 16px;
  max-width: 82%;
  word-wrap: break-word;
  line-height: 1.5;
  text-align: right;
}

.message h2,
.message h3,
.message h4 {
  margin-top: 1.2em;
}

.message p {
  margin: 0;
}

.message pre {
  background: rgba(15, 30, 80, 0.08);
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto;
}

#message-input {
  font-family: inherit;
}

.message code {
  background: rgba(15, 30, 80, 0.12);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.9em;
}

.input-bar {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: flex-end;
}
.message ul,
.message ol {
  padding-right: 20px;
}

.message-user {
  align-self: flex-start;
  background: var(--assistant-bubble);
  border: 1px solid rgba(61, 90, 241, 0.08);
  color: var(--text);
}

.message-assistant {
  align-self: flex-end;
  background: var(--user-bubble);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(61, 90, 241, 0.22);
}

.message small {
  font-size: 0.75rem;
  opacity: 0.7;
}

.input-bar {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: flex-end;
}

#message-input {
  width: 100%;
  border: 1px solid rgba(61, 90, 241, 0.25);
  border-radius: 14px;
  padding: 14px 16px;
  resize: none;
  font-size: 1rem;
  line-height: 1.4;
  box-shadow: inset 0 1px 4px rgba(15, 30, 80, 0.08);
  text-align: start;
}

#message-input:focus {
  outline: 2px solid rgba(61, 90, 241, 0.3);
}

#send-button {
  border: none;
  background: var(--primary);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
  min-width: 88px;
  text-align: center;
}

#send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#send-button:not(:disabled):hover {
  background: var(--primary-dark);
}

.ghost-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  align-self: flex-start;
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(61, 90, 241, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.inline-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.card {
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  min-height: 46px;
}

.table {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
}

.table table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  text-align: right;
}

.table th {
  background: rgba(61, 90, 241, 0.06);
}

.table tr:last-child td {
  border-bottom: none;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.modal-dialog {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  width: min(900px, 95vw);
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1;
}

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

.modal-body {
  overflow: auto;
  max-height: 60vh;
}

.messages-table table {
  width: 100%;
  border-collapse: collapse;
}

.messages-table th,
.messages-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  text-align: right;
}

.messages-table th {
  background: rgba(61, 90, 241, 0.06);
  position: sticky;
  top: 0;
}

.messages-table tr:last-child td {
  border-bottom: none;
}

.column-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(61, 90, 241, 0.04);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: rgba(61, 90, 241, 0.04);
  color: var(--text);
  white-space: nowrap;
}

.status-in-progress {
  background: rgba(255, 191, 71, 0.2);
  border-color: rgba(255, 191, 71, 0.6);
  color: #8a5a00;
}

.status-incomplete {
  background: rgba(227, 76, 89, 0.18);
  border-color: rgba(227, 76, 89, 0.6);
  color: #b00020;
}

.status-completed {
  background: rgba(55, 160, 90, 0.18);
  border-color: rgba(55, 160, 90, 0.5);
  color: #1d6f3a;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 20px;
    gap: 14px;
  }

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

  #message-input {
    font-size: 0.95rem;
  }
}
