/* Responsive overrides for Torch admin (tables + filters + nav) */

section#torch-table table th,
section#torch-table table td {
  text-align: center !important;
  vertical-align: middle;
  line-height: 1.5;
}

section#torch-table table td.torch-actions {
  white-space: nowrap;
}

.admin-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.admin-badge--success {
  background-color: #d1fae5;
  color: #166534;
}

.admin-badge--warning {
  background-color: #fef3c7;
  color: #92400e;
}

.admin-badge--danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.admin-badge--info {
  background-color: #dbeafe;
  color: #1e40af;
}

.admin-badge--neutral {
  background-color: #f3f4f6;
  color: #1f2937;
}

.torch-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 10px 12px;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  background: #fff;
  color: #555;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.torch-nav-toggle:hover,
.torch-nav-toggle:focus {
  border-color: #2aa797;
  color: #2aa797;
  outline: none;
}

.torch-filters-toggle {
  display: none;
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  background: #fff;
  color: #2aa797;
  font-size: 14px;
  font-weight: bold;
  text-align: left;
  cursor: pointer;
}

.torch-filters-toggle:hover,
.torch-filters-toggle:focus {
  border-color: #2aa797;
  outline: none;
}

.torch-filters-toggle .fa {
  float: right;
  margin-top: 2px;
}

.torch-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 1024px) {
  .torch-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Index: filters above table (single column) */
  body.torch-index section#torch-index-content .torch-container {
    display: flex !important;
    flex-direction: column !important;
  }

  body.torch-index section#torch-index-content .torch-container section#torch-table,
  body.torch-index section#torch-index-content .torch-container section#torch-filters {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
  }

  body.torch-index section#torch-index-content .torch-container section#torch-filters {
    order: 1;
    margin-bottom: 16px;
    display: block !important;
  }

  body.torch-index section#torch-index-content .torch-container section#torch-table {
    order: 2;
    /* Do not scroll the whole section — pagination must stay visible */
    overflow: visible !important;
    max-width: 100%;
  }

  section#torch-table .torch-table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  section#torch-table .torch-table-scroll table {
    min-width: 640px;
    margin-bottom: 0;
  }

  /* Pagination stays outside the horizontal scroll wrapper */
  section#torch-table section#torch-pagination,
  section#torch-pagination {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    width: 100% !important;
    max-width: 100%;
    margin: 16px 0 20px;
    clear: both;
    overflow: visible;
  }

  section#torch-pagination ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 0;
    margin: 0;
    list-style: none;
  }

  /* Filter fields: full-width stacked controls */
  section#torch-filters .field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
  }

  section#torch-filters .field label {
    width: 100%;
  }

  section#torch-filters .field select,
  section#torch-filters .field input[type="text"],
  section#torch-filters .field input[type="number"],
  section#torch-filters .field input[type="email"] {
    width: 100% !important;
    max-width: 100%;
    margin-right: 0 !important;
    margin-bottom: 8px;
    box-sizing: border-box;
  }

  section#torch-filters .field input[type="text"].datepicker {
    width: 100% !important;
  }

  section#torch-filters a {
    margin-left: 0;
    display: inline-block;
    margin-top: 10px;
  }

  section#torch-filters.is-collapsed #torch-filters-form {
    display: none;
  }

  .torch-filters-toggle {
    display: block;
  }

  /* Toolbar wrap */
  section#torch-toolbar .torch-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Nav hamburger */
  section#torch-nav .torch-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .torch-nav-toggle {
    display: inline-flex;
  }

  section#torch-nav nav.torch-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    float: none;
    padding: 8px 0 16px;
  }

  section#torch-nav nav.torch-nav.is-open {
    display: flex;
  }

  section#torch-nav nav.torch-nav > a,
  section#torch-nav nav.torch-nav .dropdown {
    float: none;
    width: 100%;
    overflow: visible;
  }

  section#torch-nav nav.torch-nav > a,
  section#torch-nav nav.torch-nav .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 10px;
    box-sizing: border-box;
  }

  section#torch-nav nav.torch-nav .dropdown-content {
    position: static;
    display: none;
    float: none;
    width: 100%;
    min-width: 0;
    box-shadow: none;
    border: 1px solid #eee;
    margin: 0 0 8px;
  }

  section#torch-nav nav.torch-nav .dropdown.is-open .dropdown-content {
    display: block;
  }

  section#torch-nav nav.torch-nav .dropdown:hover .dropdown-content {
    display: none;
  }

  section#torch-nav nav.torch-nav .dropdown.is-open:hover .dropdown-content,
  section#torch-nav nav.torch-nav .dropdown.is-open .dropdown-content {
    display: block;
  }

  /* Forms / show pages */
  section#torch-header-and-content ul li .torch-show-label {
    text-align: left;
    padding-right: 0;
    display: block;
    width: 100%;
  }

  form#torch-form .torch-form-group input,
  form#torch-form .torch-form-group select,
  form#torch-form .torch-form-group textarea,
  form#torch-form .torch-form-group input[type="email"] {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  form#torch-form .torch-submit-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (min-width: 1025px) {
  .torch-nav-toggle,
  .torch-filters-toggle {
    display: none !important;
  }

  section#torch-filters.is-collapsed #torch-filters-form {
    display: block;
  }

  .torch-table-scroll {
    overflow: visible;
  }
}
