/*****************************************************
 * MOBILE CSS (Unified for L / M / S profiles)
 * Applies styling overrides for mobile viewport only.
 *****************************************************/

/* ---------------------------------------------------
   GLOBAL MOBILE BASELINE
--------------------------------------------------- */
@media (max-width: 599px) {

  :root {
    --mobile-font-base: 16px;
    --mobile-font-small: 14px;
    --mobile-font-large: 18px;

    --toolbar-btn-padding: 6px 10px;
    --toolbar-btn-font: 16px;
  }

  body {
    font-size: var(--mobile-font-base);
  }

  /* ----- TOOLBAR NORMALIZATION ----- */
  .map-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    flex: 0 0 auto; /* keep your new rule */
  }

  .map-toolbar .btn,
  .map-toolbar .file-btn {
    font-size: var(--toolbar-btn-font) !important;
    padding: var(--toolbar-btn-padding);
    line-height: 1.2;
    height: auto;
    flex-shrink: 0;
  }

  /* keep your new hover/active behavior */
  .map-toolbar .btn:hover,
  .map-toolbar .file-btn:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
  }

  .map-toolbar .btn:active,
  .map-toolbar .file-btn:active {
    transform: translateY(1px);
  }

  /* Inputs, selects */
  input,
  select,
  textarea {
    font-size: var(--mobile-font-base);
    padding: 8px;
  }

  button {
    font-size: var(--mobile-font-base);
    padding: 8px 14px;
  }

  /* ----- Modal adjustments (generic) ----- */
  .modal {
    width: 94% !important;
    max-height: 82vh !important;
    padding: 16px !important;
    border-radius: 14px !important;
    font-size: var(--mobile-font-base);
  }

  .modal-header {
    font-size: var(--mobile-font-large);
    margin-bottom: 10px;
  }

}


/*****************************************************
 *  PROFILE L — LARGE MOBILE (>=430px)
 *****************************************************/
@media (max-width: 599px) and (min-width: 430px) {

  :root {
    --mobile-font-base: 18px;
    --mobile-font-small: 16px;
    --mobile-font-large: 22px;

    --toolbar-btn-font: 18px;
    --toolbar-btn-padding: 8px 14px;
  }

  .map-toolbar .btn,
  .map-toolbar .file-btn {
    min-width: 88px;
  }

  .modal {
    font-size: var(--mobile-font-base);
  }
}


/*****************************************************
 *  PROFILE M — MEDIUM MOBILE (380px–429px)
 *****************************************************/
@media (max-width: 429px) and (min-width: 380px) {

  :root {
    --mobile-font-base: 17px;
    --mobile-font-small: 15px;
    --mobile-font-large: 20px;

    --toolbar-btn-font: 17px;
    --toolbar-btn-padding: 7px 12px;
  }

  .map-toolbar .btn,
  .map-toolbar .file-btn {
    min-width: 80px;
  }

  .modal {
    font-size: var(--mobile-font-base);
  }
}


/*****************************************************
 *  PROFILE S — SMALL MOBILE (<=379px)
 *****************************************************/
@media (max-width: 379px) {

  :root {
    --mobile-font-base: 15px;
    --mobile-font-small: 13px;
    --mobile-font-large: 18px;

    --toolbar-btn-font: 15px;
    --toolbar-btn-padding: 6px 10px;
  }

  .map-toolbar .btn,
  .map-toolbar .file-btn {
    min-width: 70px;
  }

  .modal {
    font-size: var(--mobile-font-base);
  }
}


/*****************************************************
 *  GENERAL TOOLBAR CHANGE for all sizes
 *****************************************************/
 
@media (max-width: 1100px) {

  /* 3-dot button visible on mobile */
  .mobile-only {
    display: inline-flex !important;
  }

  /* Mobile dropdown menu – hidden by default (until .hidden is removed) */
  .mobile-menu {
    display: none;          /* base state */
    position: absolute !important;
    z-index: 200000 !important;
    pointer-events: auto !important;    
    right: 10px;
    top: 70px;
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    width: 220px;
  }
  
  .mobile-menu.show {
     display: block !important;   /* visible when class 'show' is present */
  }  

  /* Hide original desktop toolbar items */
  .map-toolbar label.file-btn,
  #fileInput,
  #exportBtn1,
  #exportBtn2,
  #importBtn2,
  #btnAbout {
     display: none !important;
  }

  /* Keep these visible */
  #btnRemoteImport,
  #btnLogin,
  #userStatus,
  #btnMobileMore {
     display: inline-flex !important;
  }
  
  /* Make mobile menu items visible and properly formatted */
  .mobile-menu-item {
    display: block !important;
    width: 100%;
    text-align: left;
    font-size: 20px !important;
    padding: 14px 20px !important;
    border-radius: 10px;
    background: #f8fafc;
    margin-bottom: 8px;
    border: 1px solid #d0d7df;
  }

  .mobile-menu-item:hover {
    background: #eef2ff;
  }  
  
 /* Reorder toolbar buttons on mobile */
  #btnRemoteImport {
    order: 1;
  }
  
  #btnMobileMore {
    order: 2;
  }
  
  #btnLogin {
    order: 3;
  }
  
  /* Optional: userStatus should come after login */
  #userStatus {
    order: 4;
}
}
