:root {
  color-scheme: light dark;
  font-family: "Vazirmatn", "IRANSans", "Segoe UI", Helvetica, Arial, sans-serif;
  background-color: #f5f6f9;
  color: #222;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
}

.chat-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.chat-card {
  width: min(900px, 100%);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.5rem 2rem 0;
  color: #0f172a;
  text-decoration: none;
}

.brand-link img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.2);
  background: #fff;
  padding: 6px;
}

.brand-text {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.brand-link:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  border-radius: 16px;
  outline-offset: 6px;
}

.chat-header {
  padding: 1.75rem 2rem 1.25rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.chat-header h1 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.chat-header p {
  margin: 0;
  line-height: 1.7;
  color: #475569;
  font-size: 0.95rem;
}

.session-panel {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.session-alert {
  background: rgba(226, 232, 240, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.session-alert p {
  margin: 0;
  color: #1e293b;
  line-height: 1.8;
}

.session-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.session-links a,
.session-links button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 12px;
  padding: 0.55rem 1.1rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.session-links a.primary,
.session-links button.primary {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

.session-links a.primary:hover,
.session-links button.primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.session-links a.secondary,
.session-links button.secondary {
  background: rgba(148, 163, 184, 0.15);
  color: #1f2937;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.session-links a.secondary:hover,
.session-links button.secondary:hover {
  background: rgba(148, 163, 184, 0.25);
}

.session-login-form {
  display: grid;
  gap: 0.75rem;
}

.session-login-form label {
  font-size: 0.9rem;
  color: #334155;
}

.session-login-form input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.session-login-form input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.session-form-actions {
  display: flex;
  justify-content: flex-end;
}

.session-form-actions button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.55rem 1.35rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.session-form-actions button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.session-form-actions button:not(:disabled):hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.session-footnote {
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.6;
}

.session-error {
  font-size: 0.9rem;
  color: #dc2626;
  line-height: 1.6;
}

.session-summary {
  background: rgba(248, 250, 252, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.session-summary strong {
  font-size: 1rem;
  color: #0f172a;
}

.session-points {
  color: #2563eb;
  font-weight: 700;
  font-size: 0.95rem;
  background: rgba(37, 99, 235, 0.08);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.session-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.session-actions a {
  text-decoration: none;
}

.session-recharge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f97316;
  color: #fff !important;
  border-radius: 12px;
  padding: 0.45rem 1rem;
  font-weight: 600;
  transition: background 0.2s ease;
}

.session-recharge:hover {
  background: #ea580c;
}

.link-button {
  background: transparent;
  border: none;
  color: #2563eb;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.link-button:hover {
  background: rgba(37, 99, 235, 0.12);
}

.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.85), rgba(226, 232, 240, 0.65));
}

.chat-message {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: 18px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.chat-message.user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: #e2e8f0;
  color: #0f172a;
  border-bottom-left-radius: 4px;
}

.chat-message.status {
  align-self: center;
  background: transparent;
  color: #475569;
  font-style: italic;
  padding: 0;
}

.chat-form {
  padding: 1.25rem 2rem 1.75rem;
  display: grid;
  gap: 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(248, 250, 252, 0.9);
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 80px;
  max-height: 180px;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  font-size: 1rem;
  line-height: 1.8;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-form textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.form-actions button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.form-actions button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.form-actions button:not(:disabled):hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.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;
}

@media (max-width: 720px) {
  .chat-card {
    border-radius: 0;
    min-height: 100vh;
  }

  .chat-header,
  .chat-window,
  .chat-form {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .brand-link {
    padding: 1.25rem 1.25rem 0;
  }

  .session-links {
    flex-direction: column;
    align-items: stretch;
  }

  .session-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .chat-message {
    max-width: 90%;
  }
}
