/* ==========================================================================
   Shared Components — Buttons, Cards, Badges, Forms, Modals, Progress, etc.
   ========================================================================== */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--neutral-800);
  font-size: var(--text-sm);
  font-family: var(--font-family);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  line-height: var(--leading-normal);
}
.btn:hover { background: var(--neutral-100); border-color: var(--neutral-400); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

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

.btn-secondary {
  background: var(--neutral-700);
  color: #fff;
  border-color: var(--neutral-700);
}
.btn-secondary:hover:not(:disabled) { background: var(--neutral-800); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary-bg); }

.btn-danger {
  color: var(--error);
  border-color: transparent;
  background: none;
  padding: 0 var(--space-1);
  font-size: var(--text-md);
}
.btn-danger:hover:not(:disabled) { color: var(--primary-hover); background: var(--error-light); }

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

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
  border-radius: var(--radius-md);
}

/* --- Cards --- */
.card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-lg); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.card-body {
  color: var(--neutral-700);
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: 1.5;
}

.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: #795548; }
.badge-error    { background: var(--error-light);   color: var(--error); }
.badge-info     { background: var(--info-light);    color: var(--info); }
.badge-neutral  { background: var(--neutral-200);   color: var(--neutral-700); }

/* Status badge (pill style for cases) */
.status-badge {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}
.status-documents_pending  { background: var(--warning-light); color: #795548; }
.status-documents_complete { background: var(--success-light); color: var(--success); }
.status-under_review       { background: var(--info-light);    color: var(--info); }
.status-created            { background: var(--neutral-200);   color: var(--neutral-700); }

/* --- Forms --- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--neutral-700);
  margin-bottom: var(--space-1);
}

.form-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast);
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-bg); }

/* --- Modals --- */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.visible { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  width: 90%;
  max-width: 400px;
  position: relative;
}

.modal h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
  color: var(--neutral-900);
  font-size: 1.3rem;
}

.modal .close-btn {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--neutral-500);
  line-height: 1;
}
.modal .close-btn:hover { color: var(--neutral-900); }

.modal label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  margin-bottom: var(--space-1);
  color: var(--neutral-700);
}

.modal input[type="email"],
.modal input[type="password"] {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  margin-bottom: var(--space-3);
  outline: none;
  font-family: var(--font-family);
}
.modal input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-bg); }

.modal .modal-submit {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--text-md);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: background var(--transition-base);
  font-family: var(--font-family);
}
.modal .modal-submit:hover { background: var(--primary-hover); }
.modal .modal-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.modal .modal-error {
  background: var(--error-light);
  color: var(--error);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
  display: none;
}

.modal .modal-success {
  background: var(--success-light);
  color: var(--success);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
  display: none;
}

.modal .modal-link {
  text-align: center;
  font-size: var(--text-sm);
  margin-top: var(--space-3);
}
.modal .modal-link a { color: var(--primary); cursor: pointer; }
.modal .modal-link a:hover { text-decoration: underline; }

/* --- Progress Bars --- */
.progress-bar {
  height: 8px;
  background: var(--neutral-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: var(--space-2) 0;
}

.progress-bar-lg {
  height: 12px;
  border-radius: var(--radius-md);
}

.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: var(--text-sm);
  color: var(--neutral-600);
}

