/**
 * Admin Panel Enhancements
 * Professional admin interface styling and functionality
 */

/* ============================================
   TYPOGRAPHY - ADMIN FONTS
   ============================================ */
/* Ensure all admin components use selected fonts */
.admin-layout,
.admin-layout *,
.admin-card,
.admin-card *,
.admin-table,
.admin-form,
.admin-btn,
admin-layout [class*="admin-"] {
  font-family: var(--font-body, var(--chakra-fonts-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif));
}

/* Admin headings use heading font */
.admin-card h1,
.admin-card h2,
.admin-card h3,
.admin-card h4,
.admin-card h5,
.admin-card h6,
.admin-modal h1,
.admin-modal h2,
.admin-modal h3 {
  font-family: var(--font-heading, var(--chakra-fonts-heading, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif)) !important;
}

/* ============================================
   ADMIN LAYOUT IMPROVEMENTS
   ============================================ */
.admin-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-main {
  flex: 1;
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================
   ADMIN CARDS & CONTAINERS
   ============================================ */
.admin-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow 0.3s ease;
}

.admin-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.chakra-ui-dark .admin-card {
  background: #1a1d29;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  color: #e2e8f0;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}

.chakra-ui-dark .admin-card-header {
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

/* ============================================
   ADMIN DATA TABLES
   ============================================ */
.admin-table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: white;
}

.chakra-ui-dark .admin-table-wrapper {
  border-color: rgba(255, 255, 255, 0.12);
  background: #1a1d29;
}

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

.admin-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f8f9fa;
}

.chakra-ui-dark .admin-table thead {
  background: #2d3748;
}

.admin-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #4a5568;
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  white-space: nowrap;
  font-family: var(--font-heading, var(--chakra-fonts-heading, sans-serif));
}

.chakra-ui-dark .admin-table th {
  color: #a0aec0;
  border-bottom-color: rgba(255, 255, 255, 0.12);
}

.admin-table td {
  padding: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  vertical-align: middle;
}

.chakra-ui-dark .admin-table td {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.admin-table tbody tr {
  transition: background-color 0.2s ease;
}

.admin-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.chakra-ui-dark .admin-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.admin-table tbody tr.selected {
  background-color: rgba(var(--primary-rgb, 197, 48, 48), 0.08);
}

.admin-table tbody tr:focus-within {
  outline: 2px solid var(--primary, #C53030);
  outline-offset: -2px;
}

/* ============================================
   ADMIN TABLE ACTIONS
   ============================================ */
.admin-table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.admin-table-action-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: white;
  cursor: pointer;
}

.admin-table-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.admin-table-action-btn:focus-visible {
  outline: 2px solid var(--primary, #C53030);
  outline-offset: 2px;
}

/* ============================================
   ADMIN FORMS
   ============================================ */
.admin-form {
  display: grid;
  gap: 20px;
}

.admin-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #2d3748;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body, var(--chakra-fonts-body, sans-serif));
}

.chakra-ui-dark .admin-form-label {
  color: #e2e8f0;
}

.admin-form-label.required::after {
  content: '*';
  color: #e53e3e;
  font-weight: bold;
}

.admin-form-input {
  padding: 10px 14px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  background: white;
}

.chakra-ui-dark .admin-form-input {
  background: #2d3748;
  border-color: rgba(255, 255, 255, 0.12);
  color: white;
}

.admin-form-input:focus {
  border-color: var(--primary, #C53030);
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 197, 48, 48), 0.1);
}

.admin-form-input.error {
  border-color: #e53e3e;
}

.admin-form-error {
  color: #e53e3e;
  font-size: 0.875rem;
  margin-top: 4px;
}

.admin-form-help {
  color: #718096;
  font-size: 0.875rem;
  margin-top: 4px;
}

/* ============================================
   ADMIN BUTTONS
   ============================================ */
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.admin-btn:focus-visible {
  outline: 3px solid var(--primary, #C53030);
  outline-offset: 2px;
}

.admin-btn-primary {
  background: linear-gradient(135deg, var(--primary, #C53030), #9b2c2c);
  color: white;
  box-shadow: 0 2px 6px rgba(197, 48, 48, 0.3);
}

.admin-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(197, 48, 48, 0.4);
}

.admin-btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

.admin-btn-secondary:hover {
  background: #cbd5e0;
  transform: translateY(-1px);
}

.admin-btn-success {
  background: #48bb78;
  color: white;
}

.admin-btn-success:hover {
  background: #38a169;
  transform: translateY(-1px);
}

.admin-btn-danger {
  background: #e53e3e;
  color: white;
}

.admin-btn-danger:hover {
  background: #c53030;
  transform: translateY(-1px);
}

.admin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================
   ADMIN STATS CARDS
   ============================================ */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.admin-stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  border-left: 4px solid var(--primary, #C53030);
}

.chakra-ui-dark .admin-stat-card {
  background: #1a1d29;
}

.admin-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.admin-stat-label {
  font-size: 0.875rem;
  color: #718096;
  font-weight: 500;
  margin-bottom: 8px;
}

.admin-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #2d3748;
  line-height: 1;
  font-family: var(--font-heading, var(--chakra-fonts-heading, sans-serif));
}

.chakra-ui-dark .admin-stat-value {
  color: #e2e8f0;
}

.admin-stat-trend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.875rem;
}

