body {
  font-family: "Roboto", sans-serif;
  font-size: 10px;
}

.accordion button {
  background-color: #ffffff00;
}

.accordion img {
  mix-blend-mode: multiply;
}

.accordion-body {
  padding: 0 0 10px 0 !important;
}

.accordion-button {
  background-color: #ababab00;
  padding: 10px;
}

.accordion-button:focus {
  border-color: #00000000;
  box-shadow: none;
}

.accordion-button:not(.collapsed) {
  font-weight: bold;
  background-color: #ababab00;
  color: black;
}

.accordion-item {
  background-color: #ababab00;
}

.clicked {
  color: cyan !important;
}

.layer-tree-control {
  border: none !important;
}

.collapse {
  visibility: unset !important;
}

/* start accordion style */
.accordion {
  width: 100%;
  border: 1px solid #ccc;
  border-radius: 5px;
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid #ccc;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  /* reduced header height */
  background-color: #D6F4ED;
  /*background: url("./resources/images/Ind2.JPG") no-repeat center center; 
  background-size: 100% 100%; /* scale image to exactly fit header height and width */
  background-repeat: no-repeat;

  color: rgb(230, 61, 10);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  z-index: 1001;
  opacity: 0;
  animation: headerFadeIn 2s forwards;
  text-align: center;
}

header h1 {
  font-size: 20px;
  margin: 0;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

header p {
  font-size: 11px;
  margin: 0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

@keyframes headerFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-30px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes logoFadeIn {
  0% {
    opacity: 0;
    transform: translateX(-30px);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.accordion-header {
  background: #f4f4f4;
  padding: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.accordion-content {
  display: none;
  padding: 10px;
  background: #fff;
  padding-left: 30px;
}

.checkbox {
  margin-left: 10px;
}

.toggle-sign {
  font-weight: bold;
  margin-right: 10px;
}

.child-container {
  display: flex;
  align-items: center;
}

/* end accordion style */

/* start legend style */

.legend-item {
  display: flex;
  margin-bottom: 5px;
  align-items: center;
}

.legend-item-color {
  width: 20px;
  height: 15px;
  margin-right: 10px;
  margin-left: 10px;
}

.legend img {
  margin-top: -1px;
  margin-right: 8px;
}

.stateLayer {
  background-color: #0000 !important;
  border: 2px solid yellow !important;
}

.districtLayer {
  background-color: #0000 !important;
  border: 2px solid orange !important;
}

/* end legend style */

#latlong {
  z-index: 1000;
}

.district-label {
  color: transparent;
  text-shadow: 1px 1px 0 black;
}

.leaflet-routing-container.leaflet-routing-container-hide {
  display: none;
  margin-right: 10px !important;
}

#nearby-info {
  position: relative;
  z-index: 10000;
  max-width: 50%;
  width: fit-content;
  border-radius: 5px;
  top: 70%;
  color: white;
  font-size: 11px;
  left: 85%;
  transform: translateX(-50%);
  background-color: #5c99db48;
  padding: -5px;
}

#rout-instruction {
  position: relative;
  z-index: 10000;
  max-width: 50%;
  width: fit-content;
  border-radius: 5px;
  top: 58%;
  color: white;
  left: 8%;
  transform: translateY(-50%);
  background-color: rgba(117, 120, 122, 0.5);
  /*semi-transparent background */
  padding: 5px;

}

#availability-info {
  position: relative;
  z-index: 10001;
  max-width: 55%;
  width: fit-content;
  border-radius: 5px;
  bottom: -60%;
  color: white;
  left: 75%;
  /* transform: 40%; */
  /* transform: translateX(-50%); */
  background-color: rgba(64, 130, 201, 0.8);
  /* semi-transparent background */
  padding: 5px;
}

.popup-table {
  /* font-family: Arial, Helvetica, sans-serif; */
  border-collapse: collapse;
  width: 100%;
  transition: 1s;
  font-size: 10px;
  table-layout: fixed;
  word-wrap: break-word;
}

.popup-table td {
  border: 1px solid #636060ec;
  /* padding: 2px 1px;
  text-align: left;
  vertical-align: middle; */
}

.popup-table th {
  border: 1px solid #322626;
  padding: 2px 1px;
  border: 1px solid gray;
}

.popup-table tr:nth-child(even) {
  background-color: #f2f2f2;
}

.popup-table tr:hover {
  background-color: #ddd;
}

.popup-table tr:nth-child(1) {

  text-align: left;

}

.ip-popup-card .popup-value {
  padding: 3px 5px !important;
  color: #222;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  width: 52%;
  border: 1px solid #ffb74d !important;
}

.ip-popup-card .popup-label {
  font-weight: 500;
  color: #444;
  padding: 2px 2px 2px 10px !important;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
  width: 48%;
  border: 1px solid #ffb74d !important;
}

.collapsible table {
  border-collapse: collapse;
  width: 100%;
  transition: 1s;
  font-size: 15px;
}

.collapsible table td {
  border: 1px solid gray;
}

.collapsible table td:nth-child(2) {
  text-align: center;
  border: 1px solid #ffb74d !important;
}

.collapsible table td:nth-child(3) {
  text-align: right;
}

.collapsible table tr:nth-child(1) {
  background-color: rgb(34, 34, 34);
  color: white;
}

.panel-group i {
  padding: 0px 5px;
}

/* start styling for toolbox */
/* Styling for the tools container */
/* .tools-container {
    display: none;
    position: absolute;
    top: 60px;
    left: 10px;
    background: white;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
} */

.tools-container {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 10px;
  background: white;
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: block;
  /* Always visible */
}

/* .tools-grid {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    gap: 5px;
} */

.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tool-button {
  width: 40px;
  height: 40px;
  background: #007bff;
  color: white;
  text-align: center;
  line-height: 40px;
  font-size: 16px;
  border-radius: 5px;
  cursor: pointer;
}

.tool-button:hover {
  background: #0056b3;
}

.active-tool {
  background: red !important;
}

.tools-toggle {
  background: white;
  padding: 8px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 5px;
  font-size: 18px;
}

/* Custom Tooltip Styling */
.custom-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2000;
  transition: opacity 0.2s ease-in-out;
}

