/**
 * Tenant System — overrides on top of AdminLTE 3.2
 * @see https://github.com/ColorlibHQ/AdminLTE/releases
 */

/* Never show WP admin bar on /app/* */
body.ts-app #wpadminbar {
  display: none !important;
}

html.ts-app {
  margin-top: 0 !important;
}

body.ts-app.admin-bar {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* ——— Map legacy ts-* classes to Bootstrap / AdminLTE ——— */
.ts-content { padding: 0; }

.ts-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.ts-card {
  background: #fff;
  border-radius: 0.25rem;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.125), 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 1rem;
  padding: 1.25rem;
  border: 0;
}

.ts-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.ts-muted { color: #6c757d; }

.ts-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .ts-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .ts-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .ts-grid--4 { grid-template-columns: repeat(4, 1fr); }
}

.ts-stat {
  font-size: 2rem;
  font-weight: 700;
  color: #007bff;
}

/* Buttons */
.ts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  border-radius: 0.25rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.ts-btn--primary {
  color: #fff;
  background-color: #007bff;
  border-color: #007bff;
}

.ts-btn--primary:hover {
  color: #fff;
  background-color: #0069d9;
  border-color: #0062cc;
}

.ts-btn--ghost {
  color: #343a40;
  background-color: #fff;
  border-color: #ced4da;
}

.ts-btn--ghost:hover {
  background-color: #f8f9fa;
}

.ts-btn--danger {
  color: #fff;
  background-color: #dc3545;
  border-color: #dc3545;
}

.ts-btn--sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

.ts-btn--block { width: 100%; }

/* Forms */
.ts-input,
.ts-form .ts-input {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #495057;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
}

.ts-input:focus {
  border-color: #80bdff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.ts-field { margin-bottom: 1rem; }
.ts-field label { display: block; margin-bottom: 0.25rem; font-weight: 500; }
.ts-field--checkbox label { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; }

.ts-form__error { color: #dc3545; font-size: 0.875rem; }
.ts-form__success { color: #28a745; font-size: 0.875rem; }
.ts-hint { font-size: 0.8125rem; color: #6c757d; }

/* Tables */
.ts-table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 0.25rem;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.125), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ts-table {
  width: 100%;
  margin-bottom: 0;
  color: #212529;
  border-collapse: collapse;
}

.ts-table th,
.ts-table td {
  padding: 0.75rem;
  vertical-align: top;
  border-top: 1px solid #dee2e6;
}

.ts-table thead th {
  vertical-align: bottom;
  border-bottom: 2px solid #dee2e6;
  background: #f8f9fa;
  font-weight: 600;
}

.ts-table--compact th,
.ts-table--compact td { padding: 0.4rem 0.5rem; }

/* Badges */
.ts-badge {
  display: inline-block;
  padding: 0.25em 0.6em;
  font-size: 75%;
  font-weight: 600;
  line-height: 1;
  border-radius: 0.25rem;
}

.ts-badge--pending { color: #856404; background-color: #fff3cd; }
.ts-badge--approved,
.ts-badge--paid,
.ts-badge--occupied { color: #155724; background-color: #d4edda; }
.ts-badge--rejected,
.ts-badge--unpaid { color: #721c24; background-color: #f8d7da; }
.ts-badge--partial { color: #856404; background-color: #fff3cd; }
.ts-badge--vacant { color: #004085; background-color: #cce5ff; }
.ts-badge--archived { color: #383d41; background-color: #e2e3e5; }

/* Tabs */
.ts-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.ts-tab {
  padding: 0.5rem 1rem;
  border: 1px solid #dee2e6;
  background: #fff;
  border-radius: 0.25rem;
  cursor: pointer;
}
.ts-tab--active {
  color: #fff;
  background-color: #007bff;
  border-color: #007bff;
}

.ts-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: flex-end;
}

.ts-filters .ts-input {
  width: auto;
  min-width: 140px;
  max-width: 200px;
}

.ts-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ts-page-header .ts-title { margin: 0; flex: 1; }

.ts-actions { display: flex; gap: 0.25rem; flex-wrap: wrap; }

/* Meter / dropzone */
.ts-meter {
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #f8f9fa;
}

.ts-meter__title { font-weight: 600; margin-bottom: 0.5rem; }

.ts-dropzone {
  border: 2px dashed #ced4da;
  border-radius: 0.25rem;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  background: #fff;
}

.ts-dropzone:hover,
.ts-dropzone.is-dragover {
  border-color: #007bff;
  background: #e7f1ff;
}

/* Modals (native dialog) */
.ts-modal {
  border: none;
  border-radius: 0.3rem;
  padding: 0;
  max-width: 500px;
  width: calc(100% - 2rem);
}

.ts-modal--wide { max-width: 640px; }

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

.ts-modal__form { padding: 1.25rem; }
.ts-modal__title { margin: 0 0 1rem; font-size: 1.25rem; font-weight: 600; }

.ts-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.ts-alert {
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: 0.25rem;
}

.ts-alert--success {
  color: #155724;
  background-color: #d4edda;
  border-color: #c3e6cb;
}

.ts-subtitle { font-size: 1rem; font-weight: 600; margin: 1rem 0 0.5rem; }
.ts-divider { border: 0; border-top: 1px solid #dee2e6; margin: 1.25rem 0; }

/* Hide duplicate page title in content when shown in header */
.content-header #ts-page-title:empty { display: none; }

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

/* Login */
.login-page .login-box { width: 400px; max-width: 96vw; }

.login-page .card-primary.card-outline {
  border-top: 3px solid #007bff;
}

/* Responsive tables on mobile */
@media (max-width: 767.98px) {
  .ts-filters .ts-input {
    width: 100%;
    max-width: none;
  }

  .content-header h1#ts-page-title {
    font-size: 1.25rem;
  }
}
