/* ============================================================
   Pengadaan Tender — Components CSS
   Cards, Tables, Forms, Modals, Alerts, Tabs, Pagination, Dropdown
   ============================================================ */

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

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card-header h3,
.card-header h4,
.card-header h5 {
  margin-bottom: 0;
  font-size: var(--text-base);
  font-weight: 600;
}

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

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

.card-stat {
  padding: var(--space-6);
}

.card-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.card-stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.card-stat-icon.green { background: var(--success-light); color: var(--success); }
.card-stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.card-stat-icon.red { background: var(--danger-light); color: var(--danger); }

.card-stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--fg-heading);
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.card-stat-label {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

/* ─── 2. Tables ─── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--surface);
}

.table thead th {
  background: var(--surface-muted);
  color: var(--fg-heading);
  font-weight: 600;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--fg);
}

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

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table .actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.table .actions .btn-sm {
  min-height: 32px;
  padding: var(--space-1) var(--space-2);
}

.table-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--fg-muted);
}

.table-empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  color: var(--border);
}

/* ─── 3. Forms ─── */
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-heading);
  margin-bottom: var(--space-2);
}

.form-label .required::after {
  content: ' *';
  color: var(--danger);
}

.form-control,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-primary);
  font-size: var(--text-base); /* 16px = prevent iOS zoom */
  line-height: 1.5;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-height: 40px;
}

.form-control::placeholder,
.form-textarea::placeholder {
  color: var(--fg-placeholder);
}

.form-control:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(229, 112, 53, 0.12);
}

.form-control:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--surface-muted);
  color: var(--fg-muted);
  cursor: not-allowed;
}

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

.form-select {
  appearance: none;
  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='%238C8C8C' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  margin-top: var(--space-1);
}

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

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

.form-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 200px;
}

/* File input styling */
.form-file {
  position: relative;
}

.form-file input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.form-file-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  min-height: 40px;
  transition: border-color var(--transition-fast);
}

.form-file:hover .form-file-label {
  border-color: var(--primary);
  color: var(--primary);
}

/* File input — error state */
.form-file.has-error .form-file-label {
  border-color: var(--danger);
  background: var(--danger-light);
  color: var(--danger);
}

/* File status badge (Sudah diisi / Belum diisi) */
.file-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  margin-left: var(--space-2);
  vertical-align: middle;
}
.file-status-ok {
  color: var(--success);
  background: var(--success-light);
  border: 1px solid var(--alert-success-border);
}
.file-status-empty {
  color: var(--danger);
  background: var(--danger-light);
  border: 1px solid var(--alert-danger-border);
}

/* File preview (existing + instan untuk file baru) */
.file-preview {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.file-preview-thumb {
  max-width: 180px;
  max-height: 120px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.file-preview-pdf {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--fg-heading);
  max-width: 100%;
}
.file-preview-pdf span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 4. Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - var(--space-8));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--surface-hover);
  color: var(--fg-heading);
}

/* Modal sizes */
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

/* ─── 5. Alert ─── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.alert-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
}

.alert-primary {
  background: var(--primary-light);
  color: var(--primary-active);
  border: 1px solid var(--alert-primary-border);
}

.alert-success {
  background: var(--success-light);
  color: var(--alert-success-text);
  border: 1px solid var(--alert-success-border);
}

.alert-warning {
  background: var(--warning-light);
  color: var(--alert-warning-text);
  border: 1px solid var(--alert-warning-border);
}

.alert-danger {
  background: var(--danger-light);
  color: var(--alert-danger-text);
  border: 1px solid var(--alert-danger-border);
}

.alert-info {
  background: var(--info-light);
  color: var(--primary-active);
  border: 1px solid var(--alert-primary-border);
}

/* ─── 6. Tabs ─── */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: var(--space-6);
}

.tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  min-height: 40px;
}

.tab:hover {
  color: var(--fg-heading);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ─── 7. Pagination ─── */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .active span,
.pagination .active a {
  background: var(--primary);
  color: var(--fg-inverse);
  border-color: var(--primary);
}

.pagination .disabled span,
.pagination .disabled a {
  color: var(--fg-placeholder);
  cursor: not-allowed;
  background: var(--surface-muted);
}

/* ─── 8. Dropdown ─── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 1040;
  display: none;
  overflow: hidden;
}

.dropdown-menu.show {
  display: block;
  animation: dropdownIn 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg);
  text-decoration: none;
  transition: background var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--surface-hover);
}

.dropdown-item.active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 500;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-1) 0;
}

/* ─── 9. Avatar ─── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }

/* ─── 10. Empty State ─── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-4);
  color: var(--border);
}

.empty-state h3 {
  font-size: var(--text-lg);
  color: var(--fg-heading);
  margin-bottom: var(--space-2);
}

.empty-state p {
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
}

/* ─── 11. Step / Wizard ─── */
.steps {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  padding-bottom: var(--space-2);
}

.step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-muted);
  white-space: nowrap;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 600;
}

.step.active {
  color: var(--primary);
}

.step.active .step-number {
  background: var(--primary);
  color: var(--fg-inverse);
}

.step.completed {
  color: var(--success);
}

.step.completed .step-number {
  background: var(--success);
  color: var(--fg-inverse);
}

.step-divider {
  width: 24px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── 12. Responsive Utilities ─── */
@media (max-width: 767.98px) {
  .form-row {
    flex-direction: column;
  }
  .form-row .form-group {
    min-width: 100%;
  }
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .table-wrap {
    border-radius: var(--radius);
  }
  .modal {
    margin: var(--space-4);
    max-height: calc(100vh - var(--space-8));
  }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .page-container {
    padding: var(--space-4);
  }
  .card-body {
    padding: var(--space-4);
  }
  .card-header,
  .card-footer {
    padding: var(--space-3) var(--space-4);
  }
}
