/* ============================================
   COMPONENTS — Buttons, Badges, Cards, Avatars,
   Forms, Modals, Tables, Tabs, Callouts
   ============================================ */

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
}

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

.btn--ghost {
  background: transparent;
  border-color: var(--border-mid);
  color: var(--text-secondary);
}
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn--success {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}
.btn--success:hover { background: var(--success); color: var(--white); }

.btn--error {
  background: var(--error-light);
  border-color: var(--error);
  color: var(--error);
}
.btn--error:hover { background: var(--error); color: var(--white); }

.btn--sm {
  padding: 4px 12px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn--full { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--surface); color: var(--navy); }

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1.5px solid;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
}
.btn-icon--success { border-color: var(--success); color: var(--success); }
.btn-icon--success:hover { background: var(--success); color: white; }
.btn-icon--error { border-color: var(--error); color: var(--error); }
.btn-icon--error:hover { background: var(--error); color: white; }

/* ---- BADGES ---- */
.badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  white-space: nowrap;
}

.badge-pill--warning { background: var(--warning-light); color: var(--warning); }
.badge-pill--success { background: var(--success-light); color: var(--success); }
.badge-pill--error   { background: var(--error-light);   color: var(--error); }
.badge-pill--info    { background: var(--info-light);    color: var(--info); }

/* ---- CHIPS ---- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--surface-mid);
  color: var(--text-secondary);
}

/* ---- AVATARS ---- */
.avatar {
  border-radius: 50%;
  background: var(--navy-mid);
  color: var(--white);
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}
.avatar--xs { width: 28px; height: 28px; font-size: 10px; }
.avatar--sm { width: 36px; height: 36px; font-size: 12px; }
.avatar--md { width: 48px; height: 48px; font-size: 15px; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
  color: var(--navy);
}

.card__body { padding: var(--space-2) var(--space-5) var(--space-5); }

/* KPI Card */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-extra);
  color: var(--navy);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.kpi-trend {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}
.kpi-trend.warning { background: var(--warning-light); color: var(--warning); }
.kpi-trend.success { background: var(--success-light); color: var(--success); }
.kpi-trend.info    { background: var(--info-light);    color: var(--info); }
.kpi-trend.error   { background: var(--error-light);   color: var(--error); }

/* ---- LINKS ---- */
.link {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--primary);
  cursor: pointer;
  transition: color var(--transition);
}
.link:hover { color: var(--primary-dark); }

/* ---- TABS ---- */
.tab-bar {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-5);
}

.tab {
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

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

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

.data-table th {
  padding: var(--space-3) var(--space-5);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--surface);
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface); }

.cell-person {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.action-group {
  display: flex;
  gap: var(--space-2);
}

/* ---- FILTERS ---- */
.filter-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  flex: 1;
  min-width: 200px;
}

.search-box input {
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: transparent;
  width: 100%;
}
.search-box input::placeholder { color: var(--text-muted); }

.filter-select {
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--white);
  cursor: pointer;
}

/* ---- FORMS ---- */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-label { font-size: var(--text-sm); font-weight: var(--weight-semi); color: var(--text-secondary); }

.form-control {
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 175, 140, 0.12); }

/* ---- MODALS ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 22, 56, 0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  margin: var(--space-4);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.modal__header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.modal__body { padding: var(--space-6); }
.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);
  background: var(--surface);
}

/* ---- PROGRESS BARS ---- */
.progress-bar {
  height: 6px;
  background: var(--surface-mid);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar--lg { height: 8px; }

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.progress-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- CALLOUTS ---- */
.callout {
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.5;
  margin: var(--space-4) 0;
}

.callout--warning { background: var(--warning-light); color: #7a4e0d; border-left: 3px solid var(--warning); }
.callout--error   { background: var(--error-light);   color: #7a1f1c; border-left: 3px solid var(--error); }
.callout--info    { background: var(--info-light);    color: #1a4d99; border-left: 3px solid var(--info); }
.callout--success { background: var(--success-light); color: #1a5c42; border-left: 3px solid var(--success); }
