/* ==========================================================================
   Aibility Trust Center — Trust-specific styles
   Extends design-system.css with document-specific layout & components
   ========================================================================== */

/* ---------- Layout ---------- */
main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
  padding-top: 120px; /* Clear fixed header */
}

/* ---------- Document View ---------- */
.document {
  background: var(--color-bg-card, #ffffff);
  border-radius: var(--radius-lg, 12px);
  padding: 48px;
  border: 1px solid var(--color-border, #e5e7eb);
}

.document-title {
  font-size: 2em;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--color-border, #e5e7eb);
  color: var(--color-text-primary, #111827);
}

.document-content h1 { font-size: 1.75em; margin: 2em 0 0.75em; font-weight: 700; color: var(--color-text-primary, #111827); }
.document-content h2 { font-size: 1.4em; margin: 2.25em 0 0.75em; font-weight: 600; color: var(--color-text-primary, #111827); }
.document-content h2:first-child { margin-top: 0; }
.document-content h3 { font-size: 1.15em; margin: 1.75em 0 0.5em; font-weight: 600; color: var(--color-text-secondary, #374151); }
.document-content h4 { font-size: 1em; margin: 1.25em 0 0.5em; font-weight: 600; color: var(--color-text-secondary, #374151); }

.document-content p {
  margin: 0 0 1em;
}

.document-content a {
  color: var(--color-accent, #7C3AED);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.document-content a:hover {
  color: var(--color-accent-hover, #6D28D9);
}

.document-content ul,
.document-content ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

.document-content li {
  margin-bottom: 0.25em;
}

.document-content blockquote {
  border-left: 3px solid var(--color-border, #d1d5db);
  padding: 8px 16px;
  margin: 1em 0;
  color: var(--color-text-secondary, #4b5563);
  background: var(--color-bg-secondary, #f9fafb);
  border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
}

.document-content code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--color-bg-secondary, #f3f4f6);
  padding: 2px 6px;
  border-radius: 3px;
}

.document-content pre {
  background: #1f2937;
  color: #e5e7eb;
  padding: 16px;
  border-radius: var(--radius-md, 8px);
  overflow-x: auto;
  margin: 1em 0;
  font-size: 0.875em;
  line-height: 1.5;
}

.document-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ---------- Tables ---------- */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5em 0;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border-light, #f3f4f6);
  border-radius: var(--radius-md, 8px);
}

.document-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875em;
  line-height: 1.5;
}

.document-content thead th {
  background: var(--color-bg-secondary, #f9fafb);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--color-border, #e5e7eb);
  white-space: nowrap;
}

.document-content tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border-light, #f3f4f6);
  vertical-align: top;
}

.document-content tbody tr:last-child td {
  border-bottom: none;
}

.document-content tbody tr:hover {
  background: var(--color-bg-secondary, #fafbfc);
}

/* Code inside tables: prevent overflow */
.document-content td code {
  font-size: 0.8em;
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Bold cells in first column (common pattern) */
.document-content td:first-child strong {
  white-space: nowrap;
}

/* Horizontal rules between sections */
.document-content hr {
  border: none;
  border-top: 1px solid var(--color-border, #e5e7eb);
  margin: 2em 0;
}

/* Reduce spacing when hr directly precedes a heading */
.document-content hr + h2 { margin-top: 1em; }
.document-content hr + h3 { margin-top: 0.75em; }

/* ---------- Hero (Index) ---------- */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero h1 {
  font-size: 2.25em;
  font-weight: 700;
  color: var(--color-text-primary, #111827);
  margin-bottom: 12px;
}

.hero-description {
  font-size: 1.15em;
  color: var(--color-text-secondary, #6b7280);
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Document Cards (Index) ---------- */
.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.doc-card {
  display: block;
  background: var(--color-bg-card, #ffffff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: var(--radius-lg, 12px);
  padding: 24px;
  text-decoration: none;
  color: var(--color-text-primary, #1a1a2e);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.doc-card:hover {
  border-color: var(--color-accent, #7C3AED);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}

.doc-card h3 {
  font-size: 1.05em;
  font-weight: 600;
  margin: 0;
}

.empty {
  text-align: center;
  color: var(--color-text-tertiary, #9ca3af);
  padding: 48px 0;
}

/* ---------- Auth Form ---------- */
.auth-container {
  max-width: 420px;
  margin: 60px auto;
  background: var(--color-bg-card, #ffffff);
  border-radius: var(--radius-lg, 12px);
  padding: 40px;
  border: 1px solid var(--color-border, #e5e7eb);
}

.auth-container h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text-primary, #111827);
}

.auth-container > p {
  color: var(--color-text-secondary, #6b7280);
  margin-bottom: 8px;
}

.doc-name {
  font-weight: 600;
  color: var(--color-text-secondary, #374151);
  margin-bottom: 24px;
}

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

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

.password-input-wrapper {
  display: flex;
  gap: 8px;
}

.password-input-wrapper input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius-md, 8px);
  font-size: 1em;
  font-family: inherit;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #111827);
  transition: border-color 0.15s;
}

.password-input-wrapper input:focus {
  outline: none;
  border-color: var(--color-accent, #7C3AED);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.toggle-password {
  padding: 10px 14px;
  background: var(--color-bg-secondary, #f3f4f6);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  font-size: 0.875em;
  color: var(--color-text-secondary, #4b5563);
  white-space: nowrap;
  min-width: 56px;
  min-height: 44px;
}

.toggle-password:hover {
  background: var(--color-border, #e5e7eb);
}

.form-help {
  display: block;
  margin-top: 6px;
  font-size: 0.8em;
  color: var(--color-text-tertiary, #9ca3af);
}

.btn-primary {
  display: inline-block;
  width: 100%;
  padding: 12px 24px;
  background: var(--color-bg-inverse, #0B1221);
  color: var(--color-text-inverse, #ffffff);
  border: none;
  border-radius: var(--radius-full, 9999px);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  min-height: 44px;
  transition: background 0.15s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md, 8px);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9em;
}

/* ---------- Error Page ---------- */
.error-container {
  text-align: center;
  padding: 80px 0;
}

.error-container h1 {
  font-size: 2em;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--color-text-primary, #111827);
}

.error-container p {
  color: var(--color-text-secondary, #6b7280);
  margin-bottom: 32px;
}

.error-container .btn-primary {
  width: auto;
  display: inline-block;
}

/* ---------- Skip Link (Accessibility) ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 1000;
  padding: 8px 16px;
  background: var(--color-bg-inverse, #0B1221);
  color: var(--color-text-inverse, #fff);
  text-decoration: none;
  border-radius: 0 0 4px 4px;
  font-size: 14px;
}

.skip-link:focus {
  top: 0;
}

/* ---------- Trust Header Override ---------- */
.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
  padding: 4px 12px;
  background: rgba(124, 58, 237, 0.08);
  border-radius: var(--radius-full, 9999px);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-accent, #7C3AED);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ---------- Trust Footer ---------- */
.trust-footer__info {
  text-align: center;
  color: var(--color-text-tertiary, #9ca3af);
  font-size: 0.8em;
}

.trust-footer__info a {
  color: var(--color-text-secondary, #6b7280);
}

.trust-footer__confidentiality {
  margin-top: 4px;
  font-style: italic;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  main {
    padding: 24px 16px;
    padding-top: 100px;
  }

  .document {
    padding: 24px 20px;
    border-radius: 0;
  }

  .document-title {
    font-size: 1.5em;
  }

  .auth-container {
    margin: 24px auto;
    padding: 24px;
  }

  .hero h1 {
    font-size: 1.75em;
  }
}

/* ---------- Print ---------- */
@media print {
  .header, footer, .no-print, button, .skip-link, .toggle-password { display: none !important; }
  body { font-size: 12pt; line-height: 1.5; color: #000; background: #fff; }
  main { padding-top: 0; }
  .document { box-shadow: none; border: none; padding: 0; }
  h1, h2, h3 { page-break-after: avoid; }
  table, figure, .document-content pre { page-break-inside: avoid; }
  a[href]:after { content: " (" attr(href) ")"; font-size: 0.8em; color: #666; }
  p { orphans: 3; widows: 3; }
  @page { margin: 2cm; }
}
