/* ─── 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;
  }
}

/* ─── App Tabs (pill-card style) ─────────────────────────────────────────
   Shared tab strip used across settings, list, and detail pages. Each
   tab is a small card with an icon tile, a bold label, and an optional
   count subtitle. Active state is brand-teal text + bottom border + soft
   top shadow. Bootstrap Tab JS still drives the active class via
   `data-bs-toggle="tab"` — these styles only override the visuals. */
.app-tabs {
  display: flex;
  gap: 0.625rem;
  padding: 1rem 1.25rem 0;
  flex-wrap: wrap;
  border-bottom: 1px solid #e9ecef;
  background: #fafbfc;
}
.app-tab {
  flex: 1 1 180px;
  min-width: 0;
  padding: 0.75rem 1rem;
  border: 1px solid #e9ecef;
  border-radius: 0.625rem 0.625rem 0 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: #fff;
  text-align: left;
  color: #6c7a8a;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: -1px;
  position: relative;
  font-family: inherit;
}
.app-tab:hover { color: #2c3e50; border-color: #d0d5dd; }
.app-tab.active {
  color: var(--brand-primary);
  border-color: #e9ecef;
  border-bottom-color: var(--brand-primary);
  background: #fff;
  z-index: 1;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.03);
}
.app-tab-icon {
  width: 36px; height: 36px;
  border-radius: 0.5rem;
  background: #f1f3f5;
  color: #6c7a8a;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.app-tab.active .app-tab-icon {
  background: rgba(0, 128, 128, 0.12);
  color: var(--brand-primary);
}
.app-tab-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.app-tab-label {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-tab-count {
  font-size: 0.75rem;
  color: #8094ae;
  margin-top: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-tab.active .app-tab-count { color: var(--brand-primary); opacity: 0.85; }

/* Compact variant — for nested or inline tabs (e.g. inside modals or
   right-rail panels). No icon tile, smaller padding, just label. */
.app-tabs.app-tabs-compact { padding: 0.5rem 0.75rem 0; gap: 0.375rem; }
.app-tabs.app-tabs-compact .app-tab {
  flex: 0 0 auto;
  padding: 0.5rem 0.875rem;
}
.app-tabs.app-tabs-compact .app-tab-icon {
  width: 28px; height: 28px; font-size: 0.95rem;
}
.app-tabs.app-tabs-compact .app-tab-label { font-size: 0.85rem; }

@media (max-width: 575.98px) {
  .app-tabs { padding: 0.625rem 0.75rem 0; gap: 0.375rem; }
  .app-tab {
    flex: 1 1 calc(50% - 0.375rem);
    padding: 0.625rem 0.75rem;
    gap: 0.5rem;
  }
  .app-tab-icon { width: 32px; height: 32px; font-size: 1rem; }
}

/* App tab content area — neutral wrapper that just gives the tabs space
   below to breathe. Pages can use their own card-body otherwise. */
.app-tab-content { padding: 1.25rem; }
@media (max-width: 575.98px) {
  .app-tab-content { padding: 0.875rem; }
}

/* ─── Collapsible explainer "guide" cards ───────────────────────────────
   Drop a `.guide-card` at the top of any page or tab to give users a
   click-to-expand cheat-sheet of how the area works. Pair it with the
   `_guide_step_grid` partial for the visual-step layout, or roll your
   own body content. The header is always visible; the body collapses
   via Bootstrap's collapse component. State (expanded/collapsed) is
   persisted per-browser via the `data-guide-storage-key` attribute. */
.guide-card {
  border: none;
  border-left: 4px solid var(--brand-primary);
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #fafffe 0%, #f0fafa 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin-bottom: 1rem;
}
.guide-card .guide-card-body { padding: 0.875rem 1rem; }
@media (min-width: 768px) { .guide-card .guide-card-body { padding: 1rem 1.25rem; } }

.guide-card .guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 0.75rem;
}
.guide-card .guide-header-text h6 { margin: 0; color: var(--brand-primary); font-weight: 700; }
.guide-card .guide-header-text small { color: #8094ae; }

.guide-card .guide-chevron {
  font-size: 1.5rem;
  color: var(--brand-primary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.guide-card [data-bs-toggle="collapse"] .guide-chevron { transform: rotate(180deg); }
.guide-card [data-bs-toggle="collapse"].collapsed .guide-chevron { transform: rotate(0deg); }

.guide-card .guide-tldr {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: rgba(0, 128, 128, 0.06);
  border-radius: 0.5rem;
  margin-bottom: 0.875rem;
}
.guide-card .guide-tldr .badge { background: var(--brand-primary); }

.guide-card .guide-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}
.guide-card .guide-step {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 0.5rem;
  padding: 0.875rem;
}
.guide-card .guide-step-head {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.guide-card .guide-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--brand-primary); color: #fff;
  font-weight: 700; font-size: 0.8rem;
}
.guide-card .guide-step-title {
  font-weight: 700; color: #2c3e50;
  margin: 0; font-size: 0.95rem;
}
.guide-card .guide-step-title i { color: var(--brand-primary); margin-right: 0.25rem; }
.guide-card .guide-step ul {
  margin: 0; padding-left: 1.1rem;
  font-size: 0.85rem; color: #6c7a8a; line-height: 1.55;
}
.guide-card .guide-step li + li { margin-top: 0.2rem; }

.guide-card .guide-example {
  margin-top: 0.875rem;
  padding: 0.75rem 1rem;
  background: #fffdf5;
  border: 1px solid #f3e9c0;
  border-radius: 0.5rem;
  display: flex; gap: 0.75rem;
}
.guide-card .guide-example > i { color: #d97706; font-size: 1.5rem; flex-shrink: 0; }
.guide-card .guide-example .body { font-size: 0.85rem; }
.guide-card .guide-example strong.label { color: #92400e; }
.guide-card .guide-example ol { margin: 0.4rem 0 0 0; padding-left: 1.1rem; line-height: 1.7; }

.guide-card .guide-tip {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #6c7a8a;
  display: flex; align-items: center; gap: 0.25rem;
}
.guide-card .guide-tip i { color: var(--brand-primary); }
/* ==================== Setup Guide ==================== */
/* Refined look: clean white card, no left bar, no gradient. A dashed
   connector line runs between the numbered steps. Active step nodes
   get a soft halo + brand fill; pending nodes are outlined. */
.setup-guide .card {
  border: 1px solid #e9ecef;
  background: #fff;
  border-radius: 0.875rem;
}
.setup-guide .card-body {
  padding: 1.5rem 1.75rem;
}

.setup-guide .setup-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-primary);
  background: rgba(0, 128, 128, 0.08);
  border-radius: 999px;
  margin-bottom: 0.65rem;
}
.setup-guide .setup-eyebrow i { font-size: 0.85rem; }

.setup-guide h5 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin-bottom: 0.25rem;
  color: #2c3e50;
}
.setup-guide .setup-subtitle {
  color: #8a99a8;
  font-size: 0.875rem;
  margin: 0;
}

.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 1.25rem;
  position: relative;
}