/* end styling for toolbox */

/* start styling for measurement */
.leaflet-control-measure .leaflet-control-measure-toggle,
.leaflet-control-measure .leaflet-control-measure-toggle:hover {
  display: none;
}

.js-start {
  width: 100% !important;
}

/* end styling for measurement */

#divFeatureInfoContent {
  max-height: 175px;
  width: 100%;
  margin: 0;
  overflow-y: auto;
  /* Enables vertical scrolling */
  overflow-x: auto;
  /* Enables horizontal scrolling */
  padding: 0;
  text-align: left;
}

#divPreNxt {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding-top: 10px;
}

.leaflet-popup-content-wrapper {
  max-height: 280px;
  width: 200px;
  overflow-y: auto;
  /* Enables vertical scrolling if content overflows */
  overflow-x: hidden;
  /* Prevents horizontal scrolling */
}

.leaflet-popup-content {
  max-height: 280px;
  width: 100%;
  padding: 10px;
  margin: 0;
  align-items: center;
  text-align: left;
  vertical-align: middle;
  word-wrap: break-word;
  /* Ensures content fits within the popup */
  box-sizing: border-box;
  /* Includes padding and border in width/height */
}

.imgSearchNearby {
  height: 20px;
  width: 20px;
}

*,
::after,
::before {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #e5e7eb00 !important;
}

.leaflet-tile {
  border: none !important;
  background: transparent !important;
}

@media print {
  @page {
    size: A3 landscape;
    margin: 0;
  }

  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    margin: 0;
    padding: 0;
    overflow: hidden !important;
  }

  #map {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    background-color: white;
  }

  .leaflet-container {
    width: 100vw !important;
    height: 100vh !important;
  }

  /* .leaflet-control-container, .tools-container, #toc, #divSearch, #divLegend, #divPrint {
        display: none !important;
    } */
}

.leaflet-draw-tooltip {
  display: none;
}

/* Add this to your CSS file or inside a <style> tag */
.feature-label {
  background-color: rgba(255,
      255,
      255,
      0.4);
  /* semi-transparent white background */
  color: #080707;
  /* dark text */
  border: 1px solid #ccc;
  /* light border */
  border-radius: 4px;
  /* rounded corners */
  padding: 1px 2px;
  /* some padding */
  font-size: 10px;
  /* smaller font size */
  font-weight: bold;
  /* bold text */
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
  /* subtle shadow */
  white-space: nowrap;
  /* keep text in one line */
  pointer-events: none;
  /* prevents tooltip from interfering with map clicks */
}

#logo {
  position: absolute;
  z-index: 10003 !important;
  width: 40px;
  height: 40px;
  top: 5px;
  left: 10px;
  padding: 3px;
  opacity: 0;
  animation: logoFadeIn 2s forwards;
}

