/* ============================================
   Bootstrap 5 + Tailwind CSS Compatibility Layer
   ============================================ */

/* Reset Bootstrap conflicts with Tailwind */
.btn-close-white {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Ensure Bootstrap modals work correctly */
.modal.fade {
  transition: opacity 0.15s linear;
}

.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out;
  transform: translate(0, -50px);
}

.modal.show .modal-dialog {
  transform: none;
}

.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-backdrop.fade {
  opacity: 0;
}

.modal-backdrop.show {
  opacity: 1;
}

/* Bootstrap alert compatibility */
.alert {
  position: relative;
  padding: 1rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
}

.alert-danger {
  color: #991b1b;
  background-color: #fef2f2;
  border-color: #fecaca;
}

.alert-success {
  color: #166534;
  background-color: #f0fdf4;
  border-color: #bbf7d0;
}

.alert-dismissible {
  padding-right: 3rem;
}

.alert-dismissible .btn-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  padding: 1.25rem 1rem;
}

/* Bootstrap form validation */
.is-invalid {
  border-color: #dc2626 !important;
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #dc2626;
}

.invalid-feedback.d-block {
  display: block;
}

/* Bootstrap table */
.table {
  width: 100%;
  margin-bottom: 1rem;
  color: #1f2937;
  border-collapse: collapse;
}

.table-bordered {
  border: 1px solid #e5e7eb;
}

.table-bordered th,
.table-bordered td {
  border: 1px solid #e5e7eb;
}

.table-hover tbody tr:hover {
  background-color: #f9fafb;
}

/* Bootstrap utilities we need */
.text-end {
  text-align: right !important;
}

.d-block {
  display: block !important;
}

.d-none {
  display: none !important;
}

.mb-0 {
  margin-bottom: 0 !important;
}

.mt-3 {
  margin-top: 0.75rem !important;
}

.list-unstyled {
  padding-left: 0;
  list-style: none;
}

/* Ensure body doesn't shift when modal opens */
body.modal-open {
  overflow: hidden;
  padding-right: 0 !important;
}

/* ============================================
   MATERIALIZE CSS COMPATIBILITY LAYER
   Ensures legacy templates render correctly
   ============================================ */

/* Card panels */
.card-panel {
  background-color: #fff;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
}

.z-depth-0 { box-shadow: none !important; }
.z-depth-1 { box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important; }

/* Materialize Grid System */
.row:after { content: ""; display: table; clear: both; }

.col {
  float: left;
  box-sizing: border-box;
  padding: 0 0.75rem;
  min-height: 1px;
}

.col.s12 { width: 100%; }
.col.s10 { width: 83.333%; }
.col.s9 { width: 75%; }
.col.s8 { width: 66.667%; }
.col.s6 { width: 50%; }
.col.s4 { width: 33.333%; }
.col.s3 { width: 25%; }

@media (min-width: 601px) {
  .col.m2 { width: 16.667%; }
  .col.m3 { width: 25%; }
  .col.m4 { width: 33.333%; }
  .col.m6 { width: 50%; }
  .col.m9 { width: 75%; }
  .col.m10 { width: 83.333%; }
}

@media (min-width: 993px) {
  .col.l3 { width: 25%; }
  .col.l4 { width: 33.333%; }
  .col.l6 { width: 50%; }
  .col.l9 { width: 75%; }
}

@media (min-width: 1201px) {
  .col.xl4 { width: 33.333%; }
}

/* Materialize input fields */
.input-field {
  position: relative;
  margin-bottom: 1rem;
}

.input-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.5rem;
}

.input-field input[type="text"],
.input-field input[type="email"],
.input-field input[type="password"],
.input-field input[type="number"],
.input-field input[type="tel"],
.input-field input[type="url"],
.input-field textarea,
.input-field select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 1rem;
  color: #111827;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field input:focus,
.input-field textarea:focus,
.input-field select:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
  outline: none;
}

