/**
 * Aurora layout — responsive grid, utilities, dropdown, switches.
 * Replaces Bootstrap 4 layout/components (no Bootstrap CDN required).
 */

/* ─── Box model helpers ─── */
*,
*::before,
*::after { box-sizing: border-box; }

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

.container-fluid {
  width: 100%;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* ─── Responsive flex grid (Bootstrap-compatible class names) ─── */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -0.375rem;
  margin-right: -0.375rem;
}

.row > [class*="col-"] {
  padding-left: 0.375rem;
  padding-right: 0.375rem;
  min-width: 0;
}

.col, .col-auto { flex: 1 0 0%; max-width: 100%; }
.col-auto { flex: 0 0 auto; width: auto; max-width: none; }

.col-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
.col-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3  { flex: 0 0 25%;        max-width: 25%; }
.col-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6  { flex: 0 0 50%;        max-width: 50%; }
.col-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9  { flex: 0 0 75%;        max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%;       max-width: 100%; }

@media (min-width: 576px) {
  .col-sm-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
  .col-sm-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-sm-3  { flex: 0 0 25%;        max-width: 25%; }
  .col-sm-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-sm-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-sm-6  { flex: 0 0 50%;        max-width: 50%; }
  .col-sm-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-sm-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-sm-9  { flex: 0 0 75%;        max-width: 75%; }
  .col-sm-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-sm-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-sm-12 { flex: 0 0 100%;       max-width: 100%; }
}

@media (min-width: 768px) {
  .col-md-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
  .col-md-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-md-3  { flex: 0 0 25%;        max-width: 25%; }
  .col-md-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-md-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-md-6  { flex: 0 0 50%;        max-width: 50%; }
  .col-md-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-md-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-md-9  { flex: 0 0 75%;        max-width: 75%; }
  .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-md-12 { flex: 0 0 100%;       max-width: 100%; }
}

@media (min-width: 992px) {
  .col-lg-1  { flex: 0 0 8.333333%;  max-width: 8.333333%; }
  .col-lg-2  { flex: 0 0 16.666667%; max-width: 16.666667%; }
  .col-lg-3  { flex: 0 0 25%;        max-width: 25%; }
  .col-lg-4  { flex: 0 0 33.333333%; max-width: 33.333333%; }
  .col-lg-5  { flex: 0 0 41.666667%; max-width: 41.666667%; }
  .col-lg-6  { flex: 0 0 50%;        max-width: 50%; }
  .col-lg-7  { flex: 0 0 58.333333%; max-width: 58.333333%; }
  .col-lg-8  { flex: 0 0 66.666667%; max-width: 66.666667%; }
  .col-lg-9  { flex: 0 0 75%;        max-width: 75%; }
  .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
  .col-lg-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
  .col-lg-12 { flex: 0 0 100%;       max-width: 100%; }
}