@keyframes logoFadeIn {
  0% {
    opacity: 0;
    transform: translateX(-30px);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

#logo1 {
  position: absolute;
  z-index: 10003 !important;
  width: 40px;
  height: 40px;
  top: 5px;
  right: 10px;
  padding: 3px;
  opacity: 0;
  animation: logo1FadeIn 2s forwards;
}

@keyframes logo1FadeIn {
  0% {
    opacity: 0;
    transform: translateX(30px);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* /////////////////////////////////// */

.right-8 {
  right: 1px !important;
}

/* .w-80 {
  width: 15rem !important;
} */

.leaflet-tooltip.black-district-label {
  background: none !important;
  color: red !important;
  font-weight: bold;
  font-size: 11px;
  font-family: sans-serif;

  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;

  padding: 0px 2px !important;
  /* tight horizontal padding */
  line-height: 1 !important;
  pointer-events: none;
  /*text-shadow:
    -1px -1px 0 white,
    1px -1px 0 white,
    -1px 1px 0 white,
    1px 1px 0 white; */
}


.highway-label {
  color: black !important;
  font-weight: bold;
  font-size: 12px;
  text-shadow: 1px 1px 2px white;
}

.text-sm {
  font-size: 0.7rem !important;
  line-height: 1rem !important;
}

.p-2\.5 {
  padding: 0.4rem !important;
}

.w-64 {
  width: 13rem !important;
}

.left-64 {
  left: 13rem !important;
}

.w-\[calc\(100\%-16rem\)\] {
  width: calc(100% - 13rem) !important;
}

.right-64 {
  right: 13rem !important;
}

.w-\[calc\(100\%-32rem\)\] {
  width: calc(100% - 26rem) !important;
}

/* Water Supply*/
.line-label {
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 1px 1px 2px white;
}

/* Road Network  */
.road-label {
   /*background: transparent; */
  text-shadow: 1px 1px 2px #fff;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 10px;
  color: #000;
  font-weight: bold;
  
}

.label-nh {
  color: #e6b800;
}

.label-sh {
  color: #cc0000;
}

.label-dr {
  color: #008000;
}


#map {
  width: 100%;
  height: 100vh;
  /* full viewport height */
}

/* Enhanced Responsive Design for All Devices */

/* Large Desktop (1440px and up) */
@media (min-width: 1440px) {
  header h1 {
    font-size: 24px;
  }

  header p {
    font-size: 14px;
  }

  .tools-container {
    left: 15px;
  }

  #toc {
    width: 13rem !important;
  }

  .w-64 {
    width: 13rem !important;
  }
}

/* Desktop (1200px - 1439px) */
@media (max-width: 1439px) and (min-width: 1200px) {
  header h1 {
    font-size: 22px;
  }

  header p {
    font-size: 12px;
  }
}

/* Large Laptop (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
  .tools-container {
    left: 8px;
  }

  header h1 {
    font-size: 20px;
  }

  header p {
    font-size: 11px;
  }

  #toc {
    width: 15rem;
  }

  .w-64 {
    width: 15rem !important;
  }
}

/* Tablet Landscape (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
  .tools-container {
    left: 5px;
    padding: 3px;
  }

  .tool-button {
    width: 35px;
    height: 35px;
    font-size: 14px;
    line-height: 35px;
  }

  header h1 {
    font-size: 18px;
  }

  header p {
    font-size: 10px;
  }

  #toc {
    width: 12rem;
  }

  .w-64 {
    width: 12rem !important;
  }

  #divSearch {
    width: 16rem;
  }

  #divLegend {
    width: 14rem;
  }

  #divPrint {
    width: 18rem;
  }
}

/* Tablet Portrait (576px - 767px) */
@media (max-width: 767px) and (min-width: 576px) {
  body {
    font-size: 12px;
  }

  .tools-container {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 8px;
  }

  .tools-grid {
    flex-direction: row;
    gap: 8px;
  }

  .tool-button {
    width: 40px;
    height: 40px;
    font-size: 16px;
    line-height: 40px;
    border-radius: 50%;
  }

  header {
    height: 45px;
    padding: 3px 8px;
  }

  header h1 {
    font-size: 16px;
    line-height: 1.2;
  }

  header p {
    font-size: 9px;
  }

  #logo,
  #logo1 {
    width: 35px;
    height: 35px;
    top: 5px;
  }

  #map {
    height: calc(100vh - 45px) !important;
    top: 45px !important;
  }

  #toc {
    width: 16rem;
    height: calc(100vh - 45px) !important;
    margin-top: 45px !important;
  }

  .w-64 {
    width: 16rem !important;
  }

  #divSearch {
    width: 20rem;
    top: 60px !important;
  }

  #divLegend {
    width: 16rem;
    top: 60px !important;
  }

  #divPrint {
    width: 20rem;
    top: 80px !important;
  }

  .accordion {
    font-size: 0.9rem;
  }

  .accordion-content {
    padding-left: 15px;
  }
}

