/* ===================================
   ADMIN DASHBOARD - MODERN UI
   =================================== */

/* Admin Wrapper */
.admin-wrapper {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-padding);
  padding-right: var(--container-padding);
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Page Header */
.admin-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.admin-title-section h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.admin-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.admin-header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Statistics Grid */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.stat-card:hover::before {
  transform: scaleX(1);
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.stat-card-title {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.1));
}

.stat-card-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--color-primary);
}

.stat-card-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.stat-card-change {
  font-size: 0.85rem;
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-card-change.negative {
  color: var(--color-destructive);
}

/* Threshold Section Header */
.threshold-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.threshold-section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
}

.threshold-section-actions {
  display: flex;
  gap: 0.75rem;
}

/* Category Tabs */
.category-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow-x: auto;
  flex-wrap: wrap;
}

.category-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.category-tab svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.category-tab:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.category-tab:hover svg {
  opacity: 1;
}

.category-tab.active {
  background: linear-gradient(135deg, var(--color-primary) 0%, #0056b3 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.25);
}

.category-tab.active svg {
  opacity: 1;
}

/* Search and Filter Bar */
.threshold-toolbar {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.threshold-search {
  flex: 1;
  position: relative;
}

.threshold-search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
}

.threshold-search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 3rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.threshold-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.threshold-filter-select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--color-background);
  cursor: pointer;
  transition: all 0.3s ease;
}

.threshold-filter-select:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Threshold Grid */
.threshold-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1.5rem;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Threshold Card */
.threshold-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.threshold-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-primary);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.threshold-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--color-primary);
}

.threshold-card:hover::before {
  transform: scaleY(1);
}

.threshold-card.has-critical::before {
  background: var(--color-destructive);
}

/* Threshold Card Header */
.threshold-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.threshold-card-name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.threshold-card-unit {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.threshold-card-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.threshold-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.threshold-badge.critical {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-destructive);
}

.threshold-badge.gender {
  background: rgba(139, 92, 246, 0.1);
  color: var(--color-accent);
}

.threshold-badge.age {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-primary);
}

/* Threshold Card Details */
.threshold-card-details {
  margin-bottom: 1rem;
}

.threshold-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.threshold-detail-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.threshold-detail-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.threshold-detail-value.critical-value {
  color: var(--color-destructive);
}

/* Threshold Card Footer */
.threshold-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.threshold-last-updated {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.threshold-last-updated svg {
  width: 14px;
  height: 14px;
}

.threshold-card-actions {
  display: flex;
  gap: 0.5rem;
}

.threshold-action-btn {
  padding: 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.threshold-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.threshold-action-btn.edit:hover {
  color: var(--color-primary);
  background: rgba(59, 130, 246, 0.1);
}

.threshold-action-btn.delete:hover {
  color: var(--color-destructive);
  background: rgba(239, 68, 68, 0.1);
}

.threshold-action-btn svg {
  width: 18px;
  height: 18px;
}

/* Empty State */
.threshold-empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--color-card);
  border: 2px dashed var(--color-border);
  border-radius: 16px;
  margin-top: 2rem;
}

.threshold-empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  opacity: 0.3;
}

.threshold-empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.threshold-empty-text {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

/* Modal Overlay */
.threshold-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.3s ease-out;
}

.threshold-modal-overlay.hidden {
  display: none;
}

/* Modal */
.threshold-modal {
  background: var(--color-card);
  border-radius: 20px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s ease-out;
  position: relative;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.threshold-modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
}

.threshold-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.threshold-modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.threshold-modal-close svg {
  width: 20px;
  height: 20px;
}

.threshold-modal-body {
  padding: 2rem;
}

.threshold-modal-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Form Sections */
.threshold-form-section {
  margin-bottom: 2rem;
}

.threshold-form-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
}

.threshold-form-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.threshold-form-section-toggle {
  transition: transform 0.3s ease;
}

.threshold-form-section-toggle.expanded {
  transform: rotate(180deg);
}

.threshold-form-section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.threshold-form-section-content.expanded {
  max-height: 2000px;
}

.threshold-form-section-content.always-open {
  max-height: none;
}

/* Form Fields */
.threshold-form-field {
  margin-bottom: 1.5rem;
}

.threshold-form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.threshold-form-label.required::after {
  content: ' *';
  color: var(--color-destructive);
}

.threshold-form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.threshold-form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.threshold-form-input.error {
  border-color: var(--color-destructive);
}

.threshold-form-error {
  font-size: 0.85rem;
  color: var(--color-destructive);
  margin-top: 0.25rem;
}

.threshold-form-help {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.threshold-form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

/* Loading State */
.threshold-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4rem 2rem;
}

.threshold-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 1024px) {
  .threshold-grid {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  }
}

@media (max-width: 768px) {
  .admin-wrapper {
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
  }

  .admin-page-header {
    flex-direction: column;
    gap: 1rem;
  }

  .admin-stats-grid {
    grid-template-columns: 1fr;
  }

  .threshold-toolbar {
    flex-direction: column;
  }

  .threshold-grid {
    grid-template-columns: 1fr;
  }

  .threshold-form-row {
    grid-template-columns: 1fr;
  }

  .threshold-modal {
    max-width: 100%;
    border-radius: 12px;
  }
}

/* Delete Confirmation Modal */
.delete-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  animation: fadeIn 0.2s ease;
}

.delete-modal-overlay.hidden {
  display: none;
}

.delete-modal {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 450px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.delete-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.delete-modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.delete-modal-message {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.delete-modal-message strong {
  color: var(--text-primary);
  font-weight: 600;
}

.delete-modal-warning {
  font-size: 0.875rem;
  color: #EF4444;
  margin-bottom: 2rem;
  font-weight: 500;
}

.delete-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.delete-modal-actions .btn {
  flex: 1;
  max-width: 180px;
}

.btn-danger {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

@media (min-width: 1024px) {
  .admin-wrapper {
    padding-left: var(--spacing-2xl);
    padding-right: var(--spacing-2xl);
  }
}

@media (min-width: 1280px) {
  .admin-wrapper {
    padding-left: var(--spacing-3xl);
    padding-right: var(--spacing-3xl);
  }
}

