/* ─── Shared component styles ────────────────────────────────────────────────
   Consolidates patterns that were duplicated inline across dashboards, list
   pages, and settings hubs. Load globally via layout/partials/styles.html.
   Pages should NOT redefine these classes in their own <style> blocks.
   ───────────────────────────────────────────────────────────────────────── */

/* Brand tokens (--brand-*, --kounet-*, --primary-*) live in
   brand-tokens.css and are loaded globally from styles.html and
   styles_front.html. */

/* ─── Button vocabulary ──────────────────────────────────────────────────
   Semantic button choices used across the app:

   .btn-primary           — Primary CTA on a page (Add, Save, Submit).
                             Teal filled. Inherits from Bootstrap/Sneat.
   .btn-outline-primary   — Secondary CTA related to primary
                             (View All, Export). Teal outline.
   .btn-primary-soft      — Tertiary inline action (Import, Quick add).
                             Light teal background, dark teal text.
   .btn-outline-secondary — Neutral / dismiss action (Cancel, Close).
                             Gray outline.
   .btn-danger            — Destructive action (Delete, Remove). Red.
   .btn-link / .btn-text-secondary — Inline-text action. No background.
   ──────────────────────────────────────────────────────────────────────── */
.btn-primary-soft {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border: none;
}
.btn-primary-soft:hover,
.btn-primary-soft:focus {
  background: var(--brand-primary);
  color: #fff;
}

/* ─── Page header ────────────────────────────────────────────────────────── */
/* Stacks vertically on phones, row on small+ screens. Gap keeps action
   buttons from crashing into the title on narrow viewports. */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.page-header > div:first-child { min-width: 0; }
.page-header .page-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  word-break: break-word;
}
.page-header .page-subtitle {
  color: var(--kounet-text-muted);
  margin-bottom: 0;
  font-size: 0.875rem;
}
.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.page-header-actions .btn { white-space: nowrap; }

@media (min-width: 576px) {
  .page-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .page-header .page-title { font-size: 1.375rem; }
}

/* ─── Stats card (dashboard / list summary tiles) ───────────────────────── */
.stats-card {
  border: none;
  border-radius: 0.75rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stats-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 128, 128, 0.15);
}
.stats-card .stats-label {
  font-size: 0.8rem;
  color: var(--kounet-text-muted);
  margin-bottom: 0.25rem;
}
.stats-card .stats-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
.stats-card .stats-change {
  font-size: 0.72rem;
  font-weight: 600;
}
.stats-card .stats-change.positive { color: #16a34a; }
.stats-card .stats-change.negative { color: #dc2626; }

.stats-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  color: #fff;
}
.stats-icon.students   { background: linear-gradient(135deg, var(--brand-primary) 0%, #00a0a0 100%); }
.stats-icon.teachers   { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); }
.stats-icon.classes    { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.stats-icon.parents    { background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%); }
.stats-icon.finance    { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); }
.stats-icon.attendance { background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); }
.stats-icon.warning    { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); }

/* ─── Section card (content panels under the page header) ───────────────── */
.section-card {
  border: none;
  border-radius: 0.875rem;
  height: 100%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.section-card .section-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f3f5;
}
.section-card .section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--kounet-text-heading);
  margin: 0;
  display: flex;
  align-items: center;
  min-width: 0;
}
.section-card .section-title i { color: var(--kounet-primary); margin-right: 0.5rem; }
.section-card .section-body { padding: 1.25rem; }

@media (min-width: 768px) {
  .section-card .section-header { padding: 1.25rem 1.5rem; }
  .section-card .section-body { padding: 1.5rem; }
}

/* ─── Tab toolbar (search + actions row at top of tabs) ─────────────────── */
.tab-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #f1f3f5;
}
.tab-toolbar .toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ─── Search wrapper (toolbar search input) ─────────────────────────────── */
.search-wrapper {
  position: relative;
  width: 100%;
  max-width: 280px;
}
.search-wrapper .form-control {
  padding-left: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--kounet-border);
  transition: all 0.2s ease;
}
.search-wrapper .form-control:focus {
  border-color: var(--kounet-primary);
  box-shadow: 0 0 0 3px var(--kounet-primary-soft);
}
.search-wrapper .search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: #a1acb8;
  pointer-events: none;
}

