/* ========================================
   Admin Management Page Styles
   ======================================== */

/* Section Layout */
.admin-section {
  margin-bottom: 2rem;
}

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

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.section-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: hsl(220 90% 56% / 0.12);
  color: hsl(220 90% 56%);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.section-badge-purple {
  background: hsl(280 70% 50% / 0.12);
  color: hsl(280 70% 50%);
}

/* Search Card */
.search-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 0.625rem;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
  border-color: hsl(var(--foreground) / 0.3);
  box-shadow: 0 0 0 3px hsl(var(--foreground) / 0.05);
}

.search-input-wrapper svg {
  color: hsl(var(--muted-foreground));
  flex-shrink: 0;
}

.search-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  color: hsl(var(--foreground));
  font-size: 0.9375rem;
  outline: none;
}

.search-input-wrapper input::placeholder {
  color: hsl(var(--muted-foreground));
}

.search-btn {
  padding: 0.5rem 1rem;
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  border: none;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.search-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Result Card */
.result-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.3s ease;
}

.result-card:hover {
  box-shadow: 0 12px 30px -10px hsl(0 0% 0% / 0.1);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--secondary) / 0.3);
}

.result-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.result-title h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.user-id-badge {
  font-size: 0.75rem;
  font-family: monospace;
  padding: 0.25rem 0.5rem;
  background: hsl(var(--secondary));
  color: hsl(var(--muted-foreground));
  border-radius: 0.375rem;
}

.btn-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-edit:hover {
  background: hsl(var(--foreground) / 0.1);
  border-color: hsl(var(--foreground) / 0.2);
}

/* Result Grid */
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: hsl(var(--border));
}

@media (max-width: 1200px) {
  .result-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.result-field {
  padding: 1rem 1.25rem;
  background: hsl(var(--card));
}

.result-field-full {
  grid-column: 1 / -1;
}

.result-field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.375rem;
}

.result-field span,
.result-field a {
  font-size: 0.9375rem;
  color: hsl(var(--foreground));
  word-break: break-all;
}

.text-preview {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.875rem !important;
  line-height: 1.5;
}

.audio-link {
  color: hsl(220 90% 56%) !important;
  text-decoration: none;
}

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

.error-text {
  color: hsl(0 84% 60%) !important;
}

/* Badges */
.plan-badge,
.role-badge,
.status-badge,
.model-badge {
  display: inline-flex;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem !important;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: capitalize;
}

.plan-badge {
  background: hsl(280 70% 50% / 0.12);
  color: hsl(280 70% 50%);
}

.role-badge {
  background: hsl(35 90% 55% / 0.12);
  color: hsl(35 90% 55%);
}

.status-badge {
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 76% 36%);
}

.status-badge.status-failed,
.status-badge.status-expired,
.status-badge.status-cancelled,
.status-badge.status-suspended,
.status-badge.status-deleted,
.status-badge.status-inactive {
  background: hsl(0 84% 60% / 0.12);
  color: hsl(0 84% 60%);
}

.status-badge.status-in_queue,
.status-badge.status-generating {
  background: hsl(35 90% 55% / 0.12);
  color: hsl(35 90% 55%);
}

.model-badge {
  background: hsl(220 90% 56% / 0.12);
  color: hsl(220 90% 56%);
}

.model-badge.model-advanced {
  background: hsl(280 70% 50% / 0.12);
  color: hsl(280 70% 50%);
}

/* Edit Modal */
.edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.edit-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.edit-modal {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  width: 90vw;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s ease;
}

.edit-modal-overlay.active .edit-modal {
  transform: scale(1) translateY(0);
}

.edit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.edit-modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.edit-modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.edit-field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.edit-field input,
.edit-field select,
.edit-field textarea {
  padding: 0.625rem 0.875rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  color: hsl(var(--foreground));
  font-size: 0.9375rem;
  transition: all 0.2s ease;
}

.edit-field input:focus,
.edit-field select:focus,
.edit-field textarea:focus {
  outline: none;
  border-color: hsl(var(--foreground) / 0.3);
  box-shadow: 0 0 0 3px hsl(var(--foreground) / 0.05);
}

.edit-field textarea {
  resize: vertical;
  min-height: 80px;
}

.edit-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--secondary) / 0.3);
}

.btn-secondary {
  padding: 0.625rem 1.25rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: hsl(var(--foreground) / 0.1);
}

.btn-primary {
  padding: 0.625rem 1.25rem;
  background: hsl(var(--foreground));
  border: none;
  color: hsl(var(--background));
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Access Denied State */
.access-denied-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 2rem;
}

.access-denied-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: hsl(0 84% 60% / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(0 84% 60%);
  margin-bottom: 1.5rem;
}

.access-denied-state h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

.access-denied-state p {
  color: hsl(var(--muted-foreground));
  margin-bottom: 1.5rem;
  max-width: 400px;
}

/* Loading State */
.search-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Affiliate Section Badge */
.section-badge-green {
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 76% 36%);
}

/* Invite Create Card */
.invite-create-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.invite-create-header {
  margin-bottom: 1.25rem;
}

.invite-create-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.25rem;
}

.invite-create-header p {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.invite-create-form .form-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .invite-create-form .form-row {
    grid-template-columns: 1fr;
  }
}

.invite-create-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.invite-create-form label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.invite-create-form input,
.invite-create-form select {
  padding: 0.625rem 0.875rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  color: hsl(var(--foreground));
  font-size: 0.9375rem;
}

.invite-create-form input:focus,
.invite-create-form select:focus {
  outline: none;
  border-color: hsl(var(--foreground) / 0.3);
  box-shadow: 0 0 0 3px hsl(var(--foreground) / 0.05);
}

.invite-create-form .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Generated Code Display */
.generated-code-display {
  margin-top: 1.25rem;
  padding: 1rem;
  background: hsl(142 76% 36% / 0.08);
  border: 1px solid hsl(142 76% 36% / 0.2);
  border-radius: 0.75rem;
}

.generated-code-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: hsl(142 76% 36%);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.generated-code-value {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.generated-code-value code {
  flex: 1;
  padding: 0.75rem 1rem;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  font-family: monospace;
  letter-spacing: 0.05em;
  color: hsl(var(--foreground));
}

.btn-copy-small {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy-small:hover {
  background: hsl(var(--foreground) / 0.1);
}

/* Table Card */
.table-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--secondary) / 0.3);
}

.table-header h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.btn-secondary-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary-sm:hover {
  background: hsl(var(--foreground) / 0.1);
}

.table-container {
  overflow-x: auto;
}

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

.admin-table th,
.admin-table td {
  padding: 0.875rem 1.25rem;
  text-align: left;
  font-size: 0.875rem;
}

.admin-table th {
  background: hsl(var(--secondary) / 0.5);
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.admin-table td {
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
}

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

.admin-table tbody tr:hover {
  background: hsl(var(--secondary) / 0.3);
}

.admin-table .empty-row td {
  text-align: center;
  color: hsl(var(--muted-foreground));
  padding: 2rem;
}

.admin-table .invite-code {
  font-family: monospace;
  font-weight: 600;
  color: hsl(220 90% 56%);
}

.admin-table .status-used {
  color: hsl(var(--muted-foreground));
}

.admin-table .status-active {
  color: hsl(142 76% 36%);
}

.admin-table .status-expired {
  color: hsl(0 84% 60%);
}
