/* ============================================
   OpsDoctor Compliance Chatbot - Styles
   ============================================ */

/* --- Reset & Base --- */

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

:root {
  --bg-primary: #0a0e14;
  --bg-secondary: #0d1117;
  --bg-tertiary: #1a1f2e;
  --bg-input: #141922;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #10b981;
  --accent-hover: #0ea572;
  --accent-dim: rgba(16, 185, 129, 0.1);
  --accent-dim-hover: rgba(16, 185, 129, 0.18);
  --border: #1e293b;
  --border-light: #2d3748;
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --transition: 150ms ease;
}

html {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

input,
textarea,
select {
  font-family: inherit;
}

.hidden {
  display: none !important;
}


/* --- CUI Warning Banner --- */

.cui-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(234, 179, 8, 0.08);
  border-bottom: 1px solid rgba(234, 179, 8, 0.15);
  font-size: 0.8125rem;
  color: #fbbf24;
  flex-shrink: 0;
}

.cui-banner-icon {
  font-size: 1rem;
  line-height: 1;
}


/* --- Site Header --- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  min-height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.header-logo:hover {
  text-decoration: none;
}

.header-brand {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 7px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  text-decoration: none;
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-ghost .btn-text {
  display: inline;
}


/* --- Main Content --- */

.main-content {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.main-content::-webkit-scrollbar {
  width: 6px;
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

.main-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}


/* --- Hero Section --- */

.hero-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100%;
  padding: 40px 20px;
}

.hero-inner {
  max-width: 640px;
}

.hero-headline {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.hero-accent {
  color: var(--accent);
}

.hero-subhead {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}

.example-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.example-pill {
  padding: 10px 18px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.example-pill:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}


/* --- Chat Messages --- */

.chat-messages {
  padding: 24px 16px;
}


/* --- Message Bubbles --- */

.message {
  max-width: 760px;
  margin: 0 auto 16px;
  display: flex;
  gap: 12px;
  animation: message-in 200ms ease;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.message.assistant {
  justify-content: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.message.assistant .message-avatar {
  background: var(--accent-dim);
  color: var(--accent);
}

.message.user .message-avatar {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  order: 2;
}

.message-content {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.65;
  max-width: calc(100% - 44px);
}

.message.user .message-content {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  border-bottom-left-radius: 4px;
}

/* Message text formatting */
.message-content p {
  margin-bottom: 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin-bottom: 4px;
}

.message-content code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125em;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  color: var(--accent);
}

.message-content pre {
  margin: 8px 0;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  overflow-x: auto;
}

.message-content pre code {
  padding: 0;
  background: none;
  color: var(--text-primary);
}


/* --- Source Citations --- */

.message-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.source-tag {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 8px;
  white-space: normal;
  word-break: break-word;
}

.source-tag::before {
  content: '';
  width: 5px;
  height: 5px;
  margin-top: 5px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}


/* --- Loading Indicator --- */

.loading-indicator {
  display: flex;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto 16px;
  animation: message-in 200ms ease;
}

.loading-indicator .message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
}

.loading-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
}

.loading-dots span {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: dot-pulse 1.4s infinite ease-in-out;
}

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

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

@keyframes dot-pulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}


/* --- Input Area --- */

.chat-input-area {
  padding: 12px 16px 8px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 16px;
  transition: border-color var(--transition);
}

.input-container:focus-within {
  border-color: var(--accent);
}

#chat-input {
  flex: 1;
  padding: 8px 0;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
}

#chat-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  transition: background var(--transition), opacity var(--transition);
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.input-footer {
  text-align: center;
  padding: 6px 0 2px;
  font-size: 0.6875rem;
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto;
}

.input-disclaimer {
  color: var(--text-muted);
}

.input-footer-sep {
  margin: 0 4px;
  color: var(--text-muted);
}

.input-cta a {
  font-size: 0.6875rem;
}


/* --- Site Footer --- */

.site-footer {
  padding: 6px 16px 10px;
  text-align: center;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.footer-inner {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.footer-inner a {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.footer-inner a:hover {
  color: var(--accent);
}

.footer-sep {
  margin: 0 6px;
}

.footer-disclaimer {
  color: var(--text-muted);
}


/* --- Modal Overlay --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.modal-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.modal-title {
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal-desc {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-fine-print {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
}


/* --- Auth Forms --- */

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
  text-align: center;
}

.form-subtitle {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.required {
  color: var(--error);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-error {
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--error);
  background: var(--error-bg);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.form-success {
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--success);
  background: var(--success-bg);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.btn-primary {
  width: 100%;
  padding: 11px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 4px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-switch {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 20px;
}

.auth-switch a {
  font-weight: 500;
}


/* --- Error Toast --- */

.error-toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  z-index: 50;
  animation: toast-in 200ms ease;
  max-width: 90%;
  text-align: center;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}


/* --- Responsive --- */

@media (max-width: 640px) {
  .cui-banner {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .site-header {
    padding: 0 12px;
  }

  .nav-link {
    display: none;
  }

  .btn-ghost .btn-text {
    display: none;
  }

  .btn-ghost {
    padding: 7px 8px;
  }

  .hero-section {
    padding: 24px 16px;
  }

  .hero-headline {
    font-size: 1.375rem;
  }

  .hero-subhead {
    font-size: 0.9375rem;
    margin-bottom: 24px;
  }

  .example-pill {
    font-size: 0.75rem;
    padding: 8px 14px;
  }

  .chat-messages {
    padding: 16px 12px;
  }

  .message {
    gap: 8px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 0.6875rem;
  }

  .message-content {
    font-size: 0.875rem;
    padding: 10px 14px;
  }

  .chat-input-area {
    padding: 10px 12px 6px;
  }

  .modal-card {
    padding: 28px 20px 24px;
  }

  .input-footer {
    font-size: 0.625rem;
  }

  .site-footer {
    padding: 4px 12px 8px;
  }
}
