/*
 * The Title of the code block must be the exact filename (e.g., setup.php). 
 * Then the title should end with .php to get setup.php. 
 * File path must include the folder (e.g., gallery/setup.php).
 *
 * Filename: archive-profile.css
 * File path: css/archive-profile.css
*/
/* ============================================================

   archive-profile.css - Modern Profile Archive

   Updated: Large Fonts & 80% Column Width

   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  /* New gradient used for active filters button in JS */
  --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --star-color: #fbbf24;

  --success-color: #10b981;

  --bg-gradient: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);

  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

  --card-shadow-hover: 0 20px 40px rgba(99, 102, 241, 0.15);

  --glass-bg: rgba(255, 255, 255, 0.95);

  --border-radius: 14px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  --header-bg: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.05) 0%,
    rgba(139, 92, 246, 0.05) 100%
  );

  /* Text Colors for Readability */

  --text-main: #111827; /* Near Black */

  --text-secondary: #374151; /* Dark Gray */

  --text-muted: #6b7280; /* Medium Gray */

  /* Buttons */
  --btn-primary: var(--primary-gradient);
  --btn-reset-color: var(--text-muted);
}

/* ============================================================
 * BASE STYLES & LAYOUT
 * ============================================================ */

.profile-archive-main {
  background: var(--bg-gradient);

  padding: 20px 0;

  min-height: 80vh;

  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;

  color: var(--text-main);
}

.archive-container {
  max-width: 1320px;

  margin: 0 auto;

  padding: 0 20px;
}

.archive-header {
  text-align: center;

  margin-bottom: 6px;
}

.archive-header-top {
  display: flex;

  justify-content: space-between;

  align-items: flex-start;

  gap: 8px;

  flex-wrap: wrap;
}

.archive-header-content {
  flex: 1;
  text-align: left;
}

.header-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 2px;
  width: 100%;
}

.archive-title {
  font-size: 2.6rem !important;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0; 
  padding-left: 12px; /* Increased left padding */
  letter-spacing: -0.5px;
}

.archive-subtitle {
  font-size: 1.5rem; /* Increased font size */
  margin-top: 0;
  margin-bottom: 0; /* Ensure no bottom margin */
  padding-bottom: 0; /* Reduce bottom padding */
  color: var(--text-secondary);
  text-align: left; 
  padding-left: 12px; /* Match title padding */
  font-weight: 500;
  line-height: 1.2;
}

.btn-add-profile {
  display: inline-flex;

  align-items: center;

  gap: 8px;

  padding: 8px 16px; /* Reduced horizontal padding to reduce width */
  margin-right: 5px; /* Small padding on right (margin to edge) */
  background: var(--primary-gradient);

  color: white;

  text-decoration: none;

  border-radius: 25px;

  font-size: 0.9rem;

  font-weight: 600;

  transition: var(--transition);

  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);

  white-space: nowrap;
}

.btn-add-profile:hover {
  transform: translateY(-2px);

  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-add-profile svg {
  flex-shrink: 0;
}

/* Responsive layout for mobile */
@media (max-width: 768px) {
  .archive-header-top {
    flex-direction: row; /* Keep row layout */
    align-items: center;
    justify-content: space-between;
  }

  .archive-header-content {
    text-align: left; /* Force left align */
    width: auto;
    flex: 1;
  }

  .btn-add-profile {
    align-self: flex-start;
  }
}

/* --- FILTER SECTION --- */

.filter-section {
  margin-bottom: 20px;

  background: #ffffff;

  border-radius: var(--border-radius);

  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);

  overflow: hidden;

  border: 1px solid #e6e8ec;

  position: -webkit-sticky; /* Safari */
  position: sticky;
  top: 60px; /* Adjust based on header height */
  z-index: 99;
}

.filter-top-bar {
  padding: 12px 20px;

  display: flex;

  justify-content: space-between;

  align-items: center;

  background: transparent;

  border-bottom: none;

  min-height: 60px;

  box-sizing: border-box;
}

.filter-toggle-btn {
  background: var(--primary-gradient);

  color: white;

  border: none;

  padding: 8px 20px;

  border-radius: 25px;

  cursor: pointer;

  font-weight: 600;

  font-size: 0.9rem;

  display: flex;

  align-items: center;

  gap: 8px;

  transition: var(--transition);

  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);

  z-index: 5;
}

.filter-toggle-btn:hover {
  transform: translateY(-2px);

  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

.result-count {
  color: var(--text-secondary);

  font-size: 0.95rem;

  font-weight: 700;

  transition: opacity 0.2s;
}

.filter-panel {
  display: block; /* Always open per user request */

  padding: 16px 20px;

  background: white;
}

.filter-panel.open {
  display: block;

  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-scroll-row {
  display: flex;

  gap: 0;

  overflow-x: auto;

  padding-bottom: 0; /* Changed from 10px to 0 to remove gap */

  scrollbar-width: thin;

  scrollbar-color: #6366f1 #f3f4f6;

  flex-wrap: nowrap;

  align-items: flex-start;
}

.filter-scroll-row::-webkit-scrollbar {
  height: 8px;
}

.filter-scroll-row::-webkit-scrollbar-thumb {
  background: var(--primary-gradient);

  border-radius: 4px;
}

.filter-col {
  min-width: 280px;

  max-width: 320px;

  flex-shrink: 0;

  border-right: 1px solid #e5e7eb;

  padding: 0 16px;

  display: flex;

  flex-direction: column;

  gap: 12px;
}

.filter-col:first-child {
  padding-left: 0;
}

.filter-col:last-child {
  border: none;

  padding-right: 0;
}

.filter-group {
  display: flex;

  flex-direction: column;

  gap: 4px;

  width: 100%;
}

.field-label {
  font-size: 0.8rem;

  font-weight: 700;

  text-transform: uppercase;

  color: var(--text-secondary);

  letter-spacing: 0.5px;

  margin-bottom: 4px;

  display: block;
}

/* Style for hidden filter wrappers */
.hidden-filter {
  display: none !important;
}

/* --- FORM ELEMENTS --- */

.filter-input,
.filter-select {
  width: 100% !important;

  max-width: 100% !important;

  padding: 10px 14px; /* Increased padding slightly */

  border: 2px solid #e5e7eb;

  border-radius: 8px;

  font-size: 0.95rem;

  color: var(--text-main);

  background: white;

  transition: var(--transition);

  box-sizing: border-box;

  font-family: "Inter", sans-serif;

  font-weight: 500;

  line-height: 1.5;

  min-height: 44px; /* Increased height back slightly for touch targets */

  display: block;
}

.filter-select {
  cursor: pointer;

  appearance: none;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23374151' d='M7 10L2 5h10z'/%3E%3C/svg%3E");

  background-repeat: no-repeat;

  background-position: right 12px center;

  padding-right: 36px;
}

.filter-select option {
  font-size: 0.95rem;

  padding: 8px;

  color: var(--text-main);

  font-weight: 500;

  line-height: 1.5;

  background: white;
}

.filter-input::placeholder {
  color: var(--text-muted);

  font-size: 0.95rem; /* Larger placeholder */

  font-weight: 400;
}

.filter-input:focus,
.filter-select:focus,
.logic-select:focus {
  /* Added .logic-select */

  border-color: #6366f1;

  outline: none;

  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-input:hover,
.filter-select:hover,
.logic-select:hover {
  /* Added .logic-select */

  border-color: #d1d5db;
}

.range-group {
  display: flex; /* Changed from block to flex to align min/max inputs inline */
  gap: 8px; /* Added spacing between min/max inputs */

  width: 100%;
}

.range-group .filter-input {
  flex-grow: 1; /* Allows inputs to fill available space evenly */
  width: auto !important; /* Override inline styles */
  max-width: 50% !important;
  display: block;
}

/* Added separation span for visual clarity in range group */
.range-group .range-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.2rem;
  font-weight: 300;
  min-width: 10px;
}

/* --- CHECKBOXES & SCROLL BOXES --- */

.checkbox-scroll-box {
  height: 140px; /* Restored height for larger text */

  overflow-y: auto;

  border: 2px solid #e5e7eb;

  padding: 8px;

  border-radius: 8px;

  background: #ffffff;

  scrollbar-width: thin;

  width: 100%;

  box-sizing: border-box;
}

.checkbox-scroll-box::-webkit-scrollbar {
  width: 6px;
}

.checkbox-scroll-box::-webkit-scrollbar-thumb {
  background: var(--primary-gradient);

  border-radius: 3px;
}

.checkbox-item {
  font-size: 0.95rem; /* Increased size */

  color: var(--text-secondary);

  display: flex;

  align-items: center;

  gap: 10px;

  margin-bottom: 8px;

  cursor: pointer;

  padding: 6px 6px; /* Larger touch target */

  border-radius: 5px;

  transition: var(--transition);
}

.checkbox-item:hover {
  background: white;
}

.checkbox-item input[type="checkbox"] {
  width: 18px; /* Larger checkbox */

  height: 18px;

  accent-color: #6366f1;

  cursor: pointer;

  flex-shrink: 0;
}

/* --- TOGGLE SWITCHES --- */

.toggle-switch {
  display: flex;

  align-items: center;

  justify-content: space-between;

  cursor: pointer;

  user-select: none;

  font-size: 0.95rem; /* Increased size */

  color: var(--text-secondary);

  padding: 8px 10px;

  border-radius: 7px;

  transition: var(--transition);

  font-weight: 500;

  margin-bottom: 4px;

  width: 100%;

  box-sizing: border-box;
}

.toggle-switch:hover {
  background: #f9fafb;
}

.toggle-slider {
  width: 44px;

  height: 24px;

  background-color: #d1d5db;

  border-radius: 24px;

  position: relative;

  transition: var(--transition);

  margin-left: 10px;

  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.1);

  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";

  position: absolute;

  top: 2px;

  left: 2px;

  width: 20px;

  height: 20px;

  background-color: white;

  border-radius: 50%;

  transition: var(--transition);

  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .toggle-slider {
  background: var(--primary-gradient);

  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

.toggle-switch.active .toggle-slider::after {
  transform: translateX(20px);
}

/* --- LOGIC SELECTOR (AND/OR) --- */

.logic-select {
  font-size: 0.9rem; /* Increased size */

  padding: 6px 10px;

  margin-bottom: 4px;

  border: 2px solid #e5e7eb;

  border-radius: 6px;

  background: white;

  color: var(--text-secondary);

  width: auto;

  font-weight: 600;

  font-family: "Inter", sans-serif;

  /* Ensure consistency with filter-select styling for dropdown arrow */
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23374151' d='M7 10L2 5h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
  cursor: pointer;
  line-height: 1.5;
}

/* --- INFO ICON AND DETAILS --- */

.info-icon {
  display: inline-flex;

  align-items: center;

  justify-content: center;

  width: 18px;

  height: 18px;

  border-radius: 50%;

  background: rgba(99, 102, 241, 0.1);

  color: #6366f1;

  font-size: 11px;

  font-weight: bold;

  cursor: pointer;

  transition: var(--transition);
}

.info-icon:hover {
  background: var(--primary-gradient);

  color: white;
}

.info-details {
  display: none;

  margin-bottom: 6px;

  padding: 8px;

  background: rgba(99, 102, 241, 0.05);

  border-left: 3px solid #6366f1;

  border-radius: 5px;

  font-size: 0.9rem;

  color: var(--text-secondary);

  line-height: 1.5;
}

.info-details.show {
  display: block;
}

/* --- FILTER ACTIONS (APPLY/RESET BUTTONS) --- */

.filter-actions {
  display: flex;

  justify-content: flex-end;

  gap: 12px;

  transition: var(--transition);
}

.filter-actions .btn-apply {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  padding: 8px 20px;
  border-radius: 25px;
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-actions .btn-apply:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

.filter-actions .btn-reset {
  border: 2px solid #e5e7eb;
  padding: 8px 20px;
  border-radius: 25px;
  background: #fff;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex; /* Ensure vertical centering if it's an anchor */
  align-items: center;
  justify-content: center;
}

.filter-actions .btn-reset:hover {
  background: #f9fafb;
  color: #111827;
  border-color: #d1d5db;
}

/* ============================================================

   MOBILE OPTIMIZATION (Max Width 1024px)

   ============================================================ */

@media (max-width: 1024px) {
  .archive-container {
      padding: 0 !important;
      margin: 0 !important;
  }
  
  /* Make filter sticky on mobile */
  .filter-section {
      position: sticky;
      top: 75px; /* Safe offset for mobile header */
      z-index: 99;
      background: white; /* Prevent content bleed */
      margin-bottom: 20px;
  }
  /* Override for Filter Actions: Moves buttons to top right on mobile/tablet */
  /* Override for Filter Actions: Moves buttons to top right on mobile/tablet */
  /* Absolute positioning removed as we moved buttons to header in HTML */
  .filter-section .filter-actions {
    position: static;
    background: transparent;
    border: none;
    box-shadow: none;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    gap: 6px; /* Tighten gap between Reset/Apply */
  }

  .filter-section {
      border-radius: 0 !important;
      border-left: none !important;
      border-right: none !important;
  }

  .filter-section .filter-actions button {
    padding: 4px 10px; /* Squeeze padding */
    font-size: 0.8rem; /* Smaller text */
    height: 30px; /* Compact height */
    white-space: nowrap;
  }
  
  .filter-top-bar {
      padding: 8px 10px; /* Reduced container padding */
      min-height: 50px;
  }

  .filter-toggle-btn {
      padding: 8px 18px; /* Wider horizontal padding for better pill shape */
      font-size: 0.85rem;
      min-height: 34px;
  }

  .filter-panel.open {
    padding-top: 0;
    padding-bottom: 0; /* Remove bottom padding too if needed */
  }

  /* Override general panel padding for mobile */
  .filter-panel {
      padding: 0 !important;
  }

  /* Mobile/Tablet Horizontal Scroll Behavior */
  .filter-scroll-row {
    display: flex;
    flex-direction: row !important;
    overflow-x: auto;
    padding: 0 !important;
    gap: 0;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #d1d5db transparent;
    align-items: stretch; /* Stretch borders to scrollbar */
  }
  
  /* Remove internal margins to tighten scrollbar gap */
  .filter-group .multiselect-dropdown,
  .filter-group .filter-input, 
  .filter-group .filter-select,
  .filter-group .logic-select,
  .filter-group .toggle-switch,
  .filter-group .range-group {
      margin-bottom: 0 !important;
      padding-bottom: 0 !important;
  }
  
  /* Webkit Scrollbar Minimal Styling */
  .filter-scroll-row::-webkit-scrollbar {
      height: 2px; /* Very thin */
  }
  .filter-scroll-row::-webkit-scrollbar-thumb {
      background: var(--primary-gradient); /* Match filter button */
      border-radius: 2px;
  }
  .filter-scroll-row::-webkit-scrollbar-track {
      background: transparent;
  }

  /* Unwrap the columns so groups are direct children of the row */
  .filter-col {
    display: contents; /* Removes the column wrapper from the rendering tree */
  }

  /* Style individual filter groups to act as the scroll items */
  /* Style individual filter groups to act as the scroll items */
  .filter-group {
    min-width: 0; /* Allow shrinking */
    width: 60%; /* Updated to 60% per request */
    max-width: 300px;
    border-right: 1px solid #e5e7eb;
    padding: 0 15px;
    margin-bottom: 0px; 
    flex-shrink: 0;
    gap: 0 !important; /* Remove internal gap */
    
    display: flex;
    flex-direction: column;
  }

  .field-label {
      margin-bottom: 0 !important; /* Remove label bottom margin in mobile */
  }
  
  /* Targeted widths */
  .filter-group.fg-exp {
      width: 60%; /* Updated to 60% per request */
  }
  
  .filter-group.fg-toggles {
      width: auto; /* Allow toggles to fit content */
      min-width: 0; /* Remove forced width */
  }

  .filter-group:last-child {
      border-right: none;
  }

  /* AGGRESSIVE: Zero out ALL vertical spacing in filter area */
  .filter-section,
  .filter-section *,
  .filter-panel,
  .filter-scroll-row,
  .filter-group,
  .filter-group *,
  .multiselect-dropdown,
  .dropdown-header {
      margin-top: 0 !important;
      margin-bottom: 0 !important;
      padding-top: 0 !important;
      padding-bottom: 0 !important;
  }

  /* Restore necessary internal padding for inputs */
  .filter-input,
  .filter-select,
  .dropdown-header {
      padding: 8px 12px !important;
  }
}

@media (max-width: 480px) {
  .archive-title {
    font-size: 2rem;
  }

  .filter-section .filter-actions {
    gap: 6px;

    padding-right: 10px;
  }

  .filter-section .filter-actions button {
    padding: 5px 10px;

    font-size: 0.8rem;
  }
}

/* ============================================================
 * PROFILE CARDS & GRID
 * ============================================================ */

.profile-grid {
  display: grid;

  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));

  gap: 28px;

  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-card-item {
  background: white;

  border-radius: var(--border-radius);

  box-shadow: var(--card-shadow);

  transition: var(--transition);

  overflow: hidden;

  border: 1px solid #e5e7eb;

  position: relative;
}

.profile-card-item::before {
  content: "";

  position: absolute;

  top: 0;

  left: 0;

  right: 0;

  height: 3px;

  background: var(--primary-gradient);

  opacity: 0;

  transition: var(--transition);
}

.profile-card-item:hover::before {
  opacity: 1;
}

.profile-card-item:hover {
  transform: translateY(-6px);

  box-shadow: var(--card-shadow-hover);

  border-color: transparent;
}

.profile-card-link {
  text-decoration: none;

  color: inherit;

  display: flex;

  flex-direction: column;
}

.card-avatar-wrapper {
  width: 100%;

  padding-top: 30px;

  display: flex;

  justify-content: center;

  background: linear-gradient(180deg, #f9fafb 0%, #ffffff 100%);
}

.card-avatar-img,
.card-avatar-placeholder {
  width: 105px;

  height: 105px;

  border-radius: 50%;

  border: 4px solid white;

  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);

  object-fit: cover;

  transition: var(--transition);
}

.profile-card-item:hover .card-avatar-img,
.profile-card-item:hover .card-avatar-placeholder {
  transform: scale(1.05);

  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.2);
}

.card-avatar-placeholder {
  background: var(--primary-gradient);

  color: white;

  display: flex;

  align-items: center;

  justify-content: center;

  font-size: 2rem;

  font-weight: 800;
}

.card-info {
  padding: 20px;

  text-align: center;

  display: flex;

  flex-direction: column;

  align-items: center;
}

.card-name {
  font-size: 1.5rem;

  font-weight: 700;

  color: var(--text-main);

  margin: 8px 0 5px;
}

.card-rating {
  margin-bottom: 8px;

  font-size: 0.95rem;

  color: var(--star-color);

  font-weight: 600;
}

.card-location {
  display: flex;

  align-items: center;

  gap: 5px;

  font-size: 0.85rem;

  color: var(--text-muted);

  margin-bottom: 12px;
}

.card-location svg {
  width: 15px;

  height: 15px;

  stroke: #9ca3af;
}

.card-pills {
  margin-top: auto;

  display: flex;

  flex-wrap: wrap;

  justify-content: center;

  gap: 7px;
}

.mini-pill {
  font-size: 0.7rem;

  font-weight: 700;

  padding: 5px 10px;

  border-radius: 18px;

  text-transform: uppercase;

  letter-spacing: 0.3px;

  transition: var(--transition);
}

.mini-pill.exp {
  background: rgba(99, 102, 241, 0.1);

  color: #6366f1;

  border: 1px solid rgba(99, 102, 241, 0.2);
}

.mini-pill.job {
  background: rgba(16, 185, 129, 0.1);

  color: #059669;

  border: 1px solid rgba(16, 185, 129, 0.2);
}

.profile-card-item:hover .mini-pill {
  transform: translateY(-2px);
}

/* --- PAGINATION & NO RESULTS --- */

.archive-pagination {
  margin-top: 45px;

  text-align: center;
}

.archive-pagination .page-numbers {
  display: inline-block;

  padding: 9px 15px;

  margin: 0 4px;

  background: white;

  border: 2px solid #e5e7eb;

  border-radius: 7px;

  text-decoration: none;

  color: var(--text-muted);

  font-weight: 600;

  transition: var(--transition);

  font-size: 0.9rem;
}

.archive-pagination .page-numbers:hover {
  background: #f9fafb;

  transform: translateY(-2px);
}

.archive-pagination .page-numbers.current {
  background: var(--primary-gradient);

  color: white;

  border-color: transparent;

  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.no-results {
  text-align: center;

  padding: 60px 20px;

  color: var(--text-muted);
}

.no-results h2 {
  font-size: 1.8rem;

  font-weight: 700;

  color: var(--text-secondary);

  margin-bottom: 10px;
}

.no-results a {
  color: #6366f1;

  text-decoration: none;

  font-weight: 600;
}

.no-results a:hover {
  text-decoration: underline;
}

/* ============================================================
 * DESKTOP LAYOUT (RIGHT SIDEBAR FILTER)
 * ============================================================ */

@media (min-width: 1024px) {
  /* 
       1. MASTER GRID LAYOUT targeting Main Container
       We use display: contents to unwrap the internal containers
       so everything participates in the Main grid.
    */

  .profile-archive-main {
    display: grid;
    grid-template-columns: minmax(0, 940px) 300px; /* Content | Sidebar */
    gap: 40px;
    justify-content: center;
    padding: 0 40px; /* Reverted to 0 top padding as requested */
    align-items: start;
    position: relative;
  }

  /* Unwrap the intermediate containers */
  .profile-archive-main > .archive-header,
  .profile-archive-main > .archive-header .archive-container,
  .profile-archive-main > .archive-container {
    display: contents;
  }

  /* Target specific direct children of the unwrapped grid */

  /* HEADER: Left Column, Row 1 */
  .archive-header-top {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 30px;
    width: 100%;
  }

  /* Decouple title and button to lower only the button */
  .header-title-row {
    align-items: flex-start;
  }

  .header-title-row .btn-add-profile {
    margin-top: 25px; /* Push button down from menu/top */
  }

  /* Remove default header margins that might mess up grid gap */
  .archive-header {
    margin-bottom: 0;
  }

  /* 
       2. REORDERING
    */

  /* Place Filter in Column 2 (Right Sidebar) */
  .profile-archive-main .filter-section {
    grid-column: 2;
    /* Start at Row 1 (Header level) and span down */
    grid-row: 1 / span 3;

    position: sticky;
    top: 70px; /* Increased to account for sticky header */

    /* Fixed height viewport for the sidebar */
    height: calc(100vh - 90px); /* Adjusted for header offset */
    max-height: calc(100vh - 90px);
    overflow: hidden; /* Main container hidden, we scroll inside */

    box-shadow: none;
    border: 1px solid #e5e7eb;
    background: white;
    margin-bottom: 0;
    border-radius: 12px;
    padding: 0;

    display: flex;
    flex-direction: column;
  }

  /* Make the form fill the sidebar */
  #profile-filter-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  /* Place Content in Column 1 */
  .profile-archive-main .profile-grid,
  .profile-archive-main .no-results {
    grid-column: 1;
    grid-row: 2; /* Below Header */
    width: 100%;
  }

  .profile-archive-main .archive-pagination {
    grid-column: 1;
    grid-row: 3; /* Below the grid */
  }

  /* 
       3. HIDE MOBILE FILTER PARTS
    */
  .filter-top-bar {
    display: block !important; /* Show container for buttons */
    padding: 0;
    margin-bottom: 20px;
  }
  
  /* Hide the toggle button on desktop, but keep actions visible */
  .filter-top-bar #filter-toggle {
      display: none !important;
  }

  .filter-panel {
    display: flex !important; /* Flex to stack content/buttons */
    flex-direction: column;
    height: 100%;
    padding: 0; /* Padding handled by children or inner spacing */
    animation: none;
    background: transparent;
    overflow: hidden;
  }

  /* 
       4. VERTICAL STACK FOR FILTERS
    */
  .filter-scroll-row {
    flex-direction: column;

    /* THIS IS THE KEY: Content scrolls, buttons stay fixed */
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* Firefox flex fix */

    padding: 20px;
    gap: 4px; /* Reduced specific gap for desktop */
  }

  .filter-col {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #f3f4f6;
    padding: 0 0 5px 0; /* Reduced vertical padding */
  }

  .filter-col:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  /* Override global margins for compact desktop view */
  .multiselect-dropdown,
  .filter-group {
      margin-bottom: 0 !important;
  }

  /* Adjust internal scroll inputs (checkboxes) */
  .checkbox-scroll-box {
    max-height: 180px;
  }

  /* Fixed Footer Buttons -> NOW HEADER BUTTONS */
  .filter-actions {
    order: -1; /* Move to top */

    display: flex;
    flex-direction: row; /* Single line */
    justify-content: space-between; /* Spread them out or use gap */
    align-items: stretch;
    gap: 10px;

    flex-shrink: 0;
    background: white;
    z-index: 10;

    margin-top: 0;
    padding: 8px 20px 4px 20px; /* Reduced bottom padding */

    /* Clean look matching other archives */
    border-top: none;
    border-bottom: none;
    box-shadow: none;
  }

  .btn-apply,
  .btn-reset {
    width: auto;
    flex: 1; /* Match other archives */
    display: flex;
    justify-content: center;
  }

  /* 
       5. PROFILE GRID ADJUSTMENT
       Since grid width is reduced, ensuring 3 columns looks good.
    */
  .profile-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Large screens cleanup */
@media (min-width: 1400px) {
  .profile-archive-main .archive-container {
    max-width: 1280px; /* Match space archive feel */
  }
}

/* Ensure 2 columns on slightly smaller desktops if needed */
@media (min-width: 1024px) and (max-width: 1200px) {
  .profile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* --- CUSTOM MULTI-SELECT DROPDOWN --- */

.multiselect-dropdown {
    position: relative;
    width: 100%;
    margin-bottom: 24px; /* Increased separation */
}

.dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px; /* Larger touch area */
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: white; /* Changed from #f9fafb to match other inputs */
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    transition: var(--transition);
    min-height: 48px;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.dropdown-header:hover {
    border-color: #d1d5db;
    background: #fff;
}

/* Highlight header when active or has selection */
.multiselect-dropdown.active .dropdown-header {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.dropdown-header.has-selection {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05); /* Tinted bg for active filters */
    color: #4f46e5;
}

.dropdown-header .selected-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
    /* match parent color */
}

.dropdown-header .arrow {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.multiselect-dropdown.active .dropdown-header .arrow {
    transform: rotate(180deg);
}

.dropdown-content {
    display: none;
    margin-top: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px;
    background: white;
    max-height: 250px;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); 
    z-index: 20; 
}

.multiselect-dropdown.active .dropdown-content {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.dropdown-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}
.dropdown-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* --- MODERN ITEM STYLING (Hidden Checkbox) --- */

.dropdown-content .checkbox-item {
    position: relative;
    padding: 10px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between; 
    align-items: center;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent; 
}

.dropdown-content .checkbox-item:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

/* Hide native checkbox visually but keep it functional */
.dropdown-content .checkbox-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Selected State */
.dropdown-content .checkbox-item:has(input:checked) {
    background: rgba(99, 102, 241, 0.08); 
    color: #4f46e5; 
    font-weight: 600;
}

/* Custom Checkmark Indicator on the right using pseudo-element */
.dropdown-content .checkbox-item::after {
    content: '✓';
    font-weight: 900;
    font-size: 0.9rem;
    color: #6366f1;
    opacity: 0;
    transform: translateX(-5px);
    transition: all 0.2s ease;
}

.dropdown-content .checkbox-item:has(input:checked)::after {
    opacity: 1;
    transform: translateX(0);
}

/* Adjust separation for other filter groups */
.filter-group {
    margin-bottom: 24px; 
}

/* Update logic-select to match modern style */
.logic-select {
    width: 100%; 
    margin-bottom: 8px;
    border-color: #e5e7eb;
    background-color: white;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ============================================================
   DESKTOP IMPROVEMENTS (Min Width 1025px)
   ============================================================ */

@media (min-width: 1025px) {
    /* Add spacing from top navigation */
    .archive-header-top {
        margin-top: 20px;
    }

    /* Increase Header Font Sizes for Large Screens */
    .archive-title {
        font-size: 3rem; /* Significantly larger */
        padding-left: 10px; /* Added desktop padding */
    }

    .archive-subtitle {
        font-size: 1.8rem; /* Increased font size */
        padding-left: 10px; /* Match title padding */
        margin-top: 0; /* Reduced gap */
    }

    /* Ensure Proper Alignment */
    .header-title-row {
        align-items: center;
        margin-bottom: 4px; /* Reduced gap for desktop */
    }

    .btn-add-profile {
        font-size: 1rem;
        padding: 10px 24px; /* Larger button for desktop */
    }
    
    /* Ensure Header Content Aligns */
    .archive-header-content {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
}

