/* =========================================================================
   BASE.CSS
   A small, self-contained layout/utility layer that replaces the Bootstrap
   CDN bundle. It gives every class already used across the templates
   (container, row, col-*, btn, card, form-control, modal, navbar, table,
   badge, alert, etc.) real structure. Brand colors/fonts are then layered
   on top by main.css, same as the old Bootstrap + custom-css combination.
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
img { max-width: 100%; }
a { text-decoration: none; }
button { font-family: inherit; }

/* ---- Containers -------------------------------------------------------- */
.container, .container-fluid {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.container { max-width: 1140px; }

/* ---- Grid (12-column, flexbox based — same model Bootstrap uses) ------- */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -0.5rem;
  margin-right: -0.5rem;
}
.row > * { padding-left: 0.5rem; padding-right: 0.5rem; }
.row.g-3 { margin-left: -0.5rem; margin-right: -0.5rem; row-gap: 1rem; }
.row.g-4 { margin-left: -0.75rem; margin-right: -0.75rem; row-gap: 1.5rem; }
.row.g-4 > * { padding-left: 0.75rem; padding-right: 0.75rem; }

.col { flex: 1 0 0%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* row-cols-N: each direct child gets an equal share, N per row */
.row-cols-2 > * { flex: 0 0 50%; max-width: 50%; }

@media (min-width: 576px) {
  .col-sm-10 { flex: 0 0 83.3333%; max-width: 83.3333%; }
  .flex-sm-row { flex-direction: row !important; }
}
@media (min-width: 768px) {
  .col-md-3 { flex: 0 0 25%; max-width: 25%; }
  .col-md-6 { flex: 0 0 50%; max-width: 50%; }
  .flex-md-row { flex-direction: row !important; }
  .row-cols-md-3 > * { flex: 0 0 33.3333%; max-width: 33.3333%; }
  .px-md-5 { padding-left: 3rem; padding-right: 3rem; }
}
@media (min-width: 992px) {
  .col-lg-4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
  .col-lg-5 { flex: 0 0 41.6667%; max-width: 41.6667%; }
  .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
  .col-lg-7 { flex: 0 0 58.3333%; max-width: 58.3333%; }
  .row-cols-lg-5 > * { flex: 0 0 20%; max-width: 20%; }
  .align-items-lg-center { align-items: center !important; }
  .gap-lg-2 { gap: 0.5rem !important; }
}

/* ---- Flex utilities ------------------------------------------------------ */
.d-flex { display: flex !important; }
.d-inline { display: inline !important; }
.d-none { display: none !important; }
.flex-column { flex-direction: column !important; }
.align-items-center { align-items: center !important; }
.align-items-md-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }

