/* Base styles */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light;
  color: #111827;
  background-color: #ffffff;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  font-weight: 500;
  color: #646cff;
  text-decoration: inherit;
}
a:hover {
  color: #535bf2;
}

body {
  margin: 0;
  padding: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #ffffff;
}

h1 {
  font-size: 3.2em;
  line-height: 1.1;
}

h1:focus {
  outline: none;
}

button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.25s;
}
button:hover {
  border-color: #646cff;
}
button:focus,
button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

/* Blazor error UI */
#blazor-error-ui {
  color-scheme: light only;
  background: lightyellow;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

.blazor-error-boundary {
  background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OS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2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
  padding: 1rem 1rem 1rem 3.7rem;
  color: white;
}

.blazor-error-boundary::after {
  content: "An error has occurred."
}

.loading-progress {
  position: absolute;
  display: block;
  width: 8rem;
  height: 8rem;
  inset: 20vh 0 auto 0;
  margin: 0 auto 0 auto;
}

.loading-progress circle {
  fill: none;
  stroke: #e0e0e0;
  stroke-width: 0.6rem;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
}

.loading-progress circle:last-child {
  stroke: #1b6ec2;
  stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
  transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
  position: absolute;
  text-align: center;
  font-weight: bold;
  inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
  content: var(--blazor-load-percentage-text, "Loading");
}

/* App styles */
.app-container {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  align-items: center;
  justify-content: flex-start;
}

.app-header {
  width: 100%;
  padding: 1.5rem 2rem;
  border: none;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: #ffffff;
  text-align: center;
  box-sizing: border-box;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  width: 100%;
}

.header-logo {
  width: clamp(50px, 10vw, 80px);
  height: clamp(50px, 10vw, 80px);
  flex-shrink: 0;
}

.header-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #202124;
  line-height: 1.3;
}

.header-subtitle {
  font-size: clamp(0.875rem, 2.5vw, 1.125rem);
  margin-top: clamp(0.25rem, 1vw, 0.5rem);
  color: #555;
  line-height: 1.5;
}

.header-link {
  color: #9b51e0;
  text-decoration: none;
  transition: color 0.2s;
  font-weight: 500;
}

.header-link:hover {
  color: #7d3cb8;
  text-decoration: underline;
}

.pass-logo {
  height: 60px;
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  flex-shrink: 0;
  background-color: #1a1a2e;
  padding: 0.5rem;
  border-radius: 8px;
}

.contact-button {
  position: fixed;
  top: 6.5rem;
  right: 1rem;
  z-index: 1000;
  padding: 0.5rem 1rem;
  background: #9b51e0;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.contact-button:hover {
  background: #8642cc;
  color: white;
}

.contact-button:active {
  background: #7333b8;
}

.chat-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  padding: 1rem 2rem 2rem;
  box-sizing: border-box;
  padding-top: 240px;
}

.clear-button {
  display: block;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  width: 100%;
  flex: 1;
}

.clear-button:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.clear-button:active {
  background: #f3f4f6;
}

.chat-main {
  flex: 1;
  padding: 0.25rem 0;
  overflow-y: auto;
  background: transparent;
  box-sizing: border-box;
  margin-bottom: 0.5rem;
}

.message {
  margin: 0.15rem 0;
  white-space: pre-wrap;
  padding: 0.4rem 0.6rem;
  border-radius: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: #374151;
  text-align: left;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.05rem;
}

.message > strong {
  font-size: 0.825rem;
  font-weight: 600;
  color: #6b7280;
}

.copy-button {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #6b7280;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.copy-button:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  color: #374151;
}

.copy-button:active {
  background: #f3f4f6;
}

.message-assistant {
  background: #f9fafb;
  border: none;
  margin-right: auto;
  margin-left: 0;
  max-width: 100%;
  text-align: left;
}

.message-assistant > strong {
  text-align: left;
}