.setup-step {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  position: relative;
}

/* Vertical dashed connector behind the step numbers. Drawn as a
   pseudo-element on each step except the last so the line ends with
   the last circle, not below it. */
.setup-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 19px; /* (40 / 2) - 1, centers under .step-number */
  top: 50px;  /* below the 40px circle + ~10px breathing */
  bottom: -0.25rem;
  width: 2px;
  background-image: linear-gradient(to bottom, #d0d7df 50%, transparent 50%);
  background-size: 2px 6px;
  background-repeat: repeat-y;
}

.step-indicator {
  flex-shrink: 0;
  z-index: 1;  /* sit above the dashed connector */
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  background: #fff;
  border: 2px solid #d0d7df;
  color: #8a99a8;
  transition: all 0.2s ease;
}

.setup-step.active .step-number {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(0, 128, 128, 0.12);
}

.setup-step.completed .step-number,
.step-check {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2ecc71;
  border: 2px solid #2ecc71;
  color: #fff;
  font-size: 1.05rem;
}

.step-content {
  flex: 1;
  min-width: 0;
  padding-top: 0.35rem;
}

.step-title {
  font-weight: 600;
  font-size: 0.975rem;
  color: #2c3e50;
  margin-bottom: 0.2rem;
}
.setup-step.pending .step-title { color: #6b7888; }
.setup-step.completed .step-title { color: #2ecc71; }

.step-description {
  font-size: 0.85rem;
  color: #6b7888;
  line-height: 1.55;
}
.setup-step.pending .step-description { color: #97a3b1; }

/* Pending steps still readable, not ghost-dimmed — opacity 0.5 was
   making them feel disabled instead of "next". */
.setup-step.pending { opacity: 1; }
.setup-step.pending .step-number {
  background: #fff;
  border-style: dashed;
}

.setup-guide .setup-cta {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f3f5;
  display: flex;
  justify-content: flex-end;
}

/* Inline tips footer — single muted row instead of a nested card. */
.setup-tips {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: #fafbfc;
  border: 1px solid #f1f3f5;
  border-radius: 0.625rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.setup-tips .tip-header {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--brand-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.setup-tips .tip-header i { font-size: 1rem; }
.setup-tips .tip-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;
}
.setup-tips .tip-list li {
  font-size: 0.825rem;
  color: #6b7888;
  line-height: 1.5;
  padding: 0.15rem 0;
}
.setup-tips .tip-list li + li { margin-top: 0.15rem; }

/* Responsive adjustments for setup guide */
@media (max-width: 767.98px) {
  .setup-guide .card-body { padding: 1.25rem; }
  .setup-step .d-flex.justify-content-between {
    flex-direction: column;
    gap: 0.5rem;
  }
  .setup-step .btn {
    align-self: flex-start;
  }
  .setup-tips {
    flex-direction: column;
    gap: 0.4rem;
  }
}

/* ─── Modal form section pattern ─────────────────────────────────────────
   Groups fields in long modal forms into named sub-sections with a small
   teal uppercase header. Use one .modal-form-section per logical group.
   Two adjacent sections get a thin top border + spacing between them.
   ───────────────────────────────────────────────────────────────────── */
.modal-form-section + .modal-form-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #eef0f3;
}
.modal-form-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-primary, #008080);
  margin-bottom: 0.85rem;
}
.modal-form-section-header i {
  font-size: 1rem;
}
.modal-form-section-header .modal-form-section-subtitle {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: #8094ae;
}

/* Tighter modal-header treatment used by the redesigned forms — title
   on top, muted subtitle below for context. */
.modal-header .modal-title-stack {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.modal-header .modal-subtitle {
  font-size: 0.78rem;
  color: #8094ae;
  font-weight: 400;
}