/* Mobile Large (480px - 575px) */
@media (max-width: 575px) and (min-width: 480px) {
  body {
    font-size: 11px;
  }

  .tools-container {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 6px;
  }

  .tools-grid {
    flex-direction: row;
    gap: 6px;
  }

  .tool-button {
    width: 35px;
    height: 35px;
    font-size: 14px;
    line-height: 35px;
    border-radius: 50%;
  }

  header {
    height: 42px;
    padding: 2px 6px;
  }

  header h1 {
    font-size: 14px;
    line-height: 1.1;
  }

  header p {
    font-size: 8px;
  }

  #logo,
  #logo1 {
    width: 32px;
    height: 32px;
    top: 5px;
  }

  #map {
    height: calc(100vh - 42px) !important;
    top: 42px !important;
  }

  #toc {
    width: calc(100vw - 20px);
    height: calc(100vh - 42px) !important;
    margin-top: 42px !important;
    left: -calc(100vw - 20px);
  }

  .w-64 {
    width: calc(100vw - 20px) !important;
  }

  #divSearch {
    width: calc(100vw - 40px);
    left: 20px;
    transform: none;
    top: 55px !important;
  }

  #divLegend {
    width: calc(100vw - 40px);
    right: 20px;
    top: 55px !important;
  }

  #divPrint {
    width: calc(100vw - 40px);
    right: 20px;
    top: 75px !important;
  }

  .accordion {
    font-size: 0.85rem;
  }

  .accordion-content {
    padding-left: 10px;
    font-size: 0.8rem;
  }
}

/* Mobile Small (320px - 479px) */
@media (max-width: 479px) {
  body {
    font-size: 10px;
  }

  .tools-container {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 4px;
  }

  .tools-grid {
    flex-direction: row;
    gap: 4px;
  }

  .tool-button {
    width: 30px;
    height: 30px;
    font-size: 12px;
    line-height: 30px;
    border-radius: 50%;
  }

  header {
    height: 38px;
    padding: 2px 4px;
  }

  header h1 {
    font-size: 12px;
    line-height: 1.1;
  }

  header p {
    font-size: 7px;
  }

  #logo,
  #logo1 {
    width: 28px;
    height: 28px;
    top: 5px;
  }

  #map {
    height: calc(100vh - 38px) !important;
    top: 38px !important;
  }

  #toc {
    width: calc(100vw - 10px);
    height: calc(100vh - 38px) !important;
    margin-top: 38px !important;
    left: -calc(100vw - 10px);
  }

  .w-64 {
    width: calc(100vw - 10px) !important;
  }

  #divSearch {
    width: calc(100vw - 20px);
    left: 10px;
    transform: none;
    top: 50px !important;
  }

  #divLegend {
    width: calc(100vw - 20px);
    right: 10px;
    top: 50px !important;
  }

  #divPrint {
    width: calc(100vw - 20px);
    right: 10px;
    top: 70px !important;
  }

  .accordion {
    font-size: 0.8rem;
  }

  .accordion-content {
    padding-left: 8px;
    font-size: 0.75rem;
  }

  .accordion-header {
    padding: 8px;
  }

  .popup-table {
    font-size: 8px;
  }

  .leaflet-popup-content-wrapper {
    width: 150px;
    max-height: 200px;
  }
}

/* Ultra-wide screens (2560px and up) */
@media (min-width: 2560px) {
  header h1 {
    font-size: 28px;
  }

  header p {
    font-size: 16px;
  }

  .tools-container {
    left: 20px;
  }

  .tool-button {
    width: 50px;
    height: 50px;
    font-size: 20px;
    line-height: 50px;
  }

  #toc {
    width: 20rem;
  }

  .w-64 {
    width: 20rem !important;
  }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  header {
    height: 35px;
  }

  header h1 {
    font-size: 12px;
  }

  header p {
    font-size: 7px;
  }

  #logo,
  #logo1 {
    width: 25px;
    height: 25px;
    top: 5px;
  }

  #map {
    height: calc(100vh - 35px) !important;
    top: 35px !important;
  }

  #toc {
    height: calc(100vh - 35px) !important;
    margin-top: 35px !important;
  }

  .tools-container {
    bottom: 5px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
  .feature-label {
    font-size: 11px;
  }

  .leaflet-tooltip.black-district-label {
    font-size: 12px;
  }

  .highway-label {
    font-size: 13px;
  }
}

