  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@100..900&family=Open+Sans:ital,wght@0,300..800;1,300..800&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');
  @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css');
html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*, *::before, *::after {
  box-sizing: inherit;
}

    /* === Basic layout & reset === */
    *{box-sizing:border-box}
    body{
      margin:0;
      font-family:"Tahoma","Arial",sans-serif;
      background:#f5f5f5;
      height:100vh;
      display:flex;
      align-items:center;
      justify-content:center;
      direction:rtl;
    }
    .container{
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;       /* instead of fixed 92vh */
    max-width: 100%;     /* instead of 1400px */
    margin: 0;           /* remove auto-centering */
    background: #fff;
    }

    /* === Topbar (search + dropdowns) === */
    .topbar{
      display:flex;
      align-items:center;
      gap:16px;
      padding:16px 20px;
      border-bottom:1px solid #eee;
      background:#fff;
      flex:0 0 auto;
      flex-wrap:wrap;
    }
    .search-wrapper{flex:0 0 39%;position:relative;min-width:250px;max-width: 39%;}
    .search-wrapper input{
      width:100%;padding:14px 40px 14px 14px;
      border:1px solid #ccc;border-radius:12px;
      font-size:14px;outline:none;background:#fff;
    }
    .search-wrapper label{
      position:absolute;right:40px;top:50%;transform:translateY(-50%);
      background:#fff;padding:0 6px;color:#888;font-size:14px;
      pointer-events:none;transition:.2s ease;
    }
    .search-wrapper input:focus+label,
    .search-wrapper input:not(:placeholder-shown)+label{
      top:-6px;right:16px;font-size:12px;color:#555;
    }
    .search-wrapper .search-icon{
      position:absolute;right:12px;top:50%;transform:translateY(-50%);
      width:18px;height:18px;opacity:.65;pointer-events:none;
    }

    /* === Dropdowns === */
    .select-wrapper{min-width:280px;max-width:300px;position:relative;flex:0 0 auto;}
    .select-toggle{
      width:100%;padding:12px 36px 12px 14px;
      border:1px solid #ddd;border-radius:12px;
      background:#fafafa;font-size:16px;
      text-align:right;display:flex;
      align-items:center;justify-content:space-between;
      cursor:pointer;
    }
    .select-wrapper.warning .select-toggle{border-color:red;}
    .warning-text{
      font-size:12px;color:red;margin-top:4px;
      display:none;
    }
    .select-wrapper.warning .warning-text{display:block;}

    .select-chevron{position:absolute;left:14px;top:50%;transform:translateY(-50%);font-size:13px;color:#666;}
    .select-options{
      position:absolute;right:0;top:calc(65% + 8px);
      width:100%;background:#f0f6ff;border:1px solid #e6e6e6;
      border-radius:12px;box-shadow:0 10px 26px rgba(0,0,0,.12);
      padding:6px;display:none;max-height:300px;
      overflow-y:auto;z-index:5000; /* ensure above map */
      direction: ltr; text-align: right;
      cursor: pointer;
    }
    .select-wrapper.open .select-options{display:block;}
    .select-option{
      padding:10px 12px;border-radius:10px;
      cursor:pointer;font-size:15px;text-align:right;color:#222;
    }
    .select-option:hover{background:#f5f5f5;}
    .select-option[aria-selected="true"]{background:#f7f4ef;border:1px solid #c2b49a;}
    .select-option:hover {
      border-radius: 12px;
      background-color: #e2e2e6; /* optional subtle bg */
    }
    .select-option img {
      width: 24px;
      height: 16px;
      margin-left: 6px; 
      vertical-align:middle;
      border: 1px solid #d6d6d6;
      border-radius:3px;
    }
    .select-label img {      
      width: 24px;
      height: 16px;
      margin-left: 6px; 
      vertical-align:middle;
      border: 1px solid #d6d6d6;
      border-radius:3px;
      margin-inline-end: 8px;
      
    }


    /* === Main layout === */
    .main{display:flex;flex:1;overflow: hidden;}
    #map{flex:0 0 60%; height:100%;}
    .sidebar{
      flex:0 0 40%;
      padding:0 18px 18px 18px; /* keep counter at top */
      overflow-y:auto;
      border-left:1px solid #eee;background:#fff;
      text-align:right;
      width: 350px;        
      height: 100%;        
     overflow-y: auto;
    }

    /* store counter */
    #store-counter {
      font-family: "Noto Sans Arabic", sans-serif;
      font-size: 18px;
      font-weight: 700;
      color: #333;
      padding: 14px 20px;
      border-bottom: 1px solid #eee;
      background: #fff;
      text-align: right;
    }

    /* === Store list === */
    .store-list-inner { padding: 12px 0; } /* container for items */
    .store{
      display:flex;align-items:center;justify-content:space-between;
      gap:16px;padding:16px 20px;margin:0; /* margin managed by separator */
      border-radius:12px;border:2px solid transparent;
      cursor:pointer;background:#fff;transition:all .15s ease;
      position:relative;
    }

    /* separator line shorter length */
  
    .store::after {
      content: none;
    }

    /* Use this for all stores except the last one */
    .store + .store {
      border-top: 1px solid #ddd;   /* light gray line */
      margin-top: 10px;             /* spacing */
      padding-top: 10px;            /* spacing so line sits between cards */
      border-radius: 0px;
    }
    /* When store is active, remove the top border */
    .store.active {
      border: 2px solid #c2b49a;
      background: #f7f4ef;
    }
    .store.active + .store {
      border-top: none;  /* hide separator under active store */
      margin-top: 0;     /* prevent double spacing */
      padding-top: 20px;
    }

    .store:last-child::after { display:none; }

    .store:hover{background:#fafafa;}
    .store.active{border-color:#c2b49a;background:#f7f4ef;padding:14px 18px;border-radius:12px;}

    .store-left{flex:1;min-width:0;}
    .store-left h3{margin:0 0 8px 0;font-size:18px;font-weight:700;color:#222;word-break:break-word;}
    .store-left p{margin:6px 0;font-size:15px;color:#555;display:flex;align-items:center;gap:6px;}
    .store-left img.icon{width:20px;height:20px;}
    .store-right a {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 6px 12px;
      border: 1px solid #d9d9d9;   /* black border, no background */
      border-radius: 25px;      /* pill shape */
      background: transparent; 
      color: #000;
      font-family: "Noto Sans Arabic", sans-serif;
      font-size: 16px;
      font-weight: bold;
      text-decoration: none;
    }
    .store-right a:hover {
    background: #d9d9d9;   /* white background on hover */
    }
    .store-right img{width:18px;height:18px;display:block;}

    /* === Popup === */
    .leaflet-popup-content-wrapper{border-radius:12px !important;box-shadow:0 6px 24px rgba(0,0,0,.14);}
    .leaflet-popup-close-button{right:8px !important;top:8px !important;background:#fff;border-radius:50%;width:26px;height:26px;box-shadow:0 1px 4px rgba(0,0,0,.12);}
    .popup-card{padding:14px;max-width:300px;direction:rtl;text-align:right;}
    .popup-card h3{margin:0 0 8px;font-size:16px;}
    .popup-card p{margin:6px 0;font-size:14px;display:flex;align-items:center;gap:6px;}
    .popup-card img.icon{width:16px;height:16px;}
    .popup-card .button{
      display:flex;align-items:center;justify-content:center;cursor: pointer;
      margin:12px auto 0 auto;width:80%;
      padding:10px 14px;border-radius:25px;
      background:#000;color:#fff;
      font-size:14px;font-weight:bold;text-decoration:none;font-family: "Noto Sans Arabic", sans-serif;
      transition-property: background-color,border-color,color,box-shadow,filter;transition-duration: .3s;
    }

    .popup-card .button:hover{background-color: #181919;}

    /* locate control on map */
    .leaflet-control-locate {
      position: absolute;
      bottom: 40px;
      right: 10px;
      z-index: 6000; /* above controls and dropdowns */
    }
    #locateMe {
      background: #fff;
      border: 1px solid #ccc;
      border-radius: 50%;
      width: 42px;
      height: 42px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      box-shadow: 0 2px 6px rgba(0,0,0,.12);
    }
    #locateMe img { width:20px; height:20px; }

    .pulse-dot {
      width: 14px;
      height: 14px;
      background: #2a93ff;
      border: 3px solid #fff;
      border-radius: 50%;
      box-shadow: 0 0 8px rgba(42,147,255,.25);
      animation: pulse 2s infinite;
    }
    @keyframes pulse {
      0% { transform: scale(1); opacity: 1; }
      50% { transform: scale(1.4); opacity: 0.6; }
      100% { transform: scale(1); opacity: 1; }
    }
      #store-counter {
        font-family: "Noto Sans Arabic", sans-serif;
        font-size: 25px;
        font-weight: 900;
        color: #333;
        padding: 18px 20px;   /* same padding as stores */
        border-bottom: 1px solid #eee;
        background: #fff;
        text-align: right;
    }
      .header {
        width: 100%;
        background: #fff;
        padding: 12px 0;
        text-align: center;
    }

      .header .logo {
        max-height: 100px; /* adjust logo size */
        cursor: pointer;
        transition: transform 0.2s ease;
    }

      .header .logo:hover {
        transform: scale(1.05);
    }



  /* Custom fullscreen button icon */
  .leaflet-control-zoom-fullscreen.fullscreen-icon {
  background-image: url("assets/fullscreen.png") !important;
  background-size: 22px 22px !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  }

  /* Active (Exit Full Screen) */
  .leaflet-control-zoom-fullscreen.fullscreen-icon[title="Exit Full Screen"] {
  background-image: url("assets/exit-fullscreen.png") !important;
  background-size: 22px 22px !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  }

  .leaflet-control-zoom{
  background: #fff !important;
  border: 1px solid #ccc !important;
  border-radius: 50% !important;
  box-shadow: 0 2px 6px rgba(0,0,0,.12) !important;
 }

  #loader {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  }

  #loader .spinner {
  width: 50px;
  height: 50px;
  border: 6px solid #ccc;
  border-top: 6px solid #c2b49a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
  to { transform: rotate(360deg); }
  }

/* ==============================
   Error Popup 
   ============================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(5px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.popup {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 16px;
  padding: 40px 30px;
  width: 340px;
  max-width: 90%;
  text-align: center;
  color: #333;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: scale(0.85);
  transition: all 0.4s ease;
}

.popup.show {
  opacity: 1;
  transform: scale(1);
}

.popup .icon {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.popup .icon img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.popup h2 {
  margin: 10px 0 5px;
  font-size: 22px;
}

.popup p {
  font-size: 15px;
  color: #555;
  margin-bottom: 25px;
}

.popup button {
  background: rgba(255, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  border: 0px solid rgba(255, 255, 255, 0.4);
  color: #d32f2f;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: 50px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.popup button:hover {
  background: rgba(255, 0, 0, 0.3);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.popup button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  transition: 0.4s ease;
}

.popup button:active::after {
  width: 200px;
  height: 200px;
  opacity: 0;
}

.popup .close {
  position: absolute;
  top: 12px;
  right: 15px;
  font-size: 20px;
  cursor: pointer;
  color: #999;
  font-weight: bold;
}

.popup .close:hover {
  color: #333;
}

/* ---------- Mobile & Tablet responsive rules (max-width:900px) ---------- */
/* These rules are mobile-first additions only; desktop rules are untouched. */

:root{
  /* responsive font scaling */
  --fs-xs: clamp(12px, 1.8vw, 14px);
  --fs-sm: clamp(13px, 2.1vw, 15px);
  --fs-base: clamp(14px, 2.4vw, 16px);
  --fs-lg: clamp(16px, 3vw, 18px);
}

/* Ensure larger font on input to prevent iOS zoom on focus (16px) */
.search-wrapper input { font-size: 16px; }

/* general improvements to dropdowns */
.select-options {
  -webkit-overflow-scrolling: touch; /* smooth mobile scroll */
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.25) transparent;
}

/* style native-like visible scrollbars for WebKit */
.select-options::-webkit-scrollbar { height:8px; width:8px; }
.select-options::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius:8px; }
.select-options::-webkit-scrollbar-track { background: transparent; }



/* ---------- Layout: STACKED 3 sections for mobile/tablet ---------- */
/* Top bar (logo + search + dropdowns), Map, Sidebar (list) */


/* tiny tweak for small tablets in between */
@media (min-width: 501px) and (max-width: 1023px) {
    .container{
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 8px;
  }

  /* Top section stack */
  .topbar{
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    align-items: flex-start;
  }

   .header .logo {
      max-height: 100px; /* adjust logo size */
      cursor: pointer;
      transition: transform 0.2s ease;
      pointer-events: auto;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
      display: block; /* Ensures it fills its clickable area */
      z-index: 1000; /* Only needed if it's under something */
    }

      .header .logo:hover {
        transform: scale(1.05);
    }

  /* Search directly below logo */
  .search-wrapper{
    min-width: 250px;
    max-width: 1023px;
    margin-bottom:8px;
    flex: 1 1 100%;
  }
  .search-wrapper input{
    width:100%;
    font-size:16px;
  }

  /* Dropdowns layout: side-by-side if space allows, otherwise stacked */
   .select-wrapper{ 
      display: flex;
      gap:8px;
      flex-wrap:wrap;
      flex-direction: row;
      align-items:flex-start;
      justify-content:space-between;
      margin-top: 8px;
      flex: 0 0 auto;
      max-width: none;
      width: 100%;
      min-width: 0; 
      flex: 1;    
  }
    .select-wrapper:last-child {
      margin-bottom: 0;
  }

    .select-toggle{
      padding-right: 8px;
    }

  /* on mobile, keep dropdown text color consistent with desktop */
  .select-option, .select-toggle, .select-label {
    color: #222 !important; /* override any blue default on mobile */
  }
  
  /* Make dropdown long text wrap and not push other elements */
  .select-toggle, .select-option {
    white-space: normal;
    word-break: break-word;
    line-height:1.25;
  }

  /* Map: second section */
  .main{
    display:block;
    flex:0 0 auto;
  }
  #map {
    height: 48vh; /* bigger map on mobile */
    width: 100%;
    margin-bottom: 8px;
    border-radius: 12px;
    overflow:hidden;
    flex: 1 1 auto;
  }

  /* Make Leaflet controls visible and sit above other elements */
  .leaflet-control-container { z-index: 1001; }
  .leaflet-top, .leaflet-bottom { z-index: 1001; }

  /* Make popup smaller on mobile */
  .leaflet-popup-content-wrapper { max-width: 220px !important; font-size: var(--fs-sm); }
  .popup-card h3 { font-size: var(--fs-lg); }
  .popup-card p { font-size: var(--fs-sm); }

  /* Sidebar: last section */
  .sidebar {
    height: 42vh; /* fixed height and scrollable */
    width: 100% !important;
    margin: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-left: none;
    border-top: 1px solid #eee;
    padding: 12px;
    box-sizing: border-box;
    text-align: right;
    flex: 1 1 auto;
    z-index: 5; /* always above map */
    position: relative;
  }

  /* Visible scrollbar for sidebar */
  .sidebar::-webkit-scrollbar { width:10px; }
  .sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius:8px; }

  /* Slightly larger store card on mobile */
  .store { padding: 16px; border-radius:0; margin: 0 0 12px 0; width: 100% !important;box-sizing: border-box; border-left: none; border-right: none;}
  .store-left h3 { font-size: var(--fs-lg); width: 100%; text-align: right;}
  .store-left p { font-size: var(--fs-base); width: 100%; text-align: right; }

  /* Directions button border only (no bg) */
  .store-right a {
    border-radius: 25px;
    padding: 8px 12px;
    border: 1px solid #c9c7c7;
    background: transparent;
    display:inline-flex;
    align-items:flex-start;
    gap:8px;
    font-size:var(--fs-base);
  }

  /* ensure icon and text align */
  .store-right img { vertical-align: middle; height:25px; width:auto; }

  /* Make store active border not cut off and avoid overlap with separator */
  .store.active { box-shadow: 0 0 0 3px rgba(194,180,154,0.09); border-color: #c2b49a; }

  /* small adjustments for select-options z-index so they appear above map */
  .select-options { z-index: 2002 !important; position: absolute; }
  /* keep dropdown z-index high so not behind map */
  .select-options { z-index: 2002 !important; }
}

/* ensure popup link button fits */
.popup-card .button { font-size: var(--fs-sm); padding:8px 10px; width:100%; box-sizing:border-box; }

  /* If super small, stack dropdowns vertically */
  @media (max-width:500px){
     .container{
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 8px;
  }

  /* Top section stack */
  .topbar{
    display:block;
    gap:8px;
    padding:10px;
  }

   .header .logo {
      max-height: 100px; /* adjust logo size */
      cursor: pointer;
      transition: transform 0.2s ease;
      pointer-events: auto;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
      display: block; /* Ensures it fills its clickable area */
      z-index: 1000; /* Only needed if it's under something */
    }

      .header .logo:hover {
        transform: scale(1.05);
    }

  /* Search directly below logo */
  .search-wrapper{
    min-width: 250px;
    max-width: 900px;
    margin-bottom:8px;
  }
  .search-wrapper input{
    width:100%;
    font-size:16px;
  }

  /* Dropdowns layout: side-by-side if space allows, otherwise stacked */
   .select-wrapper{ 
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    align-items:flex-start;
    justify-content:space-between;
    margin-top: 8px;
    flex: 0 0 40%;
    max-width: 100%;
    }
    .select-wrapper:last-child {
      margin-bottom: 0;
    }

  /* on mobile, keep dropdown text color consistent with desktop */
  .select-option, .select-toggle, .select-label {
    color: #222 !important; /* override any blue default on mobile */
  }
  
  /* Make dropdown long text wrap and not push other elements */
  .select-toggle, .select-option {
    white-space: normal;
    word-break: break-word;
    line-height:1.25;
  }

  /* Map: second section */
  .main{
    display:block;
    flex:0 0 auto;
  }
  #map {
    height: 48vh; /* bigger map on mobile */
    width: 100%;
    margin-bottom: 8px;
    border-radius: 12px;
    overflow:hidden;
    flex: 1 1 auto;
  }

  /* Make Leaflet controls visible and sit above other elements */
  .leaflet-control-container { z-index: 1001; }
  .leaflet-top, .leaflet-bottom { z-index: 1001; }

  /* Make popup smaller on mobile */
  .leaflet-popup-content-wrapper { max-width: 220px !important; font-size: var(--fs-sm); }
  .popup-card h3 { font-size: var(--fs-lg); }
  .popup-card p { font-size: var(--fs-sm); }

  /* Sidebar: last section */
  .sidebar {
    height: 42vh; /* fixed height and scrollable */
    width: 100% !important;
    margin: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-left: none;
    border-top: 1px solid #eee;
    padding: 12px;
    box-sizing: border-box;
    text-align: right;
    flex: 1 1 auto;
    z-index: 5; /* always above map */
    position: relative;
  }

  /* Visible scrollbar for sidebar */
  .sidebar::-webkit-scrollbar { width:10px; }
  .sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius:8px; }

  /* Slightly larger store card on mobile */
  .store { padding: 16px; border-radius:0; margin: 0 0 12px 0; width: 100% !important;box-sizing: border-box; border-left: none; border-right: none;}
  .store-left h3 { font-size: var(--fs-lg); width: 100%; text-align: right;}
  .store-left p { font-size: var(--fs-base); width: 100%; text-align: right; }

  /* Directions button border only (no bg) */
  .store-right a {
    border-radius: 25px;
    padding: 8px 12px;
    border: 1px solid #c9c7c7;
    background: transparent;
    display:inline-flex;
    align-items:flex-start;
    gap:8px;
    font-size:var(--fs-base);
  }

  /* ensure icon and text align */
  .store-right img { vertical-align: middle; height:25px; width:auto; }

  /* Make store active border not cut off and avoid overlap with separator */
  .store.active { box-shadow: 0 0 0 3px rgba(194,180,154,0.09); border-color: #c2b49a; }

  /* small adjustments for select-options z-index so they appear above map */
  .select-options { z-index: 2002 !important; position: absolute; }
  }

/* lazy-load images default (will be injected in JS but this helps fallback) */
img[loading="lazy"]{ opacity: 1; transition:opacity .25s ease; }

/* ensure map resize behavior */
html, body { height:100%; }

/* small helper to ensure the locate button and plus/minus are visible on top */
.leaflet-control-zoom, .leaflet-control-fullscreen, .leaflet-control-locate {
  z-index: 1200 !important;
}
