/* Admin Dashboard Styles */

/* CSS Variables for Admin Theme - WCAG 2.1 AA Compliant */
:root {
  --admin-sidebar-width: 260px;
  --admin-header-height: 64px;
  --admin-bg: #F5F7FA;
  --admin-sidebar-bg: #2C3E50;
  --admin-sidebar-text: #ECF0F1;
  --admin-sidebar-hover: #34495E;
  --admin-sidebar-active: #2563EB; /* Updated from #4A90E2 for contrast */
  --admin-content-bg: #FFFFFF;
  --admin-border: #E0E0E0;
  --admin-text-primary: #2C3E50; /* 12.6:1 contrast ✓ */
  --admin-text-secondary: #5A6C7D; /* 7.5:1 contrast ✓ */
  --color-success: #28A745;
  --color-error: #DC3545;
  --color-warning: #FFC107;
}

/* Admin Body */
.admin-body {
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  background-color: var(--admin-bg);
  margin: 0;
  padding: 0;
}

/* Main Container */
.admin-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: var(--admin-sidebar-width);
  background-color: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--admin-sidebar-text);
}

.logo-text {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.logo-subtitle {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 16px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  transition: background-color 0.2s;
  font-size: 15px;
}

.nav-link:hover {
  background-color: var(--admin-sidebar-hover);
}

.nav-link.active {
  background-color: var(--admin-sidebar-active);
  border-left: 4px solid #FFFFFF;
}

.nav-icon {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  flex-shrink: 0;
}

/* Main Content Area */
.admin-main {
  margin-left: var(--admin-sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Header */
.admin-header {
  background-color: var(--admin-content-bg);
  border-bottom: 1px solid var(--admin-border);
  padding: 0 24px;
  height: var(--admin-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--admin-text-primary);
}

.hamburger-icon,
.close-icon {
  width: 24px;
  height: 24px;
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-greeting {
  font-size: 14px;
  color: var(--admin-text-secondary);
}

.sign-out-btn {
  background: none;
  border: 1px solid var(--admin-border);
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--admin-text-primary);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.sign-out-btn:hover {
  background-color: var(--admin-bg);
  border-color: var(--admin-text-secondary);
}

/* Flash Messages */
.flash-notice {
  background-color: #D4EDDA;
  border: 1px solid #C3E6CB;
  color: #155724;
  padding: 12px 24px;
  margin: 16px 24px;
  border-radius: 4px;
  font-size: 16px;
}

.flash-alert {
  background-color: #F8D7DA;
  border: 1px solid #F5C6CB;
  color: #721C24;
  padding: 12px 24px;
  margin: 16px 24px;
  border-radius: 4px;
  font-size: 16px;
}

/* Main Content */
.admin-content {
  padding: 24px;
  flex: 1;
}

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

.page-title {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-size: 30px;
  font-weight: 600;
  color: var(--admin-text-primary);
  margin: 0 0 8px 0;
}

.page-subtitle {
  font-size: 16px;
  color: var(--admin-text-secondary);
  margin: 0;
}

/* Cards */
.card {
  background-color: var(--admin-content-bg);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--admin-text-primary);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--admin-border);
}

/* Tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--admin-content-bg);
  border-radius: 8px;
  overflow: hidden;
}

.admin-table thead {
  background-color: var(--admin-bg);
}

.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 15px;
  color: var(--admin-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--admin-border);
}

.admin-table td {
  padding: 16px;
  border-bottom: 1px solid var(--admin-border);
  color: var(--admin-text-primary);
  font-size: 16px;
}

.admin-table tbody tr:hover {
  background-color: var(--admin-bg);
}

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

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-new,
.status-badge.status-status_new {
  background-color: #FFF3CD;
  color: #856404;
}

.status-badge.status-contacted {
  background-color: #D1ECF1;
  color: #0C5460;
}

.status-badge.status-qualified {
  background-color: #D4EDDA;
  color: #155724;
}

.status-badge.status-converted {
  background-color: #C3E6CB;
  color: #0A3622;
}

.status-badge.status-archived {
  background-color: #E8E8E8;
  color: #5A6C7D;
}

/* Role Badges */
.role-badge.role-admin {
  background-color: #2563EB; /* Updated for WCAG contrast */
  color: #FFFFFF;
}

.role-badge.role-intake_coordinator {
  background-color: #66B892;
  color: #FFFFFF;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background-color: #2563EB; /* Updated for WCAG contrast */
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: #1E40AF; /* Updated for WCAG contrast */
}

.btn-secondary {
  background-color: #FFFFFF;
  color: var(--admin-text-primary);
  border: 1px solid var(--admin-border);
}

.btn-secondary:hover {
  background-color: var(--admin-bg);
}

.btn-link {
  background: none;
  color: #2563EB; /* Updated for WCAG contrast */
  padding: 4px 8px;
  text-decoration: underline;
}

.btn-link:hover {
  color: #1E40AF; /* Updated for WCAG contrast */
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 16px;
  color: var(--admin-text-primary);
  margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  font-size: 16px;
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #2563EB; /* Updated for WCAG contrast */
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.pagination a,
.pagination span {
  padding: 8px 12px;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--admin-text-primary);
  font-size: 16px;
}

.pagination a:hover {
  background-color: var(--admin-bg);
}

.pagination .current {
  background-color: #2563EB; /* Updated for WCAG contrast */
  color: #FFFFFF;
  border-color: #2563EB; /* Updated for WCAG contrast */
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--admin-text-secondary);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 18px;
  margin: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

  .admin-sidebar.active {
    transform: translateX(0);
  }

  .admin-main {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: block;
  }

  .admin-content {
    padding: 16px;
  }

  .user-greeting {
    display: none;
  }

  /* Stack table cells on mobile */
  .admin-table {
    border: 0;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tr {
    display: block;
    margin-bottom: 16px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
  }

  .admin-table td {
    display: block;
    text-align: right;
    padding: 12px 16px;
    border-bottom: 1px solid var(--admin-border);
  }

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

  .admin-table td::before {
    content: attr(data-label);
    float: left;
    font-weight: 600;
    color: var(--admin-text-secondary);
  }
}

/* Dashboard Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

/* Metric Cards */
.metric-card {
  background-color: var(--admin-content-bg);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 20px;
  transition: box-shadow 0.2s;
}

.metric-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.metric-card-attention {
  border-color: #FFC107;
  background-color: #FFFBF0;
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.metric-label {
  font-size: 14px;
  color: var(--admin-text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.metric-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--admin-text-primary);
  font-family: 'Poppins', sans-serif;
  line-height: 1.2;
  margin-bottom: 8px;
}

/* Metric Trends */
.metric-trend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.metric-trend.trend-up {
  color: var(--color-success);
}

.metric-trend.trend-down {
  color: var(--color-error);
}

.metric-trend.trend-neutral {
  color: var(--admin-text-secondary);
}

.metric-trend.trend-success {
  color: var(--color-success);
}

.metric-trend.trend-warning {
  color: var(--color-warning);
}

.metric-trend.trend-error {
  color: var(--color-error);
}

.metric-trend.trend-attention {
  color: #FF6B00;
}

.trend-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Status Breakdown Grid */
.status-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.status-breakdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--admin-bg);
  border-radius: 6px;
  transition: background-color 0.2s;
}

.status-breakdown-item:hover {
  background-color: #E8EDF3;
}

.status-breakdown-label {
  font-size: 14px;
  color: var(--admin-text-secondary);
  font-weight: 600;
}

.status-breakdown-count {
  font-size: 20px;
  font-weight: 700;
  color: var(--admin-text-primary);
  font-family: 'Poppins', sans-serif;
}

/* Mobile Responsive for Metrics */
@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 28px;
  }

  .status-breakdown-grid {
    grid-template-columns: 1fr;
  }
}

/* Filter UI Styles */
.filter-card {
  margin-bottom: 24px;
}

.filter-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  align-items: end;
}

.filter-row .form-group {
  margin-bottom: 0;
}

.filter-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

/* Search Input with Icon */
.search-input {
  padding-right: 40px;
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--admin-text-secondary);
  pointer-events: none;
}

/* Filter Summary */
.filter-summary {
  background-color: var(--admin-bg);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 16px 24px;
  margin-bottom: 24px;
}

.filter-summary p {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: var(--admin-text-primary);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tag {
  display: inline-block;
  background-color: #2563EB; /* Updated for WCAG contrast */
  color: #FFFFFF;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
}

/* Mobile Responsive for Filters */
@media (max-width: 768px) {
  .filter-row {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    flex-direction: column;
  }

  .filter-actions .btn {
    width: 100%;
    text-align: center;
  }
}
