/* ========================================
   DISTRICT CONTACTS PAGE STYLES
   ========================================
   
   This file contains all styles specific to the district contacts page.
   Styles are organized by component and use specific selectors to avoid
   conflicts with other CSS files.
   
   ORGANIZATION:
   - Global overrides & utilities
   - Search component
   - Stats bar component  
   - District grid component
   - Modal component
   - Address section component
   - Contact cards component (with specific overrides)
   - Copy button component
   - Loading & states component
   - Animations
   - Responsive design
   - Legacy styles (for backward compatibility)
   
   SPECIFICITY STRATEGY:
   - All selectors are prefixed with 'body.contacts-modern' to ensure
     they only apply to the district contacts page
   - Contact card styles use more specific selectors to override
     conflicting styles from general.css
   - Component-based organization for better maintainability
   
   CONFLICT RESOLUTION:
   - Overrides general.css contact-card styles with more specific selectors
   - Maintains separation from other page styles
   - Preserves responsive design across all breakpoints
   ======================================== */

/* ========================================
   GLOBAL OVERRIDES & UTILITIES
   ======================================== */
body.contacts-modern html {
  scroll-behavior: auto;
}

body.contacts-modern main {
  max-width: 100%;
}

/* ========================================
   SEARCH COMPONENT
   ======================================== */
body.contacts-modern .search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto 2rem;
}

body.contacts-modern .search-input {
  width: 100%;
  padding: 1rem 3rem 1rem 1rem;
  border: 2px solid #e9ecef;
  border-radius: 50px;
  font-size: 1.1rem;
  transition: all 0.3s ease;
  background: white;
}

body.contacts-modern .search-input:focus {
  outline: none;
  border-color: #204f9a;
  box-shadow: 0 0 0 3px rgba(32, 79, 154, 0.1);
}

body.contacts-modern .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  font-size: 1.2rem;
}

/* ========================================
   STATS BAR COMPONENT
   ======================================== */
body.contacts-modern .stats-bar {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

body.contacts-modern .stat-item {
  text-align: center;
}

body.contacts-modern .stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #204f9a;
}

body.contacts-modern .stat-label {
  font-size: 0.9rem;
  color: #4e565c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ========================================
   DISTRICT GRID COMPONENT
   ======================================== */
body.contacts-modern .district-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

body.contacts-modern .district-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border: 1px solid #e9ecef;
  transition: all 0.3s ease;
  cursor: pointer;
}

body.contacts-modern .district-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

body.contacts-modern .district-card.selected {
  border-color: #204f9a;
  box-shadow: 0 0 0 3px rgba(32, 79, 154, 0.1);
}

body.contacts-modern .district-id {
  font-weight: 700;
  color: #204f9a;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

body.contacts-modern .district-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1rem;
}

/* ========================================
   MODAL COMPONENT
   ======================================== */
body.contacts-modern .modal-xl {
  max-width: 95%;
}

@media (min-width: 1200px) {
  body.contacts-modern .modal-xl {
    max-width: 90%;
  }
}

@media (min-width: 1400px) {
  body.contacts-modern .modal-xl {
    max-width: 85%;
  }
}

body.contacts-modern .modal-body {
  padding: 2rem;
}