/* AP
TRANSCO Electricity Transmission Layer Styles */
.legend-item.aptransco-400kv-lines,
.legend-item.aptransco-220kv-lines,
.legend-item.aptransco-132kv-substations,
.legend-item.aptransco-220kv-substations,
.legend-item.aptransco-400kv-substations {
  align-items: center;
}

/* Transmission line legend colors */
.aptransco-400kv-lines .legend-item-color {
  background-color: #FF0000 !important;
  /* Red for 400KV */
  height: 3px !important;
}

.aptransco-220kv-lines .legend-item-color {
  background-color: #FF8C00 !important;
  /* Orange for 220KV */
  height: 3px !important;
}

/* Substation legend colors */
.aptransco-132kv-substations .legend-item-color {
  background-color: #00FF00 !important;
  /* Green for 132KV - matching transmission lines */
  border-radius: 50% !important;
  width: 12px !important;
  height: 12px !important;
}

.aptransco-220kv-substations .legend-item-color {
  background-color: #FF8C00 !important;
  /* Orange for 220KV */
  border-radius: 50% !important;
  width: 16px !important;
  height: 16px !important;
}

.aptransco-400kv-substations .legend-item-color {
  background-color: #FF0000 !important;
  /* Red for 400KV */
  border-radius: 50% !important;
  width: 20px !important;
  height: 20px !important;
}

/* 
Hierarchical checkbox styling for APTRANSCO layers */
.accordion-content ul ul {
  border-left: 2px solid #e2e8f0;
  padding-left: 0.5rem;
}

.accordion-content ul ul li {
  position: relative;
}

.accordion-content ul ul li:before {
  content: '';
  position: absolute;
  left: -0.5rem;
  top: 0.75rem;
  width: 0.5rem;
  height: 1px;
  background-color: #e2e8f0;
}

/* Indeterminate checkbox styling */
input[type="checkbox"]:indeterminate {
  background-color: #3b82f6;
  border-color: #3b82f6;
}

input[type="checkbox"]:indeterminate:after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 2px;
  background-color: white;
  transform: translate(-50%, -50%);
}

/* Touch and Accessibility Enhancements */
@media (hover: none) and (pointer: coarse) {

  /* Touch devices */
  .tool-button {
    min-height: 44px;
    min-width: 44px;
  }

  .accordion-header {
    min-height: 44px;
    padding: 12px;
  }

  input[type="checkbox"] {
    min-height: 20px;
    min-width: 20px;
  }

  select {
    min-height: 44px;
    font-size: 16px;
    /* Prevents zoom on iOS */
  }

  button {
    min-height: 44px;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  header {
    animation: none;
    opacity: 1;
    transform: none;
  }

  #logo,
  #logo1 {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .tools-container {
    background: rgba(30, 30, 30, 0.95);
    border-color: #444;
  }

  .tool-button {
    background: #333;
    color: #fff;
  }

  .tool-button:hover {
    background: #555;
  }

  .custom-tooltip {
    background: rgba(30, 30, 30, 0.9);
  }
}

/* Container queries for modern browsers */
@supports (container-type: inline-size) {
  .accordion {
    container-type: inline-size;
  }

  @container (max-width: 200px) {
    .accordion-content {
      font-size: 0.7rem;
      padding-left: 5px;
    }
  }
}

/* Flexible grid system for panels */
.responsive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

@media (max-width: 768px) {
  .responsive-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.5rem;
  }
}

/* Improved focus indicators for accessibility */
button:focus,
input:focus,
select:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  z-index: 10000;
}

.skip-link:focus {
  top: 6px;
}

/* Ensure minimum contrast ratios */
.text-low-contrast {
  color: #666;
}

@media (prefers-contrast: high) {
  .text-low-contrast {
    color: #000;
  }

  .accordion-item {
    border: 2px solid #000;
  }
}

/* Responsive typography scale */
html {
  font-size: clamp(14px, 2.5vw, 18px);
}

