/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* General Styles */
html {
  scroll-padding-top: 200px; /* For anchor links */
}

body {
  margin: 0;
  padding-top: 200px; /* Space for fixed header */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #fff;
  min-height: 100vh;
}

/* Main Content Spacing */
main {
  padding: 2rem;
  position: relative;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}

/* Adjust header height and spacing */
header {
  background-color: #0a2942;
  color: #fff;
  padding: 1rem;
  border-bottom: 3px solid #1c85c9;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: auto; /* Allow header to adjust to content */
  min-height: 60px; /* Minimum height for header */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Ensure header content is properly spaced */
header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  line-height: 1.2;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
  body {
    padding-top: 240px; /* More space for wrapped navigation */
  }
  
  html {
    scroll-padding-top: 240px;
  }

  header h1 {
    font-size: 1.5rem;
  }
}

/* Focus Styles for Accessibility */
:focus {
  outline: 3px solid #007bff;
  outline-offset: 2px;
}

/* Skip Navigation Link for Keyboard Users */
.skip-link {
  background: #007bff;
  color: #fff;
  font-weight: bold;
  left: 50%;
  padding: 8px;
  position: absolute;
  transform: translateY(-100%);
  transition: transform 0.3s;
}

.skip-link:focus {
  transform: translateY(0%);
}

/* Print Styles */
@media print {
  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
}

/* Header */
header {
  background-color: #0a2942;
  color: #fff;
  padding: 1rem;
  border-bottom: 3px solid #1c85c9;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

header h1 {
  margin: 0;
  font-size: 2rem;
}

/* Navigation */
nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0 0 0;
}

nav ul li a {
  color: #8ecdf7;
  text-decoration: none;
  font-weight: bold;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.2s ease-in-out;
  position: relative;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

nav ul li a::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  background-color: #fff;
  bottom: 0;
  left: 0;
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.3s ease-out;
}

nav ul li a:hover {
  background-color: rgba(28, 133, 201, 0.2);
  color: #ffffff;
}

nav ul li a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

nav ul li a:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

nav ul li a.active {
  background-color: rgba(28, 133, 201, 0.3);
  color: #ffffff;
  position: relative;
}

nav ul li a.active::after {
  transform: scaleX(1);
}

@media (prefers-reduced-motion: reduce) {
  nav ul li a {
    transition: none;
  }
  
  nav ul li a::after {
    transition: none;
  }
}

/* Main Content */
main {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Table Styles */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2rem 0;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

thead {
  background-color: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
}

th {
  text-align: left;
  padding: 1rem;
  font-weight: 600;
  color: #495057;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

td {
  padding: 1rem;
  border-bottom: 1px solid #dee2e6;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background-color: #f8f9fa;
}

/* Column-specific styles */
table .office-column {
  width: 25%;
}

table .name-column {
  width: 20%;
}

table .party-column {
  width: 10%;
  text-align: center;
}

table .website-column {
  width: 25%;
}

table .contact-column {
  width: 20%;
}

/* Party indicators */
.party-r, .party-d {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  text-align: center;
  min-width: 32px;
}

.party-r {
  background-color: #fff2f2;
  color: #dc3545;
}

.party-d {
  background-color: #f2f8ff;
  color: #0d6efd;
}

/* External link styles */
table a {
  display: inline-flex;
  align-items: center;
  color: #0056b3;
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

table a:hover {
  background-color: #f0f7ff;
  text-decoration: underline;
}

table a:focus {
  outline: 2px solid #0056b3;
  outline-offset: 2px;
}

/* Contact button styles */
.contact-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  color: #495057;
  text-decoration: none;
  transition: all 0.2s;
}

.contact-button:hover {
  background-color: #e9ecef;
  border-color: #ced4da;
}

/* Responsive table */
@media (max-width: 1024px) {
  main {
    padding: 1rem;
  }
  
  table {
    margin: 1rem 0;
  }
  
  th, td {
    padding: 0.75rem;
  }
}

@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  th, td {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}

article section {
  margin-bottom: 2rem;
}

article h2 {
  color: #0F4761;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

article h3 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

/* Lists */
ul {
  padding-left: 1.5rem;
}

ul li {
  margin-bottom: 0.5rem;
}

/* Links */
a {
  color: #0056b3; /* WCAG AA compliant color */
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:hover, a:focus {
  color: #003d82;
  text-decoration: none;
  background-color: rgba(0, 86, 179, 0.1);
}

a:active {
  color: #002655;
}

/* External Links */
a[target="_blank"]::after {
  content: " (opens in new tab)";
  font-size: 0.9em;
}

/* Alert message styling */
.alert {
  background-color: #ffefc1; /* light yellow background */
  border-left: 4px solid #f39c12; /* orange accent border */
  padding: 1rem;
  margin: 1rem 0;
  font-weight: bold;
}

/* Footer */
footer {
  background-color: #f4f4f4;
  color: #555;
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
}

/* Component Styles */
.official-card {
  border: 1px solid #ddd;
  padding: 15px;
  margin: 10px 0;
  border-radius: 5px;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.contact-info {
  background-color: #f5f5f5;
  padding: 10px;
  margin-top: 10px;
  border-radius: 3px;
}

.district-finder {
  background-color: #e8f4f8;
  padding: 20px;
  margin: 20px 0;
  border-radius: 5px;
  border: 1px solid #c8e4f8;
}

.chamber-info {
  margin-bottom: 30px;
}

/* Alert Styles - Updated to be consistent across the site */
.alert {
  background-color: #fff3cd;
  border: 1px solid #ffeeba;
  padding: 15px;
  margin: 15px 0;
  border-radius: 5px;
  color: #856404;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  body {
    background: #fff;
    color: #000;
  }
  
  a {
    color: #000;
    text-decoration: underline;
    text-decoration-thickness: 2px;
  }
  
  .alert {
    border: 2px solid #000;
    background: #fff;
    color: #000;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #1a1a1a;
    color: #fff;
  }
  
  a {
    color: #66b3ff;
  }
  
  .alert {
    background-color: #2d2d2d;
    border-color: #404040;
    color: #fff;
  }
}

/* Responsive Design */
@media (max-width: 600px) {
  header h1 {
    font-size: 1.5rem;
  }
  
  nav ul {
    flex-direction: column;
    align-items: center;
  }

  .official-card,
  .contact-info,
  .district-finder {
    margin: 10px;
  }
}

/* District Lookup Tool Styles */
.lookup-container {
  max-width: 800px;
  margin: 0 auto;
}

.address-form {
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.form-group input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
}

.form-group small {
  display: block;
  margin-top: 5px;
  color: #666;
}

.btn-primary {
  background-color: #0F4761;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
}

.btn-primary:hover {
  background-color: #0d3a4f;
}

.btn-primary:focus {
  outline: 3px solid #007bff;
  outline-offset: 2px;
}

.results-container {
  margin-top: 20px;
}

.note {
  font-style: italic;
  color: #666;
  margin-top: 15px;
  font-size: 0.9em;
}

.district-results {
  padding: 15px;
  background: white;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.error-message {
  background-color: #fee;
  color: #c00;
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
  font-weight: bold;
}

.representative-highlight {
  background-color: #e8f4f8 !important;
  transition: background-color 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  .representative-highlight {
    transition: none;
  }
}

@media (max-width: 768px) {
  .lookup-container {
    padding: 15px;
  }
  
  .form-group input {
    font-size: 16px; /* Prevents zoom on mobile */
  }
}
