/**
 * Sand & Sea — Forms & detail views (Milestone 0B Task 5)
 */

.ss-detail-page,
.ss-form-page {
  display: flex;
  flex-direction: column;
  gap: var(--ss-page-gap, var(--ss-space-5));
  width: 100%;
  min-width: 0;
}

.ss-detail-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ss-space-4);
  padding: var(--ss-space-5);
  background: linear-gradient(135deg, var(--ss-bg-surface) 0%, var(--ss-primary-50) 100%);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-lg);
  box-shadow: var(--ss-shadow-sm);
}

.ss-detail-hero-title {
  font-family: var(--ss-font-brand);
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  color: var(--ss-text-primary);
}

.ss-detail-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  font-size: var(--ss-text-label);
  color: var(--ss-text-secondary);
}

.ss-detail-hero-meta .ss-ref {
  font-weight: 600;
}

.ss-detail-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ss-space-3);
}

.ss-detail-fact {
  background: var(--ss-bg-surface);
  border: 1px solid var(--ss-border-subtle);
  border-radius: var(--ss-radius-md);
  padding: 12px 14px;
  box-shadow: var(--ss-shadow-xs);
}

.ss-detail-fact-label {
  font-size: var(--ss-text-meta);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ss-text-muted);
  margin-bottom: var(--ss-space-1);
}

.ss-detail-fact-value {
  font-size: var(--ss-text-label);
  font-weight: 600;
  color: var(--ss-text-primary);
}

.ss-dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
  margin: 0;
}

.ss-dl dt {
  margin: 0;
  font-size: var(--ss-text-meta);
  font-weight: 600;
  color: var(--ss-text-muted);
  padding-top: 2px;
}

.ss-dl dd {
  margin: 0;
  font-size: var(--ss-text-body);
  color: var(--ss-text-primary);
  font-weight: 500;
}

.ss-form-section {
  background: var(--ss-bg-surface);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-lg);
  box-shadow: var(--ss-shadow-sm);
  overflow: hidden;
}

.ss-form-section-header {
  padding: 14px var(--ss-space-5);
  border-bottom: 1px solid var(--ss-border-subtle);
  background: linear-gradient(180deg, var(--ss-bg-surface) 0%, var(--ss-bg-toolbar) 100%);
}

.ss-form-section-title {
  margin: 0;
  font-size: var(--ss-text-body);
  font-weight: 700;
  color: var(--ss-text-primary);
}

.ss-form-section-desc {
  margin: 4px 0 0;
  font-size: var(--ss-text-meta);
  color: var(--ss-text-muted);
}

.ss-form-section-body {
  padding: var(--ss-space-5);
}

.ss-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: var(--ss-space-3);
  justify-content: flex-end;
  align-items: center;
  padding: var(--ss-space-3) var(--ss-space-5);
  background: color-mix(in srgb, var(--ss-bg-surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-lg);
  box-shadow: var(--ss-shadow-md);
}

[data-bs-theme="dark"] .ss-form-actions {
  background: color-mix(in srgb, var(--ss-bg-surface) 94%, transparent);
}

.ss-side-panel {
  display: flex;
  flex-direction: column;
  gap: var(--ss-card-gap, var(--ss-space-4));
}

.ss-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-md);
  background: var(--ss-bg-toolbar);
}

.ss-attachment-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--ss-radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ss-primary-50);
  color: var(--ss-primary-700);
  flex-shrink: 0;
}

.ss-attachment-name {
  font-weight: 600;
  font-size: 13px;
  margin: 0;
}

.ss-attachment-meta {
  font-size: 12px;
  color: var(--ss-text-muted);
  margin: 0;
}

.ss-file-drop {
  border: 1.5px dashed var(--ss-border-strong);
  border-radius: var(--ss-radius-md);
  padding: 20px;
  text-align: center;
  background: var(--ss-bg-toolbar);
  transition: border-color var(--ss-fast) var(--ss-ease), background var(--ss-fast) var(--ss-ease);
}

.ss-file-drop:hover {
  border-color: var(--ss-primary-400);
  background: var(--ss-primary-50);
}

.ss-file-drop .ss-input {
  margin-top: 10px;
  box-shadow: none;
}

.ss-doc-preview {
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-md);
  overflow: hidden;
  background: var(--ss-bg-surface-muted);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ss-text-secondary);
  padding: 24px;
}

.ss-doc-preview i {
  font-size: 2rem;
  color: var(--ss-primary-500);
}

.ss-perm-group {
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--ss-bg-surface);
}

.ss-perm-group-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ss-text-muted);
  margin-bottom: 10px;
}

.ss-invoice-sheet {
  background: var(--ss-bg-surface);
  border: 1px solid var(--ss-border-default);
  border-radius: var(--ss-radius-lg);
  box-shadow: var(--ss-shadow-sm);
  padding: var(--ss-space-6);
}

.ss-invoice-sheet-header {
  display: flex;
  justify-content: space-between;
  gap: var(--ss-space-4);
  padding-bottom: var(--ss-space-4);
  margin-bottom: var(--ss-space-4);
  border-bottom: 1px solid var(--ss-border-subtle);
}

@media (max-width: 991.98px) {
  .ss-detail-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .ss-detail-facts {
    grid-template-columns: 1fr;
  }

  .ss-dl {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .ss-dl dt {
    padding-top: 8px;
  }

  .ss-form-actions {
    justify-content: stretch;
  }

  .ss-form-actions .ss-btn {
    flex: 1 1 auto;
  }
}

@media print {
  .ss-form-actions,
  .ss-demo-banner,
  .ss-sidebar,
  .ss-header {
    display: none !important;
  }

  .ss-invoice-sheet {
    box-shadow: none;
    border: 0;
  }
}

.ss-code-block {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.55;
  background: var(--ss-bg-muted);
  border: 1px solid var(--ss-border-subtle);
  border-radius: var(--ss-radius-md);
  padding: 14px 16px;
  overflow: auto;
  color: var(--ss-text-primary);
  margin: 0;
}

.ss-danger-zone {
  border: 1px solid rgba(185, 28, 28, 0.28);
  border-radius: var(--ss-radius-lg, 12px);
  padding: 16px;
  background: rgba(185, 28, 28, 0.04);
}

.ss-inclusion-list {
  padding-left: 1.1rem;
  color: var(--ss-text-secondary);
}

.ss-inclusion-list li + li {
  margin-top: 6px;
}

.ss-auth-title {
  font-family: var(--ss-font-brand);
  font-size: var(--ss-text-section);
  font-weight: 700;
  color: var(--ss-text-primary);
  margin-bottom: var(--ss-space-1);
}

.ss-auth-subtitle {
  color: var(--ss-text-secondary);
  margin-bottom: var(--ss-space-6);
  font-size: var(--ss-text-body);
}

.ss-auth-form .ss-field + .ss-field {
  margin-top: var(--ss-field-gap, var(--ss-space-4));
}

.ss-auth-link {
  font-size: var(--ss-text-label);
  color: var(--ss-text-link);
  text-decoration: none;
  font-weight: 600;
}

.ss-auth-link:hover {
  color: var(--ss-primary-700);
  text-decoration: underline;
}
