/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Macondo&family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap');

/* CSS variables */
:root {
  --primary-color: #2C3E50;
  --secondary-color: #1f5a86;
  --background-color: #F4F6F8;
  --highlight-color: #b0b6ba;
  --error-color: #D32F2F;
  --text-color: #333;
}

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


/* General Styles */
body {
  font-family: 'Nunito Sans', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
}


/* Main Layout */
#main-container {
  display: flex;
  height: calc(100vh - 70px); /* 70px is the title height */
  margin: 0;
  gap: 20px;
  padding: 20px;
  box-sizing: border-box; /* Ensure padding is included in height to stop scrolling*/
}

#sidebar-container {
  width: 35%;
  padding: 0px 20px;
  background-color: white;
  overflow-y: auto;
  height: 100%; 
  box-sizing: border-box; /* Ensure padding is included in height to stop scrolling*/
  align-self: flex-start; /* Align sidebar to the top */
}

/* Map */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: white;
  height: 100%; /* Ensure map fills the container */
}

#map { 
  height: 100%;
  width: 100%;
  min-height: 400px; /* Ensure map has size for mob devices, so it appears */
}

/* Title Style */

 #title {
  text-align: left;
  font-size: 2.5rem;
  padding: 0;
  color: var(--primary-color);
  margin: 0;
  font-weight: 700;
  flex-grow: 0; /* Allow title to grow and fill space */
}

/* Hide mobile shorter title */
.mobile-title {
  display: none;
}

.sub-heading {
  font-size: 1.5em;
  margin: 10px 0px;
  text-align: left;
  color: var(--primary-color);
}

#header-container {
  position: relative;
  padding-left: 20px;
  padding-right: 20px; 
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px; /* Space between title and help button */ 
}


/* Help Button */
#help-button {
  position: static;
  top: 20px;
  right: 20px; 
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#help-button:hover {
  background-color: var(--secondary-color);
}

#help-button:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
}

/* Modal Background */
.modal {
  display: none; 
  position: fixed; 
  z-index: 2000; 
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  color: var(--primary-color);
  overflow: auto;
}

/* Modal Box */
.modal-content {
  background-color: var(--primary-color);
  margin: 10% auto;
  padding: 20px;
  width: 80%;
  max-width: 500px;
  color: white;
}

/* Modal Heading */
.modal-heading {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: white;
}

/* Modal Paragraph */
.modal-paragraph {
  margin-bottom: 20px;
  line-height: 1.6;
  font-size: 1rem;
}

/* Modal List */
.modal-content ul {
  padding-left: 20px;
  list-style-type: disc;
}

.modal-content li {
  margin-bottom: 8px;
  line-height: 1.4;
}

/* Close Button */
.close {
  background-color: transparent;
  border: none;
  float: right;
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
  cursor: pointer;
  transition: color 0.2s ease;
}

.close:hover {
  color: var(--highlight-color);
  outline: none;
}

/* postcode search styles */

#postcode-search {
  width: 100%;
  padding: 10px;
  font-size: 1rem;
  margin-bottom: 10px;
  border: 0.5px solid var(--primary-color);
}

#postcode-search:focus {
  outline: none;
  border-color: var(--secondary-color);
}

#search-button {
  width: 100%;
  padding: 10px;
  font-weight: bold;
  background-color: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
}

#search-button:hover {
  background-color: var(--secondary-color);
}

#search-button:focus {
  outline: none;
  border-color: var(--secondary-color);
}

input::placeholder {
  color: var(--text-color);
  opacity: 0.85; 
}

/* Most Common Crimes Styles */

#highest-crimes-list {
  list-style-type: none;
  padding: 0;
  margin-top: 10px;
}

#highest-crimes-list li {
  padding: 10px;
  border: 0.5px solid var(--primary-color);
}

/* Info Section Styles */
#info {
  text-align: left;
  padding: 10px;
  margin-top: 20px;
  border: 0.5px solid var(--primary-color);
}


 /* Crime List */
 #crime-list {
  flex: 1;
  min-height: 0;
}

