/* StudioCRM Document Portal — Responsive styles */

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

:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-secondary: #666666;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-border: #e5e7eb;
  --color-border-focus: #2563eb;
  --color-required: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --max-width: 720px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header / Studio branding */
.header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  text-align: center;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.header .client-name {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
}

/* Main container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-secondary);
}

.loading-spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

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

/* Content blocks */
.content-block {
  margin-bottom: 1.25rem;
}

.content-block h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.content-block p {
  margin-bottom: 0.5rem;
}

/* Form elements */
.field-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.375rem;
  font-size: 0.9375rem;
}

.required-badge {
  color: var(--color-required);
  font-weight: 700;
}

.form-input,
.form-select {
  display: block;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.form-checkbox {
  margin-top: 0.25rem;
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

/* Radio buttons */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
}

.radio-label input[type="radio"] {
  accent-color: var(--color-primary);
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

/* Terms section */
.terms-section {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Page break */
.page-break {
  border: none;
  border-top: 2px dashed var(--color-border);
  margin: 2rem 0;
}

/* Field error highlight */
.field-error {
  border-left: 3px solid var(--color-error);
  padding-left: 0.75rem;
}

.field-error .form-input,
.field-error .form-select {
  border-color: var(--color-error);
}

/* Signature pad */
.signature-container {
  margin-top: 0.5rem;
}

.signature-consent {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  font-style: italic;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.signature-canvas-wrapper {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  position: relative;
  height: 200px;
  overflow: hidden;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.signature-hint {
  position: absolute;
  bottom: 0.5rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  pointer-events: none;
}

.signature-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.signature-completed {
  margin-top: 0.5rem;
}

.signature-svg-display {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 0.5rem;
  max-height: 200px;
  overflow: hidden;
}

.signature-svg-display svg {
  max-width: 100%;
  height: auto;
}

.signature-status {
  font-size: 0.8125rem;
  color: var(--color-success);
  margin-top: 0.375rem;
}

.countersign-notice {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  font-style: italic;
  padding: 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  line-height: 1.5;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
}

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

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
}

/* Form actions */
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

/* Messages */
.message {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9375rem;
}

.message--error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid #fecaca;
}

.message--success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

/* Completion banner */
.completion-banner {
  text-align: center;
}

.completion-text {
  margin-bottom: 1rem;
  font-size: 1.0625rem;
}

.completion-banner .btn {
  margin-top: 0.5rem;
}

/* Error page */
.error-page {
  text-align: center;
  padding: 3rem 1rem;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.error-message {
  font-size: 1.0625rem;
  color: var(--color-text-secondary);
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Responsive */
@media (min-width: 640px) {
  .container {
    padding: 2rem 1.5rem;
  }

  .form-actions {
    justify-content: flex-end;
  }

  .signature-canvas-wrapper {
    height: 250px;
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 2.5rem 2rem;
  }
}

/* Print */
@media print {
  .form-actions,
  .signature-actions,
  .btn {
    display: none;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }
}