/* Flexible spacing system */
.space-responsive {
  margin: clamp(0.5rem, 2vw, 2rem);
  padding: clamp(0.25rem, 1vw, 1rem);
}

/* Responsive images */
img {
  max-width: 100%;
  height: auto;
}

/* Prevent horizontal scroll */
body {
  overflow-x: hidden;
}

/* Smooth scrolling for better UX */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* 
Responsive utility classes */
.hide-mobile {
  display: block;
}

.show-mobile {
  display: none;
}

@media (max-width: 767px) {
  .hide-mobile {
    display: none;
  }

  .show-mobile {
    display: block;
  }
}

/* Responsive sidebar behavior */
@media (max-width: 767px) {
  #toc.sidebar-open {
    left: 0 !important;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  }

  #toc.sidebar-open+#map {
    filter: blur(2px);
    pointer-events: none;
  }

  /* Overlay for mobile sidebar */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 19;
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

/* Responsive panel positioning */
@media (max-width: 575px) {

  #divSearch.panel-open,
  #divLegend.panel-open,
  #divPrint.panel-open {
    position: fixed;
    top: 50px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    transform: none !important;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    z-index: 1000;
  }
}

/* Responsive form elements */
@media (max-width: 575px) {

  select,
  input[type="text"],
  input[type="email"],
  input[type="tel"] {
    font-size: 16px;
    /* Prevents zoom on iOS */
    padding: 12px;
    border-radius: 8px;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row>* {
    width: 100% !important;
    margin-bottom: 8px;
  }
}

/* Responsive table behavior */
@media (max-width: 575px) {
  .popup-table {
    font-size: 10px;
  }

  .popup-table td,
  .popup-table th {
    padding: 4px 2px;
  }

  /* Stack table cells vertically on very small screens */
  .popup-table.stack-mobile {
    display: block;
  }

  .popup-table.stack-mobile tr {
    display: block;
    border: 1px solid #ccc;
    margin-bottom: 8px;
  }

  .popup-table.stack-mobile td {
    display: block;
    text-align: left;
    border: none;
    padding: 4px 8px;
  }

  .popup-table.stack-mobile td:before {
    content: attr(data-label) ": ";
    font-weight: bold;
  }
}

/* Responsive map controls */
@media (max-width: 575px) {
  .leaflet-control-container {
    font-size: 12px;
  }

  .leaflet-control-zoom {
    margin-left: 5px !important;
    margin-top: 5px !important;
  }

  .leaflet-control-zoom a {
    width: 35px !important;
    height: 35px !important;
    line-height: 35px !important;
    font-size: 16px !important;
  }
}

/* Performance optimizations for mobile */
@media (max-width: 767px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }

  .leaflet-container {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
  }
}

/* Responsive loading screen */
@media (max-width: 575px) {
  #splash-screen img {
    width: 80px;
    height: 80px;
  }

  #splash-screen h1 {
    font-size: 18px;
  }
}

/* Responsive coordinate display */
@media (max-width: 575px) {
  #latlong {
    font-size: 10px;
    padding: 2px 4px;
  }
}

