/* ===== HumAI Shared Styles ===== */

/* === CSS Variables === */
:root {
  --charcoal: #1A1A2E;
  --charcoal-light: #252540;
  --charcoal-lighter: #2E2E4A;
  --terracotta: #C75B39;
  --terracotta-hover: #B5502F;
  --sage: #6B8F71;
  --sage-hover: #5A7D60;
  --gold: #D4A853;
  --warm-white: #FAFAF7;
  --stone: #F0EDE8;
  --stone-dark: #E4E0DA;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.08);
}

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

/* === Typography === */
html { font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--warm-white);
  color: var(--text);
  min-height: 100vh;
}

/* === Skip to Content (Accessibility) === */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--terracotta);
  color: #fff;
  padding: 8px 16px;
  z-index: 10000;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
  transition: top 150ms ease;
}
.skip-to-content:focus {
  top: 0;
}

/* === Focus Visible (Accessibility) === */
:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

/* Remove redundant outline when focus comes from click */
:focus:not(:focus-visible) {
  outline: none;
}

/* === Form Elements === */
.form-group { margin-bottom: 18px; }

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.optional-tag {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.input, .textarea {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  transition: border-color 150ms ease;
}

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(199,91,57,.1);
}

.input:focus-visible, .textarea:focus-visible {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(199,91,57,.15);
}

.textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.6;
}

.textarea-lg { min-height: 260px; }

select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* === Logo === */
.logo-icon {
  background: var(--terracotta);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
}

.logo-text {
  font-weight: 700;
  color: var(--charcoal);
}

.logo-accent { color: var(--terracotta); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
}

.btn:disabled, .btn-submit:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--terracotta); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--terracotta-hover); }

.btn-secondary { background: var(--stone); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--stone-dark); }

.btn-success { background: var(--sage); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--sage-hover); }

.btn-lg { padding: 14px 36px; font-size: 16px; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--stone);
  color: var(--text);
}

.btn-submit {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  background: var(--terracotta);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 150ms ease;
  margin-top: 6px;
}

.btn-submit:hover:not(:disabled) { background: var(--terracotta-hover); }
.btn-submit:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }

/* === Cards === */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

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

.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* === Toast Notifications === */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  max-width: 360px;
  word-wrap: break-word;
}

.toast-success { background: var(--sage); }
.toast-error { background: #EF4444; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Loading Spinner === */
.loading-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--stone);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 20px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === Error Message === */
.error-msg {
  background: #FEF2F2;
  color: #DC2626;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: none;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* === Success Message === */
.success-msg-inline {
  background: rgba(107,143,113,.08);
  color: var(--sage);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid rgba(107,143,113,.2);
}

/* === Screen Reader Only === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* === Empty State === */
.empty-state-box {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state-box svg {
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state-box h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-state-box p {
  font-size: 14px;
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto;
}

/* === Loading Skeleton === */
.skeleton {
  background: linear-gradient(90deg, var(--stone) 25%, var(--stone-dark) 50%, var(--stone) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease infinite;
  border-radius: var(--radius);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Embed Code Block === */
.embed-code {
  background: var(--charcoal);
  color: #A8E6A3;
  padding: 14px;
  border-radius: var(--radius);
  font-family: 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  margin-top: 8px;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.copy-btn:hover { background: rgba(255,255,255,.25); }

/* === Login Link === */
.login-link {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.login-link a {
  color: var(--terracotta);
  text-decoration: none;
  font-weight: 600;
}

.login-link a:hover { text-decoration: underline; }

/* === Responsive defaults === */
@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
  .btn-submit { font-size: 15px; padding: 12px; }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .loading-spinner { animation: spin 2s linear infinite; }
}