/* Materialize breadcrumbs wrapper */
.breadcrumb-wrapper {
  background: transparent !important;
  box-shadow: none !important;
}

.breadcrumb-wrapper .nav-wrapper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0;
  font-size: 0.875rem;
}

.breadcrumb-wrapper a.breadcrumb {
  color: #6b7280;
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-wrapper a.breadcrumb:hover {
  color: #dc2626;
}

.breadcrumb-wrapper span.breadcrumb {
  color: #111827;
  font-weight: 500;
}

.breadcrumb-wrapper a.breadcrumb + a.breadcrumb::before,
.breadcrumb-wrapper a.breadcrumb + span.breadcrumb::before {
  content: "/";
  color: #d1d5db;
  margin-right: 0.5rem;
}

.breadcrumb-blur { display: none; }

/* Materialize buttons */
.btn.waves-effect,
.btn-flat.waves-effect {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  line-height: 1.5;
}

.btn.waves-effect.red,
.btn.waves-effect.waves-light.red {
  background: #dc2626;
  color: white;
}

.btn.waves-effect.red:hover {
  background: #b91c1c;
}

.btn.waves-effect.blue {
  background: #2563eb;
  color: white;
}

.btn.waves-effect.blue:hover {
  background: #1d4ed8;
}

.btn-flat.waves-effect {
  background: transparent;
  color: #6b7280;
  padding: 0.5rem 1rem;
}

.btn-flat.waves-effect:hover {
  background: #f3f4f6;
  color: #dc2626;
}

/* Materialize misc */
.flow-text {
  font-size: 1.25rem;
  line-height: 1.75;
}

.text-bold {
  font-weight: 600;
}

.center {
  text-align: center;
}

.flex-reverse {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.href-underline a {
  text-decoration: none;
}

.href-underline a:hover {
  text-decoration: underline;
}

.no-padding {
  padding: 0 !important;
}

.valign-wrapper {
  display: flex;
  align-items: center;
}

.section {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.transparent { background-color: transparent !important; }

.responsive-img {
  max-width: 100%;
  height: auto;
}

/* Materialize responsive visibility */
.hide-on-med-and-up {
  display: none !important;
}

@media (max-width: 600px) {
  .hide-on-small-only { display: none !important; }
  .hide-on-med-and-up { display: none !important; }
}

/* Materialize switch */
.switch label {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.switch label .lever {
  display: inline-block;
  width: 2.5rem;
  height: 1.25rem;
  background: #d1d5db;
  border-radius: 9999px;
  position: relative;
  margin: 0 0.5rem;
  transition: background 0.3s;
}

.switch label .lever:after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  background: white;
  border-radius: 50%;
  top: 0.125rem;
  left: 0.125rem;
  transition: transform 0.3s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch label input:checked + .lever {
  background: #dc2626;
}

.switch label input:checked + .lever:after {
  transform: translateX(1.25rem);
}

.switch label input {
  display: none;
}

/* Materialize Collapsible (Accordion) */
.collapsible {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
}

.collapsible > li {
  border-bottom: 1px solid #e5e7eb;
}

.collapsible > li:last-child {
  border-bottom: none;
}

.collapsible-header {
  padding: 1rem 1.5rem;
  background: #f9fafb;
  cursor: pointer;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: #111827;
  transition: background 0.2s;
}

.collapsible-header:hover {
  background: #f3f4f6;
}

.collapsible-body {
  padding: 1.5rem;
  display: block;
}

.collapsible-body.white {
  background: white;
}

/* Toast styling (Materialize JS toast fallback) */
.toast-success {
  background: #10b981 !important;
  color: white !important;
  border-radius: 0.5rem !important;
}

/* Search wrapper in sidenav */
.search-wrapper {
  background: transparent !important;
  box-shadow: none !important;
}

/* Materialize circle class */
.circle {
  border-radius: 50%;
}

/* Side info / sidenav compat */
.side-info {
  flex: 1;
}
