/* ========= Paleta Mola Math ========= */
:root {
  --mm-bg: #e8e6d6;
  /* fons pàgina (crema suau) */
  --mm-card: #f5f3e7;
  /* targetes */
  --mm-line: rgba(0, 0, 0, .08);
  --mm-text: #2b2b2b;
  /* text principal */
  --mm-text-soft: rgba(0, 0, 0, .55);
  --mm-white: #ffffff;

  --mm-cta: #4a3216;
  /* botó principal marró */
  --mm-cta-ink: #fff2e6;

  --mm-blue: #1f5ae2;
  /* suma */
  --mm-orange: #e59700;
  /* resta */
  --mm-purple: #954d9a;
  /* multiplicació */
  --mm-green: #3f9e3f;
  /* divisió */
}

/* ========= Base ========= */
html,
body {
  background: var(--mm-bg);
  color: var(--mm-text);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a {
  color: #1e4ddb;
}

.navbar {
  background: #efeede;
  border-bottom: 1px solid var(--mm-line);
}

/* Navbar toggler (hamburger) */
.navbar-toggler {
  border-color: rgba(0, 0, 0, 0.15) !important;
  padding: 4px 8px !important;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(75, 50, 22, 0.8)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

.navbar .navbar-brand {
  color: var(--mm-text);
}

.container-fluid {
  max-width: 1200px;
}

/* ========= Targetes / taules ========= */
.card,
.stat-card {
  background: var(--mm-card) !important;
  border: none !important;
  border-radius: 16px !important;
  box-shadow: none;
}

.card-header {
  background: rgba(255, 255, 255, .45) !important;
  border-bottom: 1px solid var(--mm-line) !important;
  color: var(--mm-text) !important;
  border-top-left-radius: 16px !important;
  border-top-right-radius: 16px !important;
  font-weight: 700;
}

.table {
  color: var(--mm-text);
  --bs-table-bg: var(--mm-card) !important;
}

.table thead th {
  color: var(--mm-text-soft);
  font-weight: 600;
}

/* Header sticky global (Sense doble scroll) */
@media (min-width: 992px) {

  /* Al llevar l'overflow-x auto al div.table-responsive, permetem que el 'position: sticky' funcioni respecte a l'scroll sencer de la pàgina */
  .table-sticky-wrapper {
    overflow: visible !important;
  }
}

.table-sticky thead th {
  position: sticky;
  top: 0;
  background: var(--mm-card) !important;
  z-index: 10;
  box-shadow: inset 0 -1px 0 var(--mm-line);
}


/* ========= Formularis ========= */
.form-label {
  color: var(--mm-text);
  font-weight: 600;
}

.form-control,
.form-select {
  background: #ece9da !important;
  border: 1px solid var(--mm-line) !important;
  color: var(--mm-text) !important;
  border-radius: 12px !important;
}

.form-control::placeholder {
  color: rgba(0, 0, 0, .35)
}

.form-control:focus,
.form-select:focus {
  border-color: #c7bfa8 !important;
  box-shadow: 0 0 0 .2rem rgba(199, 191, 168, .25) !important;
}

/* ========= Botons ========= */
.btn {
  border-radius: 12px;
  font-weight: 600;
}

.btn-primary {
  background: var(--mm-cta) !important;
  border-color: var(--mm-cta) !important;
  color: var(--mm-white) !important;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-success {
  background: var(--mm-green) !important;
  border-color: var(--mm-green) !important;
}

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

.btn-outline-secondary:hover {
  background: rgba(0, 0, 0, .05);
}

/* ========= Badges / xips ========= */
.badge {
  border-radius: 999px;
  font-weight: 700;
  background: rgba(0, 0, 0, .08);
  color: var(--mm-text);
}

.badge-soft {
  background: rgba(0, 0, 0, .08);
  color: var(--mm-text);
}

/* Xips per operacions */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .6rem;
  border-radius: 999px;
  background: var(--mm-white);
  border: 1px solid var(--mm-line);
  font-weight: 600;
}

.chip i {
  font-style: normal;
  font-weight: 800;
}

.chip.sum {
  color: var(--mm-blue);
}

.chip.sub {
  color: var(--mm-orange);
}

.chip.mul {
  color: var(--mm-purple);
}

.chip.div {
  color: var(--mm-green);
}

/* ========= Helpers d’espaiat i layout ========= */
.card .btn+.btn {
  margin-left: .5rem;
}

.round-lg {
  border-radius: 16px;
}

.shadow-soft {
  box-shadow: 0 12px 28px rgba(0, 0, 0, .08);
}

/* ========= Barra superior de la vista “detall escola” ========= */
.page-title {
  font-weight: 700;
  font-size: 1.6rem;
}

.toolbar .btn {
  border-radius: 999px;
}

/* ========= Fix per a dark-text en alerts i etc. ========= */
.alert {
  background: #fff;
  color: var(--mm-text);
  border: 1px solid var(--mm-line);
}

.card.course--disabled {
  opacity: .45;
  pointer-events: none;
  /* evita hover i clics */
  filter: grayscale(0.2);
}

.card .card-actions .btn.disabled,
.card .card-actions .btn[disabled] {
  pointer-events: none;
  opacity: .7;
}

/* ================================
   MolaMath Backoffice – Buttons
================================ */

/* Base button */
.btn {
  background-color: #ffffff !important;
  color: #583a0b !important;
  border-radius: 15px !important;
  border: none;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 8px 15px 8px 16px;
}

/* Icons inside buttons */
.btn i,
.btn svg {
  color: #1f5ae2 !important;
}

/* Hover */
.btn:hover {
  background-color: #f6f6f6 !important;
  color: #583a0b !important;
  transform: translateY(-1px);
}

/* Active / focus */
.btn:focus,
.btn:active {
  box-shadow: 0 0 0 0.15rem rgba(31, 90, 226, 0.25) !important;
  outline: none !important;
}

/* Disabled */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-danger {
  background-color: #fff !important;
  color: #a61b1b !important;
}

.btn-danger i {
  color: #a61b1b !important;
}

.h5,
h5 {
  font-size: 1.25rem;
  font-weight: 700;
}

.courses-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* ajusta: 16–24px va molt bé */
}

.stat-item {
  margin-bottom: 14px;
}

.stat-item .label {
  font-size: 0.8rem;
  color: #777;
}

.stat-item .value {
  font-size: 1.25rem;
  font-weight: 600;
  color: #583a0b;
}

/* 5 column stats grid */
.stats-5cols {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.stat-card {

  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Header */
.stat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 600;
}

/* Icona estil app */
.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

/* Colors per operació */
.stat-icon.global {
  background: #6c757d;
}

.stat-icon.sum {
  background: var(--mm-blue);
}

.stat-icon.sub {
  background: var(--mm-orange);
}

.stat-icon.mul {
  background: var(--mm-purple);
}

.stat-icon.div {
  background: var(--mm-green);
}

/* Icona petita per a taules (ampliada per visibilitat) */
.stat-icon-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
  line-height: 1;
}

.stat-icon-sm.sum {
  background: var(--mm-blue);
}

.stat-icon-sm.sub {
  background: var(--mm-orange);
}

.stat-icon-sm.mul {
  background: var(--mm-purple);
}

.stat-icon-sm.div {
  background: var(--mm-green);
}

/* Navbar toggler for light-themed navbar */
.navbar-light .navbar-toggler {
  border-color: rgba(0, 0, 0, 0.1);
}

.navbar-light .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%280, 0, 0, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Items */
.stat-item {
  display: flex;
  justify-content: start;
  font-size: 0.9rem;
  margin-bottom: 15px;
  flex-direction: column;
}

.stat-item span {
  color: #777;
}

.stat-item strong {
  color: #583a0b;
  font-weight: 100;
  font-size: 1.9rem;
}

@media (max-width: 1200px) {
  .stats-5cols {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-5cols {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Toolbar / page actions: wrap buttons */
  .page-actions,
  .card-actions,
  .d-flex.gap-2 {
    flex-wrap: wrap !important;
  }

  /* Reduce page title size */
  h3 {
    font-size: 1.15rem !important;
  }

  /* Reduce container side padding */
  .container-fluid {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Smaller table text */
  .table {
    font-size: 0.82rem;
  }

  .table th,
  .table td {
    padding: 0.4rem 0.35rem;
  }

  /* Stat cards: reduce padding */
  .stat-card {
    padding: 10px 12px;
  }

  /* Smaller buttons */
  .btn {
    padding: 6px 10px !important;
    font-size: 0.82rem;
  }

  /* Hide button text labels on mobile, keep icons */
  .btn-label-hide {
    font-size: 0;
  }

  .btn-label-hide .material-symbols-outlined {
    font-size: 1.2rem;
  }
}

@media (max-width: 576px) {
  .stats-5cols {
    grid-template-columns: 1fr;
  }

  /* Stack header flex rows vertically */
  .page-header-flex {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }

  /* Reduce page title further */
  h3 {
    font-size: 1rem !important;
  }

  /* Smaller stat item values */
  .stat-item strong {
    font-size: 1.4rem;
  }

  /* Student stats 2x2 grid: stack on very small */
  .row.g-4>.col-md-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Material Symbols Adjustments */
.material-symbols-outlined {
  vertical-align: bottom;
  /* Aligns better with text baselines */
  font-size: 1.25em;
  /* Slightly larger to match Bootstrap scale */
  line-height: 1;
}

/* Optional: specific adjustment for buttons */
.btn .material-symbols-outlined {
  vertical-align: middle;
  font-size: 1.2rem;
  margin-top: -2px;
}

/* ========= Breadcrumb ========= */
.mm-breadcrumb-row {
  min-height: 38px;
}

.mm-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 500;
}

.mm-breadcrumb li {
  display: flex;
  align-items: center;
  color: rgba(0, 0, 0, 0.45);
}

.mm-breadcrumb li + li::before {
  content: '›';
  margin: 0 6px;
  color: rgba(0, 0, 0, 0.25);
  font-size: 1rem;
  line-height: 1;
}

.mm-breadcrumb a {
  color: rgba(0, 0, 0, 0.5);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.mm-breadcrumb a:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--mm-text);
  text-decoration: none;
}

.mm-breadcrumb .mm-bc-active {
  color: var(--mm-text);
  font-weight: 600;
  padding: 4px 8px;
}

.mm-breadcrumb .material-symbols-outlined {
  font-size: 1rem;
  vertical-align: middle;
  margin-right: 2px;
}