/* ============================================
   Component Styles
   ============================================ */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--navy-700); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn i { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(135deg, var(--navy-700), var(--navy-800));
  color: var(--white);
  box-shadow: 0 1px 3px rgba(30,58,138,0.3), 0 1px 2px rgba(30,58,138,0.2);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--navy-800), var(--navy-900)); box-shadow: 0 2px 6px rgba(30,58,138,0.4); transform: translateY(-1px); }

.btn-accent {
  background: linear-gradient(135deg, var(--amber-600), var(--amber-700));
  color: var(--white);
  box-shadow: 0 1px 3px rgba(180,83,9,0.3);
}
.btn-accent:hover { background: linear-gradient(135deg, var(--amber-700), var(--amber-800)); box-shadow: 0 2px 6px rgba(180,83,9,0.4); transform: translateY(-1px); }

.btn-secondary {
  background: var(--white);
  color: var(--slate-700);
  border-color: var(--slate-300);
}
.btn-secondary:hover { background: var(--slate-50); border-color: var(--slate-400); }

.btn-ghost {
  background: transparent;
  color: var(--slate-600);
}
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-900); }

.btn-danger {
  background: var(--error-600);
  color: var(--white);
}
.btn-danger:hover { background: var(--error-700); }

.btn-sm { height: 36px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }

/* ---- Cards ---- */
.card {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}
.card:hover { box-shadow: var(--shadow-card-hover, var(--shadow-md)); transform: translateY(-1px); }
.card-flat { box-shadow: none; }
.card-flat:hover { box-shadow: none; transform: none; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.card-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--slate-900);
}

/* KPI Card */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--navy-500), var(--navy-700));
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.kpi-card:hover { box-shadow: var(--shadow-card-hover, var(--shadow-md)); transform: translateY(-2px); }
.kpi-card:hover::before { opacity: 1; }

.kpi-label {
  font-size: var(--text-sm);
  color: var(--slate-500);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.kpi-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon.navy { background: var(--navy-100); color: var(--navy-700); }
.kpi-icon.amber { background: var(--amber-100); color: var(--amber-700); }
.kpi-icon.success { background: var(--success-100); color: var(--success-600); }
.kpi-icon.error { background: var(--error-100); color: var(--error-600); }
.kpi-icon.violet { background: var(--violet-100); color: var(--violet-600); }

.kpi-value {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--slate-900);
  line-height: 1.1;
}
.kpi-trend {
  font-size: var(--text-xs);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: var(--space-1);
}
.kpi-trend.up { color: var(--success-600); }
.kpi-trend.down { color: var(--error-600); }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge-navy { background: var(--navy-100); color: var(--navy-800); }
.badge-success { background: var(--success-100); color: var(--success-700); }
.badge-amber { background: var(--amber-100); color: var(--amber-800); }
.badge-error { background: var(--error-100); color: var(--error-700); }
.badge-slate { background: var(--slate-200); color: var(--slate-600); }
.badge-violet { background: var(--violet-100); color: var(--violet-700); }
.badge-outline {
  background: transparent;
  border: 1px dashed var(--slate-300);
  color: var(--slate-500);
}

/* ---- Tables ---- */
.data-table-wrapper {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.data-table thead {
  background: var(--slate-50);
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}
.data-table th:hover { color: var(--slate-900); }
.data-table th.sorted { color: var(--navy-700); }
.data-table th .sort-icon { display: inline-block; margin-left: 4px; }

.data-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--slate-700);
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}
.data-table tbody tr:hover { background: var(--navy-50); }
.data-table tbody tr.selected { background: var(--navy-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .cell-primary {
  font-weight: 600;
  color: var(--slate-900);
}

.data-table .cell-mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--slate-500);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-color);
  font-size: var(--text-sm);
  color: var(--slate-500);
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: var(--space-4);
}
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: var(--space-1);
}
.form-required { color: var(--error-500); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--slate-900);
  background: var(--white);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--navy-500);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
  outline: none;
}
.form-input::placeholder { color: var(--slate-400); }
.form-input.error { border-color: var(--error-500); }
.form-textarea { height: auto; padding: var(--space-3); min-height: 80px; resize: vertical; }
.form-select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

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

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

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
}
.form-checkbox input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--navy-700);
  cursor: pointer;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-modal-backdrop);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease-out;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.2s ease-out;
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 600;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--slate-400); padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--slate-900); }

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

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

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--slate-400);
  font-size: var(--text-sm);
  min-width: 300px;
  animation: slideInRight 0.3s ease-out;
}
.toast-success { border-left-color: var(--success-500); }
.toast-error { border-left-color: var(--error-500); }
.toast-warning { border-left-color: var(--amber-500); }
.toast-info { border-left-color: var(--navy-500); }
.toast-close {
  margin-left: auto; background: none; border: none;
  color: var(--slate-400); cursor: pointer; padding: 2px;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: var(--space-6);
}
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-body);
}
.tab:hover { color: var(--slate-700); }
.tab.active {
  color: var(--navy-800);
  border-bottom-color: var(--navy-700);
}
.tab .tab-count {
  font-size: var(--text-xs);
  background: var(--slate-200);
  color: var(--slate-600);
  padding: 0 6px;
  border-radius: var(--radius-full);
  margin-left: var(--space-2);
}
.tab.active .tab-count {
  background: var(--navy-100);
  color: var(--navy-700);
}

/* ---- Pill Filters ---- */
.pill-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.pill {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 1px solid var(--slate-300);
  background: var(--white);
  color: var(--slate-600);
  transition: all var(--transition-fast);
  font-family: var(--font-body);
}
.pill:hover { border-color: var(--navy-300); }
.pill.active {
  background: var(--navy-800);
  color: var(--white);
  border-color: var(--navy-800);
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--slate-400);
}
.empty-state-icon {
  width: 64px; height: 64px;
  margin: 0 auto var(--space-4);
  color: var(--slate-300);
}
.empty-state h3 {
  font-family: var(--font-heading);
  color: var(--slate-600);
  margin-bottom: var(--space-2);
}
.empty-state p {
  font-size: var(--text-sm);
  color: var(--slate-400);
  margin-bottom: var(--space-4);
}

/* ---- Avatar ---- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  font-weight: 600; color: var(--white);
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-md { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }

/* ---- Dropdown ---- */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  padding: var(--space-1);
  animation: fadeIn 0.15s ease-out;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--slate-700);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.dropdown-item:hover { background: var(--slate-100); }
.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-1) 0;
}

/* ---- Skeleton Loading ---- */
.skeleton {
  background: linear-gradient(90deg, var(--slate-200) 25%, var(--slate-100) 50%, var(--slate-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: var(--space-8); }
.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--slate-200);
}
.timeline-item {
  position: relative;
  padding-bottom: var(--space-4);
}
.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-8) + 10px);
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--navy-500);
  border: 2px solid var(--white);
}
.timeline-time {
  font-size: var(--text-xs);
  color: var(--slate-400);
  margin-bottom: 2px;
}
.timeline-text {
  font-size: var(--text-sm);
  color: var(--slate-700);
}

/* ---- Progress Bar ---- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--slate-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--navy-600);
  transition: width var(--transition-slow);
}