.message-user {
  background: transparent;
  border: none;
  padding: 0.3rem 0.6rem;
  margin-left: auto;
  margin-right: 0;
  max-width: 80%;
  text-align: right;
}

.message-user > strong {
  text-align: right;
}

.message-user .message-header {
  justify-content: flex-end;
}

/* Markdown content spacing */
.message p {
  margin: 0.15rem 0;
  line-height: 1.4;
}

.message p:first-of-type,
.message div:first-of-type {
  margin-top: 0 !important;
}

.message p:last-of-type,
.message div:last-of-type {
  margin-bottom: 0 !important;
}

.message h1,
.message h2,
.message h3,
.message h4 {
  margin: 0.3rem 0 0.1rem 0;
  font-weight: 600;
  line-height: 1.2;
}

.message h1 {
  font-size: 1.5rem;
}

.message h2 {
  font-size: 1.35rem;
}

.message h3 {
  font-size: 1.2rem;
}

.message h4 {
  font-size: 1.1rem;
}

.message h1:first-child,
.message h2:first-child,
.message h3:first-child,
.message h4:first-child {
  margin-top: 0 !important;
}

.message ul,
.message ol {
  margin: 0.15rem 0;
  padding-left: 1.5rem;
  line-height: 1.4;
}

.message ul:first-child,
.message ol:first-child {
  margin-top: 0 !important;
}

.message ul:last-child,
.message ol:last-child {
  margin-bottom: 0 !important;
}

.message li {
  margin: 0;
  margin-bottom: 0.05rem;
  line-height: 1.4;
}

.message li > p,
.message li > div {
  margin: 0 !important;
  display: inline;
}

.message hr {
  margin: 0.3rem 0;
  border: none;
  border-top: 1px solid #e5e5e5;
}

.message code {
  background: #f3f4f6;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.875em;
}

.message pre {
  background: #1f2937;
  color: #f9fafb;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.3rem 0;
}

.message pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.message blockquote {
  margin: 0.2rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid #d1d5db;
  color: #6b7280;
}

.message strong {
  font-weight: 600;
}

.message em {
  font-style: italic;
}

/* Loading animation */
.loading-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.loading-dots {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9b51e0;
  animation: pulse 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
  animation-delay: 0s;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1.1);
  }
}

.chat-input-container {
  position: sticky;
  bottom: 0;
  background: #ffffff;
  border-top: 1px solid #e5e5e5;
  padding: 0.75rem 1rem 1rem;
}

.chat-form {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0;
  border: none;
  background: transparent;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 100px;
}

.chat-textarea {
  flex: 1;
  min-width: 200px;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: #111827;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  height: 80px;
}

.chat-textarea::placeholder {
  color: #9ca3af;
  opacity: 1;
}

.chat-textarea:focus {
  outline: none;
  border-color: #9b51e0;
  box-shadow: 0 0 0 3px rgba(155, 81, 224, 0.1);
}

.chat-button {
  padding: 0;
  border-radius: 10px;
  border: none;
  background: #9b51e0;
  color: white;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background-color 0.2s;
  white-space: nowrap;
  width: 100%;
  flex: 1;
}

.chat-button:hover:not(:disabled) {
  background: #8642cc;
}

.chat-button:active:not(:disabled) {
  background: #7333b8;
}

.chat-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .chat-form {
    flex-direction: column;
    align-items: stretch;
  }

  .button-group {
    flex-direction: row;
    width: 100%;
  }

  .chat-button {
    height: 50px;
  }

  .chat-textarea {
    border-radius: 12px;
    height: 80px;
  }

  .clear-button {
    height: 50px;
  }

  .pass-logo {
    height: 40px;
    top: 0.75rem;
    right: 0.75rem;
  }

  .contact-button {
    top: 3.5rem;
    right: 0.75rem;
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
  }

  .app-header {
    padding: 1rem 1.5rem;
  }

  .chat-wrapper {
    padding-top: 260px;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .chat-input-container {
    padding: 0.75rem 0.75rem 1rem;
  }
}
