/* app/static/css/components.css */

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
}

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

.card-title {
  font-size: var(--font-h3);
  font-weight: 600;
}

/* ── Metric Cards (KPI) ── */
.metric {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.metric-label {
  font-size: var(--font-label);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-value {
  font-size: var(--font-metric);
  font-weight: 700;
  margin-top: 6px;
}

.metric-trend {
  font-size: 13px;
  margin-top: 5px;
}

.metric-trend.up-good { color: var(--success); }
.metric-trend.up-bad { color: var(--danger); }
.metric-trend.neutral { color: var(--text-muted); }

/* ── Table Card ── */
.table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-card table {
  font-size: var(--font-table);
}

.table-card thead th {
  background: var(--bg-table-header);
  padding: var(--space-md) var(--space-md);
  text-align: left;
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-card thead th a {
  color: var(--text-muted);
  text-decoration: none;
}

.table-card thead th a:hover {
  color: var(--text-primary);
}

.table-card tbody td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.table-card tbody tr:hover {
  background: var(--bg-expanded-row);
}

.table-card .text-right {
  text-align: right;
}

.table-card .text-muted {
  color: var(--text-muted);
}

/* ── Expansion Card (inline drill-down) ── */
.expansion-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--border);
  margin: var(--space-sm) 0;
}

.expansion-row {
  background: var(--bg-expanded-row);
}

.expansion-row td {
  padding-top: 0 !important;
  padding-bottom: var(--space-md) !important;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--accent-light); color: var(--accent); }
.badge-neutral { background: var(--bg-muted); color: var(--text-secondary); }
.badge-dark { background: var(--bg-sidebar); color: var(--text-on-sidebar); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-on-accent);
  text-decoration: none;
}

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

.btn-secondary:hover {
  border-color: var(--text-secondary);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-light);
}

.btn-danger:hover {
  background: var(--danger-light);
  text-decoration: none;
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-xs);
}

.btn-icon {
  padding: var(--space-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

/* ── Pill Tabs ── */
.pill-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.pill-tab {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-pill);
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-muted);
  text-decoration: none;
  transition: background 0.15s;
}

.pill-tab:hover {
  background: var(--border);
  color: var(--text-primary);
  text-decoration: none;
}

.pill-tab.active {
  background: var(--accent);
  color: var(--text-on-accent);
}

/* ── Alerts ── */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 3px solid;
  margin-bottom: var(--space-sm);
}

.alert-success { background: var(--success-light); border-color: var(--success); }
.alert-warning { background: var(--warning-light); border-color: var(--warning); }
.alert-danger { background: var(--danger-light); border-color: var(--danger); }
.alert-info { background: var(--accent-light); border-color: var(--accent); }

.alert-title {
  font-size: 13px;
  font-weight: 500;
}

.alert-text {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Avatar ── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-md { width: 36px; height: 36px; font-size: var(--font-sm); }

/* ── Form Controls ── */
.form-input,
.form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-label {
  display: block;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

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

/* Inline edit selects (in tables) */
.inline-select {
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: var(--font-table);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}

.inline-select:hover {
  border-color: var(--border);
  background: var(--bg-muted);
}

.inline-select:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  outline: none;
}

/* ── Notification Bell ── */
.notification-bell {
  position: relative;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
}

.notification-bell:hover {
  color: var(--text-primary);
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 10px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ── Notification Dropdown ── */
.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 340px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  border: 1px solid var(--border);
  z-index: 200;
  margin-top: var(--space-sm);
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

.notification-dropdown.open {
  display: block;
}

.notification-dropdown-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: var(--font-sm);
}

.notification-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--text-primary);
}

.notification-item:hover {
  background: var(--bg-expanded-row);
  text-decoration: none;
}

.notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.notification-dot-warning { background: var(--warning); }
.notification-dot-danger { background: var(--danger); }
.notification-dot-success { background: var(--success); }
.notification-dot-info { background: var(--accent); }

/* ── Command Palette ── */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
}

.cmd-palette-backdrop.open {
  display: flex;
}

.cmd-palette {
  width: 520px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  overflow: hidden;
}

.cmd-palette-input {
  width: 100%;
  padding: var(--space-lg);
  border: none;
  font-size: 18px;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  border-bottom: 1px solid var(--border-light);
}

.cmd-palette-input::placeholder {
  color: var(--text-muted);
}

.cmd-palette-results {
  max-height: 320px;
  overflow-y: auto;
}

.cmd-result {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
}

.cmd-result:hover,
.cmd-result.selected {
  background: var(--bg-muted);
  text-decoration: none;
}

.cmd-result-icon {
  font-size: 16px;
  color: var(--text-muted);
  width: 24px;
  text-align: center;
}

.cmd-result-name {
  font-weight: 500;
  flex: 1;
}

.cmd-result-type {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

/* ── Sparkline ── */
.sparkline {
  display: inline-block;
  vertical-align: middle;
  margin-left: var(--space-sm);
}

.sparkline svg {
  display: block;
}

/* ── Deduction / USD colors ── */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 600; }

/* ── Help Button (restyled) ── */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-style: italic;
  font-family: serif;
  color: var(--text-muted);
  vertical-align: middle;
  margin-left: var(--space-sm);
}

.help-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Search + Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

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

/* ── Month Navigator ── */
.month-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.month-nav-btn {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 18px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.month-nav-btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  text-decoration: none;
}

.month-nav-label {
  font-weight: 600;
  font-size: var(--font-base);
  min-width: 120px;
  text-align: center;
}

/* ── Progress Bar ── */
.progress-bar {
  height: 6px;
  background: var(--bg-muted);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.red { background: var(--danger); }
.progress-fill.blue { background: var(--accent); }

/* ── Capacity Heatmap ── */
.heatmap-cell {
  width: 48px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xs);
  font-weight: 500;
}

.heatmap-green { background: var(--success-light); color: var(--success); }
.heatmap-amber { background: var(--warning-light); color: var(--warning); }
.heatmap-red { background: var(--danger-light); color: var(--danger); }
.heatmap-empty { background: var(--bg-muted); color: var(--text-muted); }

/* ── Details/Summary restyled ── */
details {
  margin-bottom: var(--space-md);
}

details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-base);
  padding: var(--space-sm) 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

details > summary::before {
  content: "▸";
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.15s;
}

details[open] > summary::before {
  transform: rotate(90deg);
}

details > summary::-webkit-details-marker {
  display: none;
}

/* ── Sticky footer (bulk actions) ── */
.sticky-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Terminated employee row ── */
.row-terminated {
  opacity: 0.4;
}

/* ── Help Modal (restyled) ── */
#help-modal {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  padding: var(--space-xl);
  max-width: 640px;
  width: 90%;
}

#help-modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

#help-modal h1 { font-size: var(--font-h2); margin-bottom: var(--space-md); }
#help-modal h2 { font-size: var(--font-h3); margin-top: var(--space-lg); margin-bottom: var(--space-sm); }
#help-modal h3 { font-size: var(--font-base); margin-top: var(--space-md); margin-bottom: var(--space-sm); }
#help-modal p { margin-bottom: var(--space-md); line-height: 1.6; }
#help-modal code {
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: var(--font-sm);
}
#help-modal table {
  font-size: var(--font-sm);
  margin-bottom: var(--space-md);
}
#help-modal table th,
#help-modal table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}
#help-modal table th {
  font-weight: 600;
  color: var(--text-secondary);
}
tr.hidden { display: none; }