.crime-items {
  list-style-type: none;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  max-height: 200px;
}

.crime-items li {
  list-style: none;
  margin-bottom: 6px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background-color 0.2s ease;
}

.crime-items li:hover {
  background-color: var(--primary-color);
  color: white;
}

/* Dropdown Styles */
#dropdown {
  margin-top: 10px;
}

#dropdown select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 0.5px solid var(--primary-color);
  background-color: white;
  color: var(--text-color);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#dropdown select:hover {
  border-color: var(--secondary-color);
}

#dropdown select:focus {
  outline: none;
  border-color: var(--secondary-color);
}

/* Highlight for filter match */
.highlight {
  background-color: var(--primary-color);
  color: white;
  transition: background-color 0.5s ease;
}

/* Focus style for map to help pass accessibility tests */
#map:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 2px;
}

/*  Reload Button Styles */
#reload-button {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 1000;
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: bold;
}

#reload-button:hover {
  background-color: var(--secondary-color);
}

#reload-button:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
}

#error-message {
  background-color: var(--error-color);
  color: white;
  font-weight: bold;
  padding: 10px 15px;
  text-align: center;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);/* Center it */
  z-index: 999;
  display: none; /* Hidden by default */
  max-width: 80%; 
  word-wrap: break-word;
}

/* Responsive Styles */

/* Tablet Styles */
@media (min-width: 768px) and (max-width: 1024px) {
  #help-button {
    position: static;
    display: block;
    margin: 10px 0 0 0;
    width: auto;
    padding-left: 10px;
    padding-right: 10px;
  }

  #header-container {
    flex-direction: column; 
    align-items: flex-start; 
    padding-left: 20px;
    padding-right: 20px;
    gap: 10px; 
  }
}
  

/* Mobile Styles */
@media (max-width: 768px) {
  #main-container {
    flex-direction: column;
    height: auto;
  }

  #sidebar-container {
    width: 100%;
    padding: 10px;
    order: 2;
  }

  #map-container {
    height: 60vh;
    order: 1;
    width: 100%;
  }

   #map {
    height: 100%; /* ensure map fills the container and appears*/
    width: 100%;
  }

  .full-title {
    display: none;
  }

  .mobile-title {
    display: inline;
    text-align: left;
  }

  #header-container { 
    padding-left: 20px;
    padding-right: 20px;
    flex-direction: column; /* Stack title and button vertically */
    align-items: flex-start; /* Align both to the left */
    gap: 10px; /* Add space between title and button */
  }
  
  #help-button {
    position: static;
    display: block; 
    padding: 10px 15px; /* Consistent padding */
    margin: 0; 
  }

  .sub-heading {
    font-size: 1.2em;
  }
  #postcode-search {
    width: 100%;

  }
  #search-button {
    width: 100%;
  }

  #error-message {
    font-size: 14px;
    padding: 10px 14px;
    max-width: 90%; /* Even wider on small screens */
    word-break: break-word; /* Ensures fit on small screens */
  }
}

/* Landscape Mode on Mobiles and Tablets (max-width of 1024px) */
@media (max-width: 1024px) and (orientation: landscape) {
  /* Revert main container to a row layout */
  #main-container {
    flex-direction: row;
    height: 100vh; 
    padding: 10px;
    gap: 10px;
  }

  #sidebar-container {
    width: 40%; 
    height: 100%;
    order: 0; 
    padding: 0px 10px; /* Reduced padding for landscape */
  }
  
  #map-container {
    height: 100%;
    flex: 1; 
    order: 0; 
  }

  #header-container {
    flex-direction: row; 
    align-items: center;
    gap: 10px;
    padding: 0 10px; /* Reduced padding for landscape */
  }

  #title {
    font-size: 2rem; 
  }
  
  .sub-heading {
    font-size: 1.2em;
    margin: 5px 0;
  }

  #help-button {
    position: static;
    margin: 0;
  }
}
  