.admin-stat-trend.positive {
  color: #48bb78;
}

.admin-stat-trend.negative {
  color: #e53e3e;
}

/* ============================================
   ADMIN FILTERS & SEARCH
   ============================================ */
.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.chakra-ui-dark .admin-filters {
  background: #2d3748;
}

.admin-search-box {
  flex: 1;
  min-width: 280px;
  position: relative;
}

.admin-search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 0.9375rem;
  transition: all 0.2s ease;
}

.admin-search-input:focus {
  border-color: var(--primary, #C53030);
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 197, 48, 48), 0.1);
}

.admin-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #718096;
  pointer-events: none;
}

/* ============================================
   ADMIN BADGES & TAGS
   ============================================ */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
}

.admin-badge-success {
  background: #c6f6d5;
  color: #22543d;
}

.admin-badge-warning {
  background: #fef3c7;
  color: #78350f;
}

.admin-badge-danger {
  background: #fed7d7;
  color: #742a2a;
}

.admin-badge-info {
  background: #bee3f8;
  color: #2c5282;
}

.admin-badge-default {
  background: #e2e8f0;
  color: #2d3748;
}

/* ============================================
   ADMIN PAGINATION
   ============================================ */
.admin-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.chakra-ui-dark .admin-pagination {
  background: #2d3748;
}

.admin-pagination-info {
  font-size: 0.875rem;
  color: #718096;
}

.admin-pagination-controls {
  display: flex;
  gap: 8px;
}

.admin-pagination-btn {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.chakra-ui-dark .admin-pagination-btn {
  background: #1a1d29;
  border-color: rgba(255, 255, 255, 0.12);
}

.admin-pagination-btn:hover:not(:disabled) {
  background: var(--primary, #C53030);
  color: white;
  transform: translateY(-1px);
}

.admin-pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.admin-pagination-btn.active {
  background: var(--primary, #C53030);
  color: white;
  border-color: var(--primary, #C53030);
}

/* ============================================
   ADMIN LOADING STATES
   ============================================ */
.admin-skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 0%,
    #e8e8e8 50%,
    #f0f0f0 100%
  );
  background-size: 200% 100%;
  animation: adminShimmer 1.5s infinite;
  border-radius: 6px;
}

.chakra-ui-dark .admin-skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
}

@keyframes adminShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.admin-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary, #C53030);
  border-radius: 50%;
  animation: adminSpin 0.8s linear infinite;
}

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

/* ============================================
   ADMIN ALERTS & NOTIFICATIONS
   ============================================ */
.admin-alert {
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: start;
  gap: 12px;
  border-left: 4px solid;
}

.admin-alert-success {
  background: #c6f6d5;
  border-color: #48bb78;
  color: #22543d;
}

.admin-alert-warning {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f;
}

.admin-alert-danger {
  background: #fed7d7;
  border-color: #e53e3e;
  color: #742a2a;
}

.admin-alert-info {
  background: #bee3f8;
  border-color: #3b82f6;
  color: #2c5282;
}

/* ============================================
   ADMIN MODAL ENHANCEMENTS
   ============================================ */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  animation: adminFadeIn 0.2s ease;
}

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

.admin-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
  z-index: 10000;
  animation: adminSlideUp 0.3s ease;
}

@keyframes adminSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.chakra-ui-dark .admin-modal {
  background: #1a1d29;
}

/* ============================================
   ADMIN BULK ACTIONS
   ============================================ */
.admin-bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #edf2f7;
  border-radius: 8px;
  margin-bottom: 16px;
  animation: adminSlideDown 0.3s ease;
}

@keyframes adminSlideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chakra-ui-dark .admin-bulk-actions {
  background: #2d3748;
}

.admin-bulk-count {
  font-weight: 600;
  color: var(--primary, #C53030);
}

/* ============================================
   ADMIN DRAG & DROP
   ============================================ */
.admin-dropzone {
  border: 2px dashed rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.admin-dropzone:hover,
.admin-dropzone.active {
  border-color: var(--primary, #C53030);
  background: rgba(var(--primary-rgb, 197, 48, 48), 0.05);
}

.admin-dropzone.dragging {
  border-color: #48bb78;
  background: rgba(72, 187, 120, 0.05);
  transform: scale(1.02);
}

/* ============================================
   RESPONSIVE ADMIN DESIGN
   ============================================ */
@media (max-width: 768px) {
  .admin-main {
    padding: 16px;
  }
  
  .admin-card {
    padding: 16px;
  }
  
  .admin-table-wrapper {
    font-size: 0.875rem;
  }
  
  .admin-table th,
  .admin-table td {
    padding: 12px 8px;
  }
  
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
  
  .admin-filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .admin-search-box {
    width: 100%;
    min-width: 0;
  }
  
  .admin-pagination {
    flex-direction: column;
    gap: 12px;
  }
}

/* ============================================
   ADMIN KEYBOARD SHORTCUTS INDICATOR
   ============================================ */
.admin-shortcut-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: #e2e8f0;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
  color: #4a5568;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.chakra-ui-dark .admin-shortcut-hint {
  background: #2d3748;
  color: #a0aec0;
}