/* Responsive info panels */
@media (max-width: 575px) {

  #nearby-info,
  #rout-instruction,
  #availability-info {
    max-width: 90%;
    font-size: 10px;
    padding: 3px;
  }

  #nearby-info {
    left: 50%;
    transform: translateX(-50%);
  }

  #availability-info {
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Responsive animations */
@media (max-width: 575px) {
  @keyframes headerFadeIn {
    0% {
      opacity: 0;
      transform: translateY(-15px);
    }

    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes logoFadeIn {
    0% {
      opacity: 0;
      transform: translateX(-15px);
    }

    100% {
      opacity: 1;
      transform: translateX(0);
    }
  }

  @keyframes logo1FadeIn {
    0% {
      opacity: 0;
      transform: translateX(15px);
    }

    100% {
      opacity: 1;
      transform: translateX(0);
    }
  }
}

/* Mobile sidebar close button */
.sidebar-close-btn {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  background: rgba(255, 255, 255, 0.9) !important;
  border: none !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 50% !important;
  font-size: 20px !important;
  cursor: pointer !important;
  z-index: 1000 !important;
  display: none !important;
}

@media (max-width: 767px) {
  .sidebar-close-btn {
    display: block !important;
  }
}

/* No hover effects on touch devices */
.no-hover *:hover {
  background-color: initial !important;
  color: initial !important;
}

/* Performance optimizations */
.mobile-device * {
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

/* Responsive font scaling */
.mobile h1 {
  font-size: clamp(12px, 4vw, 16px) !important;
}

.mobile p {
  font-size: clamp(7px, 2.5vw, 10px) !important;
}

.tablet h1 {
  font-size: clamp(16px, 3vw, 20px) !important;
}

.tablet p {
  font-size: clamp(9px, 2vw, 12px) !important;
}

/* Responsive spacing */
.mobile .accordion-content {
  padding: clamp(5px, 2vw, 10px) !important;
}

.mobile .accordion-header {
  padding: clamp(8px, 3vw, 12px) !important;
}

/* Responsive button sizing */
.mobile .tool-button {
  width: clamp(28px, 8vw, 35px) !important;
  height: clamp(28px, 8vw, 35px) !important;
  font-size: clamp(10px, 3vw, 14px) !important;
}

/* Responsive panel sizing */
.mobile #divSearch,
.mobile #divLegend,
.mobile #divPrint {
  width: calc(100vw - 20px) !important;
  left: 10px !important;
  right: 10px !important;
  transform: none !important;
}

/* Responsive map controls */
.mobile .leaflet-control-zoom a {
  width: clamp(30px, 8vw, 40px) !important;
  height: clamp(30px, 8vw, 40px) !important;
  line-height: clamp(30px, 8vw, 40px) !important;
  font-size: clamp(14px, 4vw, 18px) !important;
}

/* Responsive coordinate display */
.mobile #latlong {
  font-size: clamp(8px, 2.5vw, 12px) !important;
  padding: clamp(1px, 1vw, 4px) !important;
}

/* Responsive loading screen */
.mobile #splash-screen img {
  width: clamp(60px, 20vw, 100px) !important;
  height: clamp(60px, 20vw, 100px) !important;
}

.mobile #splash-screen h1 {
  font-size: clamp(14px, 5vw, 20px) !important;
}

/* Responsive table styling */
.mobile .popup-table {
  font-size: clamp(8px, 2.5vw, 12px) !important;
}

.mobile .popup-table td,
.mobile .popup-table th {
  padding: clamp(2px, 1vw, 6px) !important;
}

/* Responsive form elements */
.mobile select,
.mobile input {
  font-size: 16px !important;
  /* Prevents zoom on iOS */
  padding: clamp(8px, 3vw, 12px) !important;
}

/* Responsive accordion */
.mobile .accordion {
  font-size: clamp(0.7rem, 2.5vw, 0.9rem) !important;
}

/* Responsive legend */
.mobile .legend-item {
  margin-bottom: clamp(3px, 1.5vw, 8px) !important;
}

.mobile .legend-item-color {
  width: clamp(15px, 5vw, 25px) !important;
  height: clamp(12px, 4vw, 20px) !important;
}

/* Responsive tooltips */
.mobile .custom-tooltip {
  font-size: clamp(10px, 3vw, 14px) !important;
  padding: clamp(4px, 2vw, 8px) clamp(6px, 3vw, 12px) !important;
}

/* Responsive info panels */
.mobile #nearby-info,
.mobile #rout-instruction,
.mobile #availability-info {
  font-size: clamp(8px, 2.5vw, 12px) !important;
  padding: clamp(2px, 1vw, 5px) !important;
  border-radius: clamp(3px, 1.5vw, 8px) !important;
}

/* Responsive popup content */
.mobile .leaflet-popup-content-wrapper {
  width: clamp(120px, 80vw, 200px) !important;
  max-height: clamp(150px, 60vh, 250px) !important;
}

.mobile .leaflet-popup-content {
  padding: clamp(5px, 2vw, 10px) !important;
  font-size: clamp(8px, 2.5vw, 12px) !important;
}

/* Responsive animations for mobile */
@media (max-width: 575px) {
  * {
    animation-duration: 0.3s !important;
    transition-duration: 0.3s !important;
  }
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
  .tool-button {
    border: 2px solid #000 !important;
  }

  .accordion-header {
    border: 1px solid #000 !important;
  }

  header {
    border-bottom: 2px solid #000 !important;
  }
}

/* Reduced transparency for better readability on mobile */
@media (max-width: 575px) {
  .bg-opacity-50 {
    background-color: rgba(255, 255, 255, 0.9) !important;
  }

  .bg-opacity-80 {
    background-color: rgba(255, 255, 255, 0.95) !important;
  }

  .bg-opacity-95 {
    background-color: rgba(255, 255, 255, 1) !important;
  }
}

