/* ==========================================================================
   pages.css — Shared styles for all data pages (Manager + Admin)
   Color palette: navy #1a365d, light gray #f8fafc, border #e2e8f0
   ========================================================================== */

/* --------------- Full-bleed content --------------- */

.container-fluid {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* --------------- Table Styles --------------- */

.table-sm > :not(caption) > * > * {
  padding: 0.25rem 0.5rem;
}

.table thead tr,
.table thead th,
.table-light {
  background: linear-gradient(135deg, #1a365d 0%, #2a4a7f 100%) !important;
  color: #ffffff !important;
  border-bottom: 2px solid #0d2b4b;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 48px;
  padding: 0 0.5rem;
  vertical-align: middle;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* White text/icons inside navy header */
.table thead th span,
.table thead th .small,
.table thead th i,
.table thead th .bi {
  color: #ffffff !important;
}

.table thead th .btn {
  color: rgba(255, 255, 255, 0.7) !important;
}

.table thead th .btn:hover {
  color: #ffffff !important;
}

.table th .d-flex {
  height: 100%;
  align-items: center;
  gap: 0.5rem;
}

.table th .position-relative {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.table th .d-flex .small {
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  text-align: left;
}

.table td {
  max-width: min(200px, 15vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-wrap: break-word;
  font-size: 0.875rem;
  line-height: 1.4;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid #e8edf2;
}

/* Alternating row stripes */
.table-striped > tbody > tr:nth-of-type(odd) > *,
.table > tbody > tr:nth-of-type(odd) {
  background-color: #f0f3f7;
}

.table-striped > tbody > tr:nth-of-type(even) > *,
.table > tbody > tr:nth-of-type(even) {
  background-color: #ffffff;
}

/* Card body panel — subtle darker panel for search/content area */
.card-body {
  background-color: #344254;
  color: #e2e8f0;
}

.card-body .form-control,
.card-body .form-select {
  background-color: #2d3a4a;
  color: #e2e8f0;
  border-color: #4a5a6d;
}

.card-body .form-control:focus,
.card-body .form-select:focus {
  background-color: #2d3a4a;
  color: #e2e8f0;
  border-color: #5b9bd5;
  box-shadow: 0 0 0 0.2rem rgba(91, 155, 213, 0.25);
}

.card-body .form-control::placeholder {
  color: #8a99ab;
}

.card-body .small {
  color: #8a99ab;
}

/* Card footer — pagination bar integrated with grid */
.card-footer {
  background-color: #2d3a4a;
  border-top: 1px solid #4a5a6d;
  color: #c0cad6;
}

/* Text muted adjustment for dark backgrounds */
.text-muted {
  color: #8a99ab !important;
}

/* --------------- Table Container (Pattern B: sortable-header tables) --------------- */

.table-container {
  min-height: 400px;
  overflow: visible;
}

/* --------------- Filter Popup (Pattern A) --------------- */

.filter-popup {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  margin-top: 0.5rem;
  min-width: 200px;
  background: #344254;
  border-radius: 0.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #4a5a6d;
  color: #e2e8f0;
}

.filter-popup .p-2 {
  padding: 0.5rem;
}

/* --------------- Filter Dropdown (Pattern B) --------------- */

.filter-dropdown {
  position: absolute;
  top: 100%;
  left: -100px;
  z-index: 1055;
  background: #344254;
  border: 1px solid #4a5a6d;
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
  min-width: 250px;
  max-height: 300px;
  overflow-y: auto;
  color: #e2e8f0;
}

.filter-content {
  padding: 1rem;
}

.filter-input {
  width: 100%;
  margin-bottom: 0.5rem;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

/* --------------- Sortable Headers (Pattern B) --------------- */

.sortable-header {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.15s ease;
}

.sortable-header:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.sort-icon {
  margin-left: 0.5rem;
  opacity: 0.5;
  color: rgba(255, 255, 255, 0.6);
}

.sort-icon.active {
  opacity: 1;
  color: #ffffff;
}

.filter-indicator {
  color: #ffffff !important;
  margin-left: 0.25rem;
}

/* --------------- Search --------------- */

.search-container {
  position: relative;
}

.search-input {
  padding-right: 2.5rem;
}

.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
}

/* --------------- Button Utilities --------------- */

.btn-xs {
  padding: 0.125rem 0.25rem;
  font-size: 0.75rem;
  line-height: 1.2;
}

.cursor-pointer {
  cursor: pointer;
}

/* --------------- Form Utilities --------------- */

.required::after {
  content: " *";
  color: red;
}

/* --------------- Confirmation Dialog --------------- */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1050;
}

.confirmation-dialog {
  background: #344254;
  padding: 1.5rem;
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  min-width: 320px;
  text-align: left;
  color: #e2e8f0;
  border: 1px solid #4a5a6d;
}

/* --------------- Loading Overlay --------------- */

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  background: #344254;
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid #4a5a6d;
}

.loading-text {
  font-weight: 500;
  color: #c0cad6;
}

/* --------------- Dark Modals (Bootstrap Override) --------------- */

.modal-content {
  background-color: #344254;
  color: #e2e8f0;
  border: 1px solid #4a5a6d;
}

.modal-header {
  background: linear-gradient(135deg, #1a365d 0%, #2a4a7f 100%);
  border-bottom: 1px solid #4a5a6d;
  color: #ffffff;
}

.modal-header .modal-title {
  color: #ffffff;
}

.modal-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

.modal-body {
  background-color: #344254;
  color: #e2e8f0;
}

.modal-footer {
  background-color: #2d3a4a;
  border-top: 1px solid #4a5a6d;
}

.modal-body .text-muted {
  color: #8a99ab !important;
}

.modal-body .form-label {
  color: #c0cad6;
}

.modal-body .form-control,
.modal-body .form-select {
  background-color: #2d3a4a;
  color: #e2e8f0;
  border-color: #4a5a6d;
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
  background-color: #2d3a4a;
  color: #e2e8f0;
  border-color: #5b9bd5;
  box-shadow: 0 0 0 0.2rem rgba(91, 155, 213, 0.25);
}

.modal-body .form-control::placeholder,
.modal-body .form-select::placeholder {
  color: #8a99ab;
}

.modal-body .form-select option {
  background-color: #2d3a4a;
  color: #e2e8f0;
}

.modal-body hr {
  border-color: #4a5a6d;
  opacity: 0.5;
}

.modal-body .validation-message {
  color: #f87171;
  font-size: 0.85rem;
}

.modal-body .form-check-label {
  color: #e2e8f0;
}

.modal-body .form-check-input {
  background-color: #2d3a4a;
  border-color: #4a5a6d;
}

.modal-body .form-check-input:checked {
  background-color: #1a365d;
  border-color: #1a365d;
}

.modal-body .border {
  border-color: #4a5a6d !important;
}

.modal-body .border-top {
  border-color: #4a5a6d !important;
}

.modal-body .btn-outline-secondary {
  color: #c0cad6;
  border-color: #4a5a6d;
}

.modal-body .btn-outline-secondary:hover {
  background-color: #3d4f63;
  color: #ffffff;
  border-color: #5b9bd5;
}

.modal-body .btn-outline-danger {
  color: #f87171;
  border-color: #f87171;
}

.modal-body .btn-outline-danger:hover {
  background-color: #f87171;
  color: #ffffff;
}

.modal-body .form-control:disabled,
.modal-body .form-control[readonly] {
  background-color: #2d3a4a;
  color: #8a99ab;
  border-color: #4a5a6d;
  opacity: 1;
}

/* --------------- Pagination --------------- */

.pagination-sm .page-link {
  min-width: 30px;
  text-align: center;
  padding: 0.25rem 0.5rem;
  color: #c0cad6;
  background-color: #2d3a4a;
  border-color: #4a5a6d;
}

.pagination-sm .page-link:hover {
  background-color: #3d4f63;
  border-color: #5b9bd5;
  color: #ffffff;
}

.pagination-sm .page-item.active .page-link {
  background-color: #1a365d;
  border-color: #1a365d;
  color: #ffffff;
}

.pagination-sm .page-item.disabled .page-link {
  color: #5a6878;
  background-color: #2d3a4a;
  border-color: #3d4f63;
}

/* =====================================================================
   Mobile Styles — Full mobile card system (991.98px breakpoint)
   ===================================================================== */

@media (max-width: 991.98px) {

  /* --- Mobile Header --- */
  .mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem 1rem 3.5rem;
    background: #1a365d;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    margin: 0;
  }

  .mobile-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
  }

  .mobile-add-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
  }

  .mobile-add-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    transform: scale(1.05);
  }

  /* --- Mobile Search --- */
  .mobile-search {
    padding: 1rem;
    background: #344254;
    margin: 0;
    position: sticky;
    top: 76px;
    z-index: 99;
  }

  .mobile-search-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
  }

  .mobile-search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #4a5a6d;
    border-radius: 25px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #2d3a4a;
    color: #e2e8f0;
  }

  .mobile-search-input::placeholder {
    color: #8a99ab;
  }

  .mobile-search-input:focus {
    border-color: #5b9bd5;
    box-shadow: 0 0 0 0.2rem rgba(91, 155, 213, 0.25);
    outline: none;
    background-color: #2d3a4a;
  }

  .mobile-search-btn,
  .mobile-search-clear {
    background: #1a365d;
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
  }

  .mobile-search-clear {
    background: #6c757d;
  }

  .mobile-search-btn:hover,
  .mobile-search-clear:hover {
    transform: scale(1.05);
  }

  /* --- Mobile Filter Bar --- */
  .mobile-filter-bar {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: #2d3a4a;
    border-bottom: none;
    overflow-x: auto;
    position: sticky;
    top: 152px;
    z-index: 98;
  }

  .mobile-filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: #344254;
    border: 2px solid #4a5a6d;
    border-radius: 12px;
    color: #c0cad6;
    font-size: 0.875rem;
    white-space: nowrap;
    min-width: 80px;
    transition: all 0.2s ease;
    position: relative;
  }

  .mobile-filter-btn.active {
    background: #1a365d;
    border-color: #1a365d;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(26, 54, 93, 0.3);
  }

  .mobile-filter-btn i:first-child {
    font-size: 1.2rem;
  }

  .mobile-filter-btn .bi-check-circle-fill {
    position: absolute;
    top: -4px;
    right: -4px;
    font-size: 1rem;
    color: #28a745;
    background: white;
    border-radius: 50%;
  }

  /* --- Mobile Filter Panel (full-screen overlay) --- */
  .mobile-filter-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #3b4a5c;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    animation: slideInUp 0.3s ease;
  }

  @keyframes slideInUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .mobile-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #2d3a4a;
    border-bottom: 1px solid #4a5a6d;
  }

  .mobile-filter-header h6 {
    margin: 0;
    font-weight: 600;
    color: #e2e8f0;
  }

  .mobile-filter-close {
    background: #dc3545;
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-filter-options {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
  }

  .mobile-filter-option {
    display: block;
    width: 100%;
    padding: 1rem;
    background: #344254;
    border: 1px solid #4a5a6d;
    border-radius: 8px;
    color: #c0cad6;
    text-align: left;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
  }

  .mobile-filter-option.active {
    background: #1a365d;
    border-color: #5b9bd5;
    color: white;
  }

  .mobile-filter-option:hover {
    border-color: #5b9bd5;
    transform: translateY(-1px);
  }

  .mobile-filter-text-content {
    padding: 1rem;
  }

  .mobile-text-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #4a5a6d;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
    background-color: #2d3a4a;
    color: #e2e8f0;
  }

  .mobile-filter-text-actions {
    display: flex;
    gap: 1rem;
  }

  .mobile-text-clear,
  .mobile-text-apply {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
  }

  .mobile-text-clear {
    background: #6c757d;
    color: white;
  }

  .mobile-text-apply {
    background: #1a365d;
    color: white;
  }

  /* --- Mobile Loading / Empty / Alert States --- */
  .mobile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: #8a99ab;
  }

  .mobile-loading .spinner-border {
    margin-bottom: 1rem;
  }

  .mobile-alert {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin: 1rem;
    border-radius: 8px;
    color: white;
  }

  .mobile-alert-error {
    background: #dc3545;
  }

  .mobile-alert button {
    background: none;
    border: none;
    color: white;
    padding: 0.25rem;
  }

  .mobile-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: #8a99ab;
  }

  .mobile-empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #5a6878;
  }

  .mobile-empty-state h5 {
    color: #c0cad6;
    margin-bottom: 1rem;
  }

  .mobile-empty-action {
    background: #1a365d;
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    margin-top: 1rem;
  }

  /* --- Mobile Cards --- */
  .mobile-cards-container,
  .mobile-cards {
    padding: 1rem;
  }

  .mobile-card {
    background: #344254;
    border: 1px solid #4a5a6d;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  }

  .mobile-card-header {
    background: linear-gradient(135deg, #1a365d 0%, #2a4a7f 100%);
    border-bottom: 1px solid #4a5a6d;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem 0.5rem 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .mobile-card-title {
    font-weight: 600;
    color: #ffffff;
  }

  .mobile-card-body {
    padding: 1rem;
    color: #e2e8f0;
  }

  .mobile-card-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #c0cad6;
  }

  .mobile-card-row:last-child {
    margin-bottom: 0;
  }

  .mobile-card-actions {
    display: flex;
    border-top: 1px solid #4a5a6d;
  }

  .mobile-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem 0.5rem;
    background: #2d3a4a;
    border: none;
    color: #c0cad6;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-right: 1px solid #4a5a6d;
  }

  .mobile-action-btn:last-child {
    border-right: none;
  }

  .mobile-action-btn i {
    font-size: 1.2rem;
  }

  /* Action button hover colors */
  .mobile-edit-btn:hover {
    background: #1a365d;
    color: white;
  }

  .mobile-details-btn:hover {
    background: #17a2b8;
    color: white;
  }

  .mobile-permits-btn:hover {
    background: #6f42c1;
    color: white;
  }

  .mobile-activate-btn:hover {
    background: #198754;
    color: white;
  }

  .mobile-deactivate-btn:hover {
    background: #dc3545;
    color: white;
  }

  .mobile-resolve-btn:hover {
    background: #198754;
    color: white;
  }

  .mobile-unresolve-btn:hover {
    background: #dc3545;
    color: white;
  }

  /* --- Mobile Pagination --- */
  .mobile-pagination {
    padding: 1rem;
    background: #2d3a4a;
    border-top: 1px solid #4a5a6d;
    position: sticky;
    bottom: 0;
    z-index: 95;
  }

  .mobile-pagination-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #8a99ab;
  }

  .mobile-page-size {
    padding: 0.5rem;
    border: 1px solid #4a5a6d;
    border-radius: 4px;
    background: #344254;
    color: #e2e8f0;
  }

  .mobile-pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .mobile-page-btn {
    background: #1a365d;
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
  }

  .mobile-page-btn.disabled {
    background: #6c757d;
    opacity: 0.5;
  }

  .mobile-page-info {
    font-size: 0.875rem;
    color: #c0cad6;
    font-weight: 500;
  }

  /* --- Mobile Filters (simple style, e.g. PropertyReports) --- */
  .mobile-filters {
    background: #2d3a4a;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #4a5a6d;
  }

  /* --- Mobile Info Items (detail cards) --- */
  .mobile-info-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .mobile-info-item i {
    font-size: 1.2rem;
    color: #8a99ab;
    min-width: 20px;
    margin-top: 0.25rem;
  }

  .mobile-info-label {
    display: block;
    font-size: 0.75rem;
    color: #8a99ab;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
  }

  .mobile-info-value {
    display: block;
    font-size: 0.9rem;
    color: #e2e8f0;
    font-weight: 500;
  }
}

/* --------------- Responsive Confirmation Dialog --------------- */

@media (max-width: 768px) {
  .confirmation-dialog {
    width: 90%;
    max-width: 320px;
    margin: 0 1rem;
  }
}