/* ---- Spacing -------------------------------------------------------------- */
.m-3 { margin: 1rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-auto { margin-left: auto !important; }
.p-2 { padding: 0.5rem !important; }
.p-4 { padding: 1.5rem !important; }
.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
.position-fixed { position: fixed !important; }
.bottom-0 { bottom: 0 !important; }
.end-0 { right: 0 !important; }
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

/* ---- Text ------------------------------------------------------------------ */
.text-center { text-align: center !important; }
.text-nowrap { white-space: nowrap !important; }
.text-white { color: #fff !important; }
.fw-bold { font-weight: 700 !important; }
.fs-3 { font-size: 1.75rem !important; }
small, .small { font-size: 0.875em; }
.rounded-circle { border-radius: 50% !important; }

/* ---- Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-block;
  font-weight: 500;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 6px;
  background: #e9ecef;
  color: #212529;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { filter: brightness(0.95); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; border-radius: 4px; }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.btn-group > .btn:last-child { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.btn-group-sm > .btn { padding: 0.25rem 0.5rem; font-size: 0.78rem; }
.d-inline .btn, form.d-inline { display: inline-block; }

.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-outline-primary { background: transparent; border-color: #2563eb; color: #2563eb; }
.btn-outline-secondary { background: transparent; border-color: #6c757d; color: #6c757d; }
.btn-outline-danger { background: transparent; border-color: #dc3545; color: #dc3545; }
.btn-danger { background: #dc3545; border-color: #dc3545; color: #fff; }
.btn-success { background: #198754; border-color: #198754; color: #fff; }
.btn-warning { background: #ffc107; border-color: #ffc107; color: #212529; }
.btn-light { background: #f8f9fa; border-color: #f8f9fa; color: #212529; }

.btn-close {
  width: 1.2em;
  height: 1.2em;
  border: none;
  background: transparent;
  position: relative;
  cursor: pointer;
  opacity: 0.65;
}
.btn-close::before {
  content: "\00d7";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4em;
  line-height: 1;
  color: currentColor;
}
.btn-close:hover { opacity: 1; }
.btn-close-white { color: #fff; }

/* ---- Forms ------------------------------------------------------------------- */
.form-label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; }
.form-control, .form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  color: #212529;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: #86b7fe;
}
.form-control-sm { padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.form-check { display: flex; align-items: center; gap: 0.4rem; }
.form-check-input { width: 1.1em; height: 1.1em; }
.form-check-label { font-size: 0.9rem; }
.form-floating { position: relative; }
.form-floating > .form-control { padding-top: 1.4rem; padding-bottom: 0.4rem; }
.form-floating > label {
  position: absolute;
  top: 0.6rem;
  left: 0.75rem;
  font-size: 0.78rem;
  color: #6c757d;
  pointer-events: none;
}

/* ---- Cards -------------------------------------------------------------------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.125);
  border-radius: 8px;
  overflow: hidden;
}
.card-body { padding: 1.25rem; flex: 1 1 auto; }
.card-header { padding: 0.75rem 1.25rem; border-bottom: 1px solid rgba(0,0,0,0.125); }
.card-footer { padding: 0.75rem 1.25rem; border-top: 1px solid rgba(0,0,0,0.125); }
.card-title { margin-top: 0; margin-bottom: 0.5rem; }
.card-img-top { width: 100%; display: block; }
.shadow { box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15) !important; }
.shadow-sm { box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075) !important; }

/* ---- Tables ------------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid #dee2e6; vertical-align: top; }
.table.align-middle th, .table.align-middle td { vertical-align: middle; }
.table-responsive { overflow-x: auto; }

/* ---- Badges / alerts ------------------------------------------------------------ */
.badge { display: inline-block; padding: 0.35em 0.65em; font-size: 0.75em; font-weight: 700; border-radius: 0.375rem; color: #fff; }
.badge.bg-primary { background: #2563eb; }
.badge.bg-secondary { background: #6c757d; }
.badge.bg-success { background: #198754; }
.badge.bg-danger { background: #dc3545; }
.badge.bg-warning { background: #ffc107; color: #212529; }

.alert { padding: 0.9rem 1.1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-info { background: #cff4fc; border-color: #b6effb; color: #055160; }
.alert-success { background: #d1e7dd; border-color: #badbcc; color: #0f5132; }
.alert-danger { background: #f8d7da; border-color: #f5c2c7; color: #842029; }

/* ---- Navbar ------------------------------------------------------------------- */
.navbar { padding: 0.5rem 0; }
.navbar .container-fluid { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.navbar-brand { font-size: 1.25rem; }
.navbar-toggler {
  display: none;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px;
  background: transparent;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}
.navbar-toggler-icon {
  display: inline-block;
  width: 1.3em;
  height: 1.3em;
  background: currentColor;
  -webkit-mask: radial-gradient(circle, transparent 1px, #000 1px) 0 0/6px 2px repeat-x, none;
  mask: none;
  position: relative;
}
.navbar-toggler-icon::before {
  content: "\2630";
}
.navbar-nav { list-style: none; display: flex; margin: 0; padding: 0; gap: 0.25rem; flex-wrap: wrap; }
.nav-item { list-style: none; }
.nav-link { display: inline-block; padding: 0.4rem 0.75rem; }

@media (max-width: 991.98px) {
  .navbar-toggler { display: inline-block; }
  .navbar-collapse { display: none; width: 100%; }
  .navbar-collapse.show { display: block; }
  .navbar-collapse .navbar-nav { flex-direction: column; }
}
@media (min-width: 992px) {
  .navbar-collapse { display: flex !important; flex: 1; justify-content: flex-end; }
}

/* ---- Modal ---------------------------------------------------------------------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(0,0,0,0.5);
  padding: 1rem;
  overflow-y: auto;
}
.modal.show { display: flex; align-items: flex-start; justify-content: center; }
.modal-dialog { width: 100%; max-width: 500px; margin: 1.75rem auto; }
.modal-dialog-centered { display: flex; align-items: center; min-height: calc(100% - 3.5rem); margin: 0 auto; }
.modal-lg { max-width: 800px; }
.modal-content { background: #fff; border-radius: 8px; overflow: hidden; width: 100%; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid #dee2e6; }
.modal-title { margin: 0; }
.modal-body { padding: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid #dee2e6; }
body.modal-open { overflow: hidden; }
