/* ============================================
   Voice2Contract — Shared Styles
   ============================================ */

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

:root {
  --primary: #1a56db;
  --primary-hover: #1649c0;
  --primary-light: #ebf0ff;
  --secondary: #6b7280;
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a:hover {
  text-decoration: underline;
}

/* --- Layout --- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  flex: 1;
  padding: 2rem 0;
}

/* --- Header --- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.025em;
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

nav a:hover,
nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  text-decoration: none;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--text-secondary);
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 1.25rem;
}

.collapsible {
  cursor: pointer;
  user-select: none;
}

.collapsible:hover {
  background: #f3f4f6;
}

.toggle-icon {
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

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

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

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

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

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-danger:hover {
  background: var(--danger-light);
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
}

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

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

/* --- Drop Zone --- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin: 1.25rem;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-icon {
  width: 48px;
  height: 48px;
  color: var(--text-secondary);
  margin: 0 auto 0.75rem;
  display: block;
}

.drop-zone p {
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* --- File List --- */
.file-list {
  margin: 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.file-item:last-child {
  border-bottom: none;
}

.file-icon {
  margin-right: 0.5rem;
}

.file-name {
  flex: 1;
  font-weight: 500;
}

.file-size {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.file-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  font-size: 1rem;
  line-height: 1;
}

.file-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.upload-actions {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: flex-end;
}

/* --- Status Section --- */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

#status-text {
  display: flex;
  flex-direction: column;
}

.session-id {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: monospace;
}

/* --- Progress Steps --- */
.progress-steps {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  opacity: 0.35;
  transition: opacity 0.3s;
}

.step.active,
.step.done {
  opacity: 1;
}

.step-icon {
  font-size: 1.25rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
}

.step.active .step-icon {
  border-color: var(--primary);
  background: var(--primary-light);
}

.step.done .step-icon {
  border-color: var(--success);
  background: var(--success-light);
}

.step-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 20px;
  margin-bottom: 1.25rem;
}

/* --- Email field --- */
.email-field {
  padding: 1.25rem 1.25rem 0;
}

.email-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.email-field input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}

.email-field input[type="email"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

/* --- Banners --- */
.banner {
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
}

.banner-success {
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* --- Messages --- */
.success-message {
  background: var(--success-light);
  color: #065f46;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
}

.error-message {
  background: var(--danger-light);
  color: #7f1d1d;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin: 0 1.25rem 1rem;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--bg);
  padding: 0.625rem 0.875rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

tbody tr:hover {
  background: var(--bg);
}

.num-col {
  text-align: right !important;
  width: 110px;
}

.num-col input {
  text-align: right;
}

.conf-col {
  width: 90px;
}

.action-col {
  width: 130px;
  text-align: center !important;
}

.loading-cell {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem !important;
}

.table-footer {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}

/* --- Editable Inputs --- */
.editable-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  background: transparent;
  transition: border-color 0.15s, background 0.15s;
}

.editable-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}

/* --- Confidence Badge --- */
.confidence-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.confidence-high {
  background: var(--success-light);
  color: #065f46;
}

.confidence-med {
  background: var(--warning-light);
  color: #78350f;
}

.confidence-low {
  background: var(--danger-light);
  color: #7f1d1d;
}

/* --- Totals Table --- */
.totals-section {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.totals-table {
  width: auto;
  min-width: 280px;
}

.totals-table td {
  padding: 0.375rem 0.5rem !important;
  border-bottom: none !important;
}

.totals-table td:first-child {
  color: var(--text-secondary);
  padding-right: 2rem !important;
}

.totals-table td:last-child {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.totals-table tr.total-row td {
  font-weight: 700;
  font-size: 1rem;
  border-top: 2px solid var(--border) !important;
  padding-top: 0.5rem !important;
}

/* --- Actions Card --- */
.actions-card .form-actions {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- PDF Ready --- */
.pdf-ready {
  padding: 2.5rem;
  text-align: center;
}

.success-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.pdf-ready h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.pdf-ready p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.pdf-ready .btn {
  margin: 0 0.5rem;
}

/* --- Transcription --- */
.transcription-text {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 4px;
}

/* --- Forms --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.form-group-wide {
  flex: 2;
  min-width: 200px;
}

.form-group-btn {
  align-self: flex-end;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.15s;
  min-width: 100px;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* --- Search --- */
.search-box {
  display: flex;
  align-items: center;
}

.search-input {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  width: 200px;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 480px;
  z-index: 1;
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--bg);
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* --- Footer --- */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: auto;
}

/* --- Utilities --- */
.hidden {
  display: none !important;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .progress-steps {
    justify-content: center;
  }

  .step-connector {
    display: none;
  }

  .form-row {
    flex-direction: column;
  }

  nav {
    gap: 1rem;
  }

  .actions-card .form-actions {
    flex-direction: column-reverse;
  }

  .actions-card .form-actions .btn {
    width: 100%;
    justify-content: center;
  }
}