@media (max-width: 767.98px) {
  .row > [class*="col-md-"],
  .row > [class*="col-lg-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ─── Flex utilities ─── */
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-block { display: block !important; }
.d-none { display: none !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

.justify-content-start   { justify-content: flex-start !important; }
.justify-content-end     { justify-content: flex-end !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }

.align-items-start   { align-items: flex-start !important; }
.align-items-center { align-items: center !important; }
.align-items-end   { align-items: flex-end !important; }

.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 0.75rem !important; }

.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }
.mr-1 { margin-right: 0.25rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.ml-2 { margin-left: 0.5rem !important; }

.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.my-3 { margin-top: 1rem !important; margin-bottom: 1rem !important; }

.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }

.w-100 { width: 100% !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-muted { color: var(--dm-text-3, #667085) !important; }
.text-success { color: var(--dm-success, #12b76a) !important; }
.text-danger { color: var(--dm-danger, #b42318) !important; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ─── Forms (legacy class aliases — prefer dm-field / dm-input) ─── */
.form-group { margin-bottom: 0.75rem; }
.form-row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -0.375rem;
  margin-right: -0.375rem;
}
.form-row > .col,
.form-row > [class*="col-"] {
  padding-left: 0.375rem;
  padding-right: 0.375rem;
}
.form-inline {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
}
.form-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--dm-text-3);
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--dm-danger);
}
.was-validated .form-control:invalid ~ .invalid-feedback,
.dm-aurora-form .dm-input:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback,
.dm-input.is-invalid ~ .invalid-feedback {
  display: block;
}

/* ─── Input group (password toggle on auth) ─── */
.input-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 100%;
  position: relative;
}
.input-group > .form-control,
.input-group > .dm-input {
  flex: 1 1 auto;
  min-width: 0;
}
.input-group-append {
  display: flex;
  margin-left: -1px;
}
.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  background: var(--dm-surface-2);
  border: 1px solid var(--dm-border-strong);
  border-radius: 0 var(--dm-radius) var(--dm-radius) 0;
  color: var(--dm-text-2);
}

/* ─── Dropdown ─── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1050;
  min-width: 10rem;
  padding: 0.25rem 0;
  margin: 0.125rem 0 0;
  list-style: none;
  background: var(--dm-surface);
  border: 1px solid var(--dm-border);
  border-radius: var(--dm-radius-lg);
  box-shadow: var(--dm-shadow-md);
}

.dropdown-menu-right { right: 0; left: auto; }

.dropdown.show > .dropdown-menu,
.dropdown-menu.show { display: block; }

.dropdown-header {
  display: block;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0;
  font-size: 0.6875rem;
  color: var(--dm-text-3);
  white-space: nowrap;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.4375rem 0.75rem;
  clear: both;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--dm-text-2);
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--dm-surface-2);
  color: var(--dm-text);
  text-decoration: none;
}

.dropdown-divider {
  height: 0;
  margin: 0.25rem 0;
  overflow: hidden;
  border-top: 1px solid var(--dm-border);
}

/* ─── Button groups / tab toggles ─── */
.btn-group {
  display: inline-flex;
  vertical-align: middle;
  position: relative;
}
.btn-group > .btn {
  position: relative;
  flex: 0 1 auto;
}
.btn-group > .btn:not(:first-child) {
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.btn-group > .btn:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.btn-group-toggle .btn input[type="radio"],
.btn-group-toggle .btn input[type="checkbox"] {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}

/* ─── Custom checkbox / switch ─── */
.custom-control {
  position: relative;
  display: block;
  min-height: 1.25rem;
  padding-left: 1.75rem;
}

.custom-control-input {
  position: absolute;
  left: 0;
  z-index: -1;
  width: 1rem;
  height: 1.25rem;
  opacity: 0;
}

.custom-control-label {
  position: relative;
  margin-bottom: 0;
  vertical-align: top;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--dm-text-2);
  user-select: none;
}

.custom-control-label::before {
  position: absolute;
  top: 0.125rem;
  left: -1.75rem;
  display: block;
  width: 1rem;
  height: 1rem;
  content: "";
  background: var(--dm-surface);
  border: 1px solid var(--dm-border-strong);
  border-radius: 0.2rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.custom-control-label::after {
  position: absolute;
  top: 0.125rem;
  left: -1.75rem;
  display: block;
  width: 1rem;
  height: 1rem;
  content: "";
  background: no-repeat 50% / 50% 50%;
}

.custom-control-input:checked ~ .custom-control-label::before {
  background: var(--dm-accent);
  border-color: var(--dm-accent);
}

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='%23fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26l2.974 2.99L8 2.193z'/%3E%3C/svg%3E");
}

.custom-switch {
  padding-left: 2.375rem;
}

.custom-switch .custom-control-label::before {
  left: -2.375rem;
  width: 1.875rem;
  height: 1.125rem;
  border-radius: 0.5625rem;
  pointer-events: all;
}

.custom-switch .custom-control-label::after {
  top: calc(0.125rem + 2px);
  left: calc(-2.375rem + 2px);
  width: calc(1.125rem - 4px);
  height: calc(1.125rem - 4px);
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.custom-switch .custom-control-input:checked ~ .custom-control-label::after {
  transform: translateX(0.75rem);
  background: #fff;
}

.btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--dm-border-strong);
  color: var(--dm-text-2);
}
.btn-outline-secondary:hover {
  background: var(--dm-surface-2);
  color: var(--dm-text);
  border-color: var(--dm-border-strong);
}

.close {
  float: right;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  color: var(--dm-text-3);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0.7;
}
.close:hover { opacity: 1; color: var(--dm-text); }

/* ─── Tables ─── */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

/* ─── Cards (minimal) ─── */
.card {
  background: var(--dm-surface);
  border: 1px solid var(--dm-border);
  border-radius: var(--dm-radius-lg);
}
.card-body { padding: 0.75rem 1rem; }

/* ─── Pagination base ─── */
.pagination {
  display: flex;
  flex-wrap: wrap;
  padding-left: 0;
  list-style: none;
  margin: 0;
}
.page-item { display: inline-block; }
.page-link {
  display: block;
  padding: 0.375rem 0.625rem;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
}