/* Search By Plot Button - Enhanced Styling */
.plot-query-button {
  position: absolute;
  top: 15px;
  right: -10px;
  z-index: 1000;
  background: linear-gradient(135deg, #c78ad4 0%, #3540e7 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 140px;
  overflow: hidden;
  position: relative;
}

.plot-query-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.6s;
}

.plot-query-button:hover::before {
  left: 100%;
}

.plot-query-button:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 6px 25px rgba(37, 99, 235, 0.6);
  transform: translateY(-2px) scale(1.03);
}

.plot-query-button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.plot-query-button.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.5);
  animation: pulse-active 2s infinite;
}

@keyframes pulse-active {
  0%, 100% {
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.5);
  }
  50% {
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.7);
  }
}

.plot-query-button i {
  font-size: 16px;
  transition: transform 0.3s ease;
}

.plot-query-button:hover i {
  transform: scale(1.15) rotate(10deg);
}

.plot-query-button .button-label {
  font-weight: 600;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments for Plot Query Button */
@media (max-width: 768px) {
  .plot-query-button {
    top: 60px;
    right: 10px;
    padding: 10px 14px;
    font-size: 12px;
    min-width: 130px;
  }
  
  .plot-query-button i {
    font-size: 15px;
  }
}

@media (max-width: 576px) {
  .plot-query-button {
    top: 55px;
    right: 8px;
    padding: 10px 12px;
    font-size: 11px;
    min-width: 48px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    justify-content: center;
  }
  
  .plot-query-button .button-label {
    display: none;
  }
  
  .plot-query-button i {
    font-size: 18px;
  }
}

/* Touch device optimization */
.touch-device .plot-query-button {
  min-height: 48px;
  min-width: 48px;
}

/* Draggable panels styling */
#pq-panel-header:hover,
#pq-results-header-drag:hover {
  background: rgba(243, 244, 246, 0.5);
  border-radius: 4px;
}

#pq-panel-header:active,
#pq-results-header-drag:active {
  background: rgba(229, 231, 235, 0.7);
  cursor: grabbing !important;
}

/* Prevent text selection while dragging */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Grip icon styling */
.fa-grip-vertical {
  transition: color 0.2s;
}

#pq-panel-header:hover .fa-grip-vertical,
#pq-results-header-drag:hover .fa-grip-vertical {
  color: #6b7280 !important;
}

/* Smooth transitions for panels */
#pq-panel,
#pq-result-popup {
  transition: opacity 0.2s, box-shadow 0.2s;
}

#pq-panel:hover,
#pq-result-popup:hover {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Plot Query Panel Enhancements */
#pq-panel {
  backdrop-filter: blur(10px);
}

#pq-panel select,
#pq-panel input {
  transition: all 0.2s;
}

#pq-panel select:hover,
#pq-panel input:hover {
  border-color: #2563eb;
}

#pq-panel select:focus,
#pq-panel input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#pq-panel button:hover {
  transform: translateY(-1px);
}

#pq-panel button:active {
  transform: translateY(0);
}

/* Results Table Enhancements */
#pq-result-popup {
  backdrop-filter: blur(10px);
}

#pq-results-table::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#pq-results-table::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

#pq-results-table::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

#pq-results-table::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Legend Item Hover Effects */
.pq-legend-item {
  user-select: none;
}

.pq-legend-item:active {
  transform: scale(0.98);
}

/* Responsive Panel Adjustments */
@media (max-width: 768px) {
  #pq-panel {
    width: 240px !important;
    left: 10px !important;
    top: 100px !important;
  }
  
  #pq-result-popup {
    width: calc(100vw - 40px) !important;
    right: 20px !important;
    left: 20px !important;
    bottom: 20px !important;
    max-height: 50vh !important;
  }
}

@media (max-width: 576px) {
  #pq-panel {
    width: calc(100vw - 20px) !important;
    left: 10px !important;
    top: 80px !important;
    max-width: 300px;
  }
  
  #pq-result-popup {
    width: calc(100vw - 20px) !important;
    right: 10px !important;
    left: 10px !important;
    bottom: 10px !important;
    max-height: 60vh !important;
  }
}

/* Print Styles for Query Results */
@media print {
  #pq-panel,
  #plot-query-btn {
    display: none !important;
  }
  
  #pq-result-popup {
    position: static !important;
    width: 100% !important;
    max-height: none !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  
  #pq-results-table {
    max-height: none !important;
    overflow: visible !important;
  }
}