/* ─── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
}
.empty-state .empty-state-icon {
  font-size: 3rem;
  color: var(--kounet-primary);
  opacity: 0.5;
  margin-bottom: 0.75rem;
}
.empty-state h5 { margin-bottom: 0.5rem; }
.empty-state p { color: var(--kounet-text-muted); margin-bottom: 1rem; }

/* ─── List tables → card rows on phones (<768px) ──────────────────────────
   Horizontal scroll is bad UX on a phone, so below md we reshape each row
   into a card: header hidden, cells stack, action dropdown floats to the
   top-right. Opt in by tagging the table with `.people-table` (people
   list, has avatar/checkbox affordances) or `.app-stack-table` (generic
   list tables: payroll rates, pricing plans, discounts, etc.).
   Parents already use .parent-card and aren't affected. */
@media (max-width: 767.98px) {
  .people-table,
  .app-stack-table { border: 0; margin: 0; }
  .people-table thead,
  .app-stack-table thead { display: none; }
  .people-table tbody tr,
  .app-stack-table tbody tr {
    display: block;
    position: relative;
    margin: 0 0 0.75rem;
    padding: 0.875rem 2.75rem 0.875rem 0.875rem;
    border: 1px solid var(--kounet-border);
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  .people-table tbody tr:hover,
  .app-stack-table tbody tr:hover { background: #fff; }
  .people-table tbody td,
  .app-stack-table tbody td {
    display: block;
    padding: 0.125rem 0;
    border: 0;
    width: auto !important;
  }
  .people-table tbody td:empty,
  .app-stack-table tbody td:empty { display: none; }
  /* People-only: avatar + name gets a little breathing room below */
  .people-table tbody td:has(.avatar-wrapper) { padding-bottom: 0.5rem; }
  /* People-only: select checkbox → top-left */
  .people-table tbody td:has(> .form-check) {
    position: absolute;
    top: 0.875rem;
    left: 0.625rem;
    padding: 0;
  }
  /* Shift the name cell when a checkbox is present so they don't overlap */
  .people-table tbody td:has(> .form-check) ~ td:has(.avatar-wrapper) {
    padding-left: 1.75rem;
  }
  /* Generic: first cell becomes the card title */
  .app-stack-table tbody td:first-child {
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
  }
  /* Action dropdown → top-right */
  .people-table tbody td:last-child,
  .app-stack-table tbody td:last-child {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0;
  }
}

/* ─── Mobile tune-ups (<576px) ──────────────────────────────────────────── */
/* Selectors nested under .stats-card / .welcome-card win over page-level
   overrides without needing !important. */
@media (max-width: 575.98px) {
  .stats-card .card-body { padding: 1rem; }
  .stats-card .stats-icon { width: 40px; height: 40px; font-size: 1.125rem; border-radius: 0.5rem; }
  .stats-card .stats-value { font-size: 1.25rem; }
  .stats-card .stats-label { font-size: 0.75rem; }

  .welcome-card .card-body { padding: 1.25rem !important; }
  .welcome-card .welcome-title { font-size: 1.25rem !important; line-height: 1.3; }
  .welcome-card .welcome-subtitle { font-size: 0.875rem; }
  .welcome-card .welcome-date { font-size: 0.75rem; }

  .section-card .section-header { padding: 0.875rem 1rem; }
  .section-card .section-body { padding: 1rem; }
  .section-card .section-title { font-size: 0.875rem; }

  /* Tap targets — Sneat's .btn-icon.btn-sm renders ~28px square; on
     phones bump to 36px so list-row icon actions (remove, unenroll,
     unlink, dropdown menus) are reliably tappable. */
  .btn-icon.btn-sm,
  .btn-group-sm > .btn-icon.btn {
    width: 36px;
    height: 36px;
  }
}