/* --- Summary Bar --- */
.summary-bar {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.summary-item {
  background: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  text-align: center;
  flex: 1;
  min-width: 100px;
}

.summary-number {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
}
.summary-number.green  { color: var(--success); }
.summary-number.red    { color: var(--error); }
.summary-number.yellow { color: var(--warning); }

.summary-label {
  font-size: var(--text-xs);
  color: var(--neutral-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Status Icons (checklist) --- */
.status-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.status-linked  { background: var(--success-light); color: var(--success); }
.status-required { background: var(--error-light);  color: var(--error); }
.status-warning  { background: var(--warning-light); color: #795548; }

/* --- Validation Messages --- */
.validation-msg {
  font-size: var(--text-xs);
  margin-top: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}
.validation-warning { background: var(--warning-light); color: #795548; }
.validation-error   { background: var(--error-light);   color: var(--error); }
.validation-valid   { background: var(--success-light); color: var(--success); }

/* --- Document Panel (chat sidebar) --- */
.doc-panel {
  width: 240px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  max-height: 60vh;
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.doc-panel h3 {
  font-size: var(--text-sm);
  color: var(--primary);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.doc-panel .doc-item {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
}
.doc-item .doc-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-item .doc-badge {
  display: inline-block;
  font-size: var(--text-xs);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-top: var(--space-1);
  font-weight: var(--font-semibold);
}
.doc-badge.processing { background: var(--warning-light); color: #795548; }
.doc-badge.classified { background: var(--success-light); color: var(--success); }
.doc-badge.failed     { background: var(--error-light);   color: var(--error); }
.doc-panel .no-docs {
  font-size: var(--text-sm);
  color: var(--neutral-500);
  font-style: italic;
}

/* --- Upload Elements --- */
.upload-input { display: none; }

.upload-progress {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--primary);
}
.upload-progress .file-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}
.upload-progress .spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--neutral-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Drop Overlay --- */
.drop-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(183, 28, 28, 0.08);
  border: 3px dashed var(--primary);
  border-radius: var(--radius-lg);
  z-index: 10;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: var(--font-semibold);
  pointer-events: none;
}
.drop-overlay.visible { display: flex; }

/* --- Linked Documents (checklist) --- */
.linked-docs { margin-top: var(--space-2); }
.linked-doc {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
}
.linked-doc a { color: var(--primary); }

.unlink-btn {
  color: var(--error);
  cursor: pointer;
  border: none;
  background: none;
  font-size: var(--text-md);
  padding: 0 var(--space-1);
}
.unlink-btn:hover { color: var(--primary-hover); }

/* --- Item Content (checklist) --- */
.item-content { flex: 1; }
.item-name { font-weight: var(--font-semibold); font-size: var(--text-base); }
.item-notes { font-size: var(--text-sm); color: var(--neutral-600); margin-top: var(--space-1); }
.item-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  margin-left: var(--space-2);
}
.badge-mandatory   { background: var(--neutral-200);   color: var(--neutral-700); }
.badge-optional    { background: var(--warning-light); color: #795548; }
.badge-translation { background: var(--info-light);    color: var(--info); }

.badge-auto-matched { background: var(--success-light); color: var(--success); }

.item-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* --- Drop Zone (checklist) --- */
.drop-zone {
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-5);
  text-align: center;
  margin-bottom: var(--space-5);
  background: var(--primary-bg);
  transition: background var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}
.drop-zone.drag-over {
  background: #FFCDD2;
  border-color: var(--primary-hover);
}
.drop-zone-icon { font-size: 2.25rem; margin-bottom: var(--space-2); color: var(--primary); }
.drop-zone-text { font-size: var(--text-base); color: var(--neutral-600); margin-bottom: var(--space-3); }
.drop-zone-hint { font-size: var(--text-xs); color: var(--neutral-500); }
.drop-zone-actions { display: flex; gap: var(--space-3); justify-content: center; margin-top: var(--space-3); }

/* --- Upload Progress List (checklist) --- */
.upload-progress-list { margin-bottom: var(--space-5); }
.upload-progress-item {
  background: #fff;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-2);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.upload-file-name { flex: 1; font-size: var(--text-sm); font-weight: var(--font-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-size { font-size: var(--text-xs); color: var(--neutral-500); flex-shrink: 0; }
.upload-status-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  flex-shrink: 0;
}
.badge-uploading  { background: var(--info-light);    color: var(--info); }
.badge-done       { background: var(--success-light); color: var(--success); }
.badge-error      { background: var(--error-light);   color: var(--error); }

/* --- Unassociated Documents (checklist) --- */
.unassociated-section {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}
.unassociated-header {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: #795548;
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.unassociated-count {
  background: var(--warning);
  color: var(--neutral-900);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
}
.unassociated-doc {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.unassociated-doc-info { flex: 1; min-width: 150px; }
.unassociated-doc-name { font-weight: var(--font-medium); font-size: var(--text-sm); }
.unassociated-doc-meta { font-size: var(--text-xs); color: var(--neutral-600); }

.reassign-select {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--neutral-300);
  font-size: var(--text-sm);
  min-width: 200px;
  font-family: var(--font-family);
}
.reassign-btn {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--success);
  background: var(--success);
  color: #fff;
  font-size: var(--text-xs);
  cursor: pointer;
  font-family: var(--font-family);
}
.reassign-btn:hover { background: #1B5E20; }

.delete-btn {
  padding: var(--space-1) 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--error);
  background: none;
  color: var(--error);
  font-size: var(--text-base);
  cursor: pointer;
  line-height: 1;
}
.delete-btn:hover { background: var(--error); color: #fff; }

/* --- Toast Notification --- */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--success);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* --- Action Panel --- */
.action-panel {
  background: var(--neutral-50);
  border: 2px solid var(--neutral-300);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}
.action-panel-header {
  margin-bottom: var(--space-4);
}
.action-panel-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--success);
}
.action-panel-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.action-btn {
  flex: 1;
  min-width: 200px;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.action-btn-help {
  font-size: var(--text-sm);
  color: var(--neutral-600);
  margin: 0 0 var(--space-3) 0;
  flex-basis: 100%;
}
.btn-secondary {
  background: var(--neutral-200);
  color: var(--neutral-900);
  border: 1px solid var(--neutral-400);
}
.btn-secondary:hover { background: var(--neutral-300); }
.btn-outline {
  background: transparent;
  color: var(--neutral-700);
  border: 1px solid var(--neutral-400);
}
.btn-outline:hover:not(:disabled) { background: var(--neutral-100); }
.action-panel-consultation {
  border-top: 1px solid var(--neutral-300);
  padding-top: var(--space-4);
}
@media (max-width: 600px) {
  .action-panel-buttons { flex-direction: column; }
  .action-btn { min-width: 100%; }
}

/* --- Form Generation Progress --- */
.form-progress-section {
  background: var(--neutral-50);
  border: 2px solid var(--neutral-300);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}
.form-progress-header { margin-bottom: var(--space-4); }
.form-progress-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--neutral-900);
  margin-bottom: var(--space-3);
}
.form-progress-list { display: flex; flex-direction: column; gap: var(--space-2); }
.form-progress-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--neutral-200);
}
.form-type-label { font-weight: var(--font-medium); }
.form-status-badge {
  font-size: var(--text-sm);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.form-status-pending   { background: var(--neutral-200); color: var(--neutral-600); }
.form-status-processing { background: var(--info-light); color: var(--info); }
.form-status-completed  { background: var(--success-light); color: var(--success); }
.form-status-failed     { background: var(--error-light); color: var(--error); }
.form-download-area { margin-top: var(--space-4); text-align: center; }
.form-error-area { margin-top: var(--space-4); }
.form-error-message {
  color: var(--error);
  font-weight: var(--font-medium);
  margin-bottom: var(--space-3);
}