/* Modal header styling with blue gradient */
body.contacts-modern .modal-header {
  background: linear-gradient(135deg, #204f9a 0%, #163465 100%);
  color: white;
  border-bottom: none;
  padding: 1.5rem 2rem;
}

body.contacts-modern .modal-header .modal-title {
  color: white;
  font-weight: 600;
  font-size: 1.3rem;
}

/* Make modal close button white */
body.contacts-modern .modal-header .btn-close {
  filter: invert(1);
}

/* ========================================
   ADDRESS SECTION COMPONENT
   ======================================== */
body.contacts-modern .address-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

body.contacts-modern .address-title {
  font-weight: 600;
  color: #204f9a;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

/* ========================================
   CONTACT CARDS COMPONENT (District Contacts Specific)
   ======================================== */
body.contacts-modern .contact-cards-container {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Override general.css contact-card styles for district contacts page */
body.contacts-modern .contact-cards-container .contact-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid #e9ecef;
  overflow: hidden;
  transition: all 0.3s ease;
  min-height: auto;
  text-align: left;
  padding: 0; /* Override general.css padding */
}

body.contacts-modern .contact-cards-container .contact-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transform: translateY(-4px);
}

body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-card-header {
  background: linear-gradient(135deg, #204f9a 0%, #163465 100%);
  color: white;
  padding: 1rem 1.5rem;
  font-weight: 600;
  font-size: 1.1rem;
}

body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-card-header
  .contact-dept {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-card-header
  h5 {
  margin: 0;
  font-weight: 600;
  font-size: 1.1rem;
}

body.contacts-modern .contact-cards-container .contact-card .contact-card-body {
  padding: 1.5rem;
}

/* New compact contact info layout */
body.contacts-modern .contact-cards-container .contact-card .contact-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

body.contacts-modern .contact-cards-container .contact-card .contact-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0;
  background: transparent;
  border-radius: 0;
  border-left: none;
  margin-bottom: 0;
}

body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-info-item:last-child {
  margin-bottom: 0;
}

/* Left column: Name and Phone */
body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-info-item:first-child {
  gap: 0.5rem;
}

body.contacts-modern .contact-cards-container .contact-card .contact-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-field:last-child {
  margin-bottom: 0;
}

/* Remove labels, keep only icons and values */
body.contacts-modern .contact-cards-container .contact-card .contact-label {
  display: none;
}

body.contacts-modern .contact-cards-container .contact-card .contact-value {
  font-size: 1rem;
  color: #333;
  word-break: break-word;
  line-height: 1.4;
  font-weight: 500;
}

/* Name styling */
body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-field:first-child
  .contact-value {
  font-weight: 600;
  color: #333;
  font-size: 1.1rem;
}

/* Phone styling */
body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-field:nth-child(2)
  .contact-value {
  color: #333;
  font-size: 1rem;
}

/* Right column: Title and Email */
body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-info-item:last-child {
  gap: 0.5rem;
  text-align: right;
}

body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-info-item:last-child
  .contact-field {
  justify-content: flex-end;
}

/* Title styling */
body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-info-item:last-child
  .contact-field:first-child
  .contact-value {
  color: #6c757d;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Email styling */
body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-info-item:last-child
  .contact-field:last-child {
  gap: 0.25rem;
}

body.contacts-modern .contact-cards-container .contact-card .contact-link {
  color: #204f9a;
  text-decoration: none;
  transition: color 0.2s ease;
  font-weight: 500;
  font-size: 0.9rem;
}

body.contacts-modern
  .contact-cards-container
  .contact-card
  .contact-link:hover {
  color: #163465;
  text-decoration: underline;
}

body.contacts-modern .contact-cards-container .contact-card .contact-dept .bx {
  color: #fff;
}

/* Icon styling */
body.contacts-modern .contact-cards-container .contact-card .contact-field .bx {
  color: #6c757d;
  font-size: 1rem;
  flex-shrink: 0;
}

/* Copy button styling */
body.contacts-modern .contact-cards-container .contact-card .copy-btn {
  background: transparent;
  color: #6c757d;
  border: none;
  border-radius: 4px;
  padding: 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 0.25rem;
  position: relative;
  min-width: 20px;
  text-align: center;
}

body.contacts-modern .contact-cards-container .contact-card .copy-btn:hover {
  background: #e9ecef;
  color: #204f9a;
}

body.contacts-modern .contact-cards-container .contact-card .copy-btn.copied {
  color: #28a745;
}

/* Visual feedback for copied state */
body.contacts-modern
  .contact-cards-container
  .contact-card
  .copy-btn.copied::after {
  content: " ✓ Copied!";
  font-weight: bold;
  font-size: 0.75rem;
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: #28a745;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ========================================
   LOADING & STATES COMPONENT
   ======================================== */
body.contacts-modern .loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  color: #204f9a;
}

body.contacts-modern .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e9ecef;
  border-top: 4px solid #204f9a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

body.contacts-modern .no-results {
  text-align: center;
  padding: 3rem;
  color: #6c757d;
  font-style: italic;
}

body.contacts-modern .no-results .retry-button {
  margin-top: 1.5rem;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  border: none;
  background: #204f9a;
  color: white;
}

body.contacts-modern .no-results .retry-button:hover:not(:disabled) {
  background: #163465;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(32, 79, 154, 0.3);
}

body.contacts-modern .no-results .retry-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

body.contacts-modern .no-results .retry-button .bx-spin {
  animation: spin 1s linear infinite;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet and smaller desktop */
@media (min-width: 768px) {
  body.contacts-modern
    .contact-cards-container
    .contact-card
    .contact-info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  body.contacts-modern
    .contact-cards-container
    .contact-card
    .contact-info-item {
    padding: 0;
  }
}

@media (min-width: 992px) {
  body.contacts-modern .contact-cards-container {
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2.5rem;
  }
}

@media (min-width: 1200px) {
  body.contacts-modern .contact-cards-container {
    grid-template-columns: repeat(auto-fit, minmax(550px, 1fr));
  }
}

@media (min-width: 1400px) {
  body.contacts-modern .contact-cards-container {
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
  }
}

/* Mobile devices */
@media (max-width: 768px) {
  body.contacts-modern .district-grid {
    grid-template-columns: 1fr;
  }

  body.contacts-modern .stats-bar {
    flex-direction: column;
    text-align: center;
  }

  body.contacts-modern .contact-cards-container .contact-card .contact-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  body.contacts-modern .copy-btn {
    align-self: flex-end;
    margin-left: 0;
    margin-top: 0.25rem;
  }

  body.contacts-modern
    .contact-cards-container
    .contact-card
    .contact-info-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  body.contacts-modern
    .contact-cards-container
    .contact-card
    .contact-card-body {
    padding: 1.25rem;
  }

  body.contacts-modern
    .contact-cards-container
    .contact-card
    .contact-info-item {
    padding: 0;
  }

  /* Mobile: stack right column content */
  body.contacts-modern
    .contact-cards-container
    .contact-card
    .contact-info-item:last-child {
    text-align: left;
  }

  body.contacts-modern
    .contact-cards-container
    .contact-card
    .contact-info-item:last-child
    .contact-field {
    justify-content: flex-start;
  }

  body.contacts-modern .contact-cards-container {
    margin-top: 2rem;
  }
}

/* ========================================
   LEGACY STYLES (for backward compatibility)
   ======================================== */
body.contacts-modern .search-bar {
  margin: 0 auto;
  margin-bottom: 20px;
  margin-top: 20px;
  padding: 10px;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
}

body.contacts-modern .school-list {
  list-style: none;
  padding: 0;
}

body.contacts-modern .school-item {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid #ccc;
  cursor: pointer;
}

body.contacts-modern .school-item:hover {
  background-color: #eee;
}

body.contacts-modern .email-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

body.contacts-modern .email-link {
  flex: 1;
}

/* Address section copy buttons - remove border and match contact card style */
body.contacts-modern .address-section .copy-btn {
  background: transparent;
  color: #6c757d;
  border: none;
  border-radius: 4px;
  padding: 0.25rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 0.25rem;
  position: relative;
  min-width: 20px;
  text-align: center;
}

body.contacts-modern .address-section .copy-btn:hover {
  background: #e9ecef;
  color: #204f9a;
}

body.contacts-modern .address-section .copy-btn.copied {
  color: #28a745;
}

body.contacts-modern .address-section .copy-btn.copied::after {
  content: " ✓ Copied!";
  font-weight: bold;
  font-size: 0.75rem;
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: #28a745;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-left: 0.5rem;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ========================================
   CONTACT UPDATE NOTICE COMPONENT
   ======================================== */
body.contacts-modern .contact-update-notice {
  background: linear-gradient(135deg, #667eea 0%, #4e4ba2 100%);
  color: white;
  padding: 2rem;
  border-radius: 15px;
  margin: 2rem 0;
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

body.contacts-modern .contact-update-notice .notice-content {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

body.contacts-modern .contact-update-notice .notice-icon {
  flex-shrink: 0;
  font-size: 2.5rem;
  color: white;
  margin-top: 0.25rem;
}

body.contacts-modern .contact-update-notice .notice-text {
  flex: 1;
}

body.contacts-modern .contact-update-notice .notice-text h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: white;
}

body.contacts-modern .contact-update-notice .notice-text p {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  color: white;
}

body.contacts-modern .contact-update-notice .notice-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

body.contacts-modern .contact-update-notice .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

body.contacts-modern .contact-update-notice .btn-primary {
  background: white;
  color: #204f9a;
  border-color: white;
}

body.contacts-modern .contact-update-notice .btn-primary:hover {
  background: #f8f9fa;
  color: #163465;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.contacts-modern .contact-update-notice .btn-outline-primary {
  background: transparent;
  color: white;
  border-color: white;
}

body.contacts-modern .contact-update-notice .btn-outline-primary:hover {
  background: white;
  color: #204f9a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Mobile responsive for notice */
@media (max-width: 768px) {
  body.contacts-modern .contact-update-notice {
    padding: 1.5rem;
  }

  body.contacts-modern .contact-update-notice .notice-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  body.contacts-modern .contact-update-notice .notice-icon {
    margin-top: 0;
  }

  body.contacts-modern .contact-update-notice .notice-text h3 {
    font-size: 1.3rem;
  }

  body.contacts-modern .contact-update-notice .notice-text p {
    font-size: 1rem;
  }

  body.contacts-modern .contact-update-notice .notice-actions {
    justify-content: center;
    flex-direction: column;
  }

  body.contacts-modern .contact-update-notice .btn {
    justify-content: center;
    width: 100%;
  }
}
