/*
 * JetLegal Styles
 */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  text-decoration: none;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  gap: 24px;
}

.nav-link {
  color: var(--gray-700);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--gray-100);
  color: var(--primary);
}

/* Main Content */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Page Header */
.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--gray-900);
}

.page-subtitle {
  color: var(--gray-500);
  margin-top: 4px;
}

/* Table */
.table-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-link {
  color: var(--primary);
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge.issued {
  background: #dcfce7;
  color: #166534;
}

.status-badge.terminated {
  background: #fee2e2;
  color: #991b1b;
}

.status-badge.repaid {
  background: #dbeafe;
  color: #1e40af;
}

/* Pagination */
.pagination-container {
  padding: 16px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: center;
}

.pagy {
  display: flex;
  gap: 4px;
  list-style: none;
}

.pagy a, .pagy span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--gray-700);
  background: white;
  border: 1px solid var(--gray-200);
  transition: all 0.15s;
}

.pagy a:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.pagy .current {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.pagy .disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Filters */
.filters-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 24px;
}

.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}


.filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

.filter-input,
.filter-select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--gray-700);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

/* Tom Select Overrides */
.ts-wrapper {
  min-width: 180px;
}

/* When Tom Select is active, override filter-select styles on wrapper */
.ts-wrapper.filter-select {
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
}

.ts-wrapper.multi .ts-control {
  min-height: 40px;
  padding: 4px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ts-control {
  border: 1px solid var(--gray-200) !important;
  border-radius: 6px !important;
  background: white !important;
}

.ts-control:focus,
.ts-wrapper.focus .ts-control {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

.ts-control input {
  min-width: 60px;
}

.ts-dropdown {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-top: 4px;
}

.ts-dropdown .option {
  padding: 8px 12px;
}

.ts-dropdown .option.active {
  background: var(--primary);
  color: white;
}

.ts-wrapper.multi .ts-control > .item {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 2px 6px;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

.ts-wrapper.multi .ts-control > .item .remove {
  color: white;
  border-left: 1px solid rgba(255,255,255,0.3);
  margin-left: 6px;
  padding-left: 6px;
}

.ts-wrapper.multi .ts-control > .item .remove:hover {
  background: transparent;
  color: white;
}

/* Show Page Styles */
.page-header-top {
  margin-bottom: 16px;
}

.back-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.back-link:hover {
  text-decoration: underline;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.detail-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 24px;
}

.detail-card.full-width {
  grid-column: 1 / -1;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.detail-row dt {
  font-size: 0.875rem;
  color: var(--gray-500);
  font-weight: 500;
}

.detail-row dd {
  font-size: 0.875rem;
  color: var(--gray-900);
  text-align: right;
  max-width: 60%;
}

.no-data {
  color: var(--gray-500);
  font-size: 0.875rem;
  font-style: italic;
}

.active-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: #dcfce7;
  color: #166534;
}

.inactive-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: var(--gray-100);
  color: var(--gray-500);
}

@media (max-width: 768px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Main Content Full (no header) */
.main-content-full {
  min-height: 100vh;
}

/* Auth Styles */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo .logo {
  font-size: 2rem;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 1rem;
  color: var(--gray-900);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-form .form-actions {
  margin-top: 8px;
}

.auth-form .btn {
  width: 100%;
  height: 44px;
}

.auth-links {
  margin-top: 20px;
  text-align: center;
  font-size: 0.875rem;
}

.auth-links a {
  color: var(--primary);
  text-decoration: none;
}

.auth-links a:hover {
  text-decoration: underline;
}

.auth-links .separator {
  color: var(--gray-300);
  margin: 0 8px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Logout Button */
.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--gray-500);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.logout-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}
