/* Ground Force Land — Reusable Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

.btn-icon {
  padding: 6px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-text); }

/* Forms */
.form-group {
  margin-bottom: var(--space-md);
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-error {
  color: var(--color-danger);
  font-size: 13px;
  margin-top: var(--space-xs);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2, .card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: var(--space-lg);
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.stat-card .stat-label {
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: var(--space-xs);
}
.stat-card .stat-sub {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 2px;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-researched { background: var(--badge-bg-researched, #f1f5f9); color: var(--badge-text-researched, #475569); }
.badge-contact_made { background: var(--badge-bg-contact_made, #fef3c7); color: var(--badge-text-contact_made, #92400e); }
.badge-in_negotiation { background: var(--badge-bg-in_negotiation, #ffedd5); color: var(--badge-text-in_negotiation, #9a3412); }
.badge-signed { background: var(--badge-bg-signed, #dcfce7); color: var(--badge-text-signed, #166534); }

.badge-to_do { background: var(--badge-bg-to_do, #f1f5f9); color: var(--badge-text-to_do, #475569); }
.badge-in_progress { background: var(--badge-bg-in_progress, #dbeafe); color: var(--badge-text-in_progress, #1e40af); }
.badge-done { background: var(--badge-bg-done, #dcfce7); color: var(--badge-text-done, #166534); }

.badge-payment-pending { background: #fef3c7; color: #92400e; }
.badge-payment-completed { background: #dcfce7; color: #166534; }
.badge-payment-void { background: #fee2e2; color: #991b1b; }

/* Tables */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th:hover { background: var(--color-border); }
th .sort-icon { margin-left: 4px; opacity: 0.5; }
th.sorted .sort-icon { opacity: 1; }

td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* Checkbox in table */
.row-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Inline editing in tables */
.inline-edit,
.inline-select {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-text);
  background: transparent;
  transition: border-color 0.15s, background 0.15s;
}
.inline-edit:hover,
.inline-select:hover {
  border-color: var(--color-border);
  background: var(--color-surface);
}
.inline-edit:focus,
.inline-select:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.inline-edit::placeholder {
  color: var(--color-text-light);
}
.inline-edit.saving,
.inline-select.saving {
  opacity: 0.6;
}

.cell-with-link {
  position: relative;
}
.cell-with-link .inline-edit {
  padding-right: 22px;
}
.detail-link {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--color-text-light);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.cell-with-link:hover .detail-link,
.detail-link:focus {
  opacity: 1;
  color: var(--color-primary);
}

/* Flash feedback for inline save */
@keyframes flashSuccess {
  0% { background: #dcfce7; }
  100% { background: transparent; }
}
@keyframes flashError {
  0% { background: #fee2e2; }
  100% { background: transparent; }
}
td.flash-success { animation: flashSuccess 0.8s ease-out; }
td.flash-error { animation: flashError 0.8s ease-out; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
}
.pagination-buttons {
  display: flex;
  gap: var(--space-sm);
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 160px;
}

.search-input {
  position: relative;
}
.search-input input {
  padding-left: 32px;
}
.search-input::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: fadeIn 0.2s;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 18px; }
.modal-body { padding: var(--space-lg); }
.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Upload drop zone */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* Activity timeline */
.activity-list {
  list-style: none;
}
.activity-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-content {
  flex: 1;
}
.activity-description {
  font-size: 13px;
}
.activity-time {
  font-size: 12px;
  color: var(--color-text-light);
}

/* Project selector */
.project-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.project-selector select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}

/* ===== Workflow Management Page ===== */

.workflow-card {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}
.workflow-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
.workflow-card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.workflow-card-body {
  padding: var(--space-md);
}

.workflow-step-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.workflow-step-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border-light, #f1f5f9);
}
.workflow-step-item:last-child {
  border-bottom: none;
}
.workflow-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary-light, #eff6ff);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.workflow-step-name {
  font-size: 14px;
}

/* Workflow step editor (modal) */
.workflow-steps-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.workflow-step-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.workflow-step-row .form-input {
  flex: 1;
}
.workflow-step-drag {
  cursor: grab;
  color: var(--color-text-muted, #94a3b8);
  font-size: 18px;
  user-select: none;
}
.step-actions {
  display: flex;
  gap: 2px;
}
.step-actions button {
  padding: 4px 8px;
  font-size: 12px;
  min-width: unset;
}

/* Workflow inline select in line list */
.inline-workflow {
  min-width: 120px;
}
