/* Foundry — app.mobile.css (Briefr)
   Goal: iPhone-optimal responsiveness WITHOUT changing table semantics or JS.
   Strategy:
   - Keep tables as tables (horizontal scroll, no hiding cells)
   - Mobile toolbar becomes hamburger (text menu modal) instead of wrapped icon bar
   - Modals fit iPhone (remove any desktop min-width constraints)
   - Searchbar wraps cleanly
   - Reports grid collapses cleanly
*/

/* ------------------------------
   iOS safe area + tokens
------------------------------ */
:root{
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --m-pad-x: 12px;
  --m-pad-y: 12px;
}

/* Avoid iOS zoom on focus (inputs must be >= 16px) */
@media (max-width: 520px){
  input, select, textarea, button{ font-size:16px; }
  img, svg{ max-width:100%; height:auto; }
}

/* ------------------------------
   Titlebar + Toolbar (mobile)
   - Keep tidy, avoid wrapped icon billboard
------------------------------ */
@media (max-width: 520px){
  .app-titlebar{
    padding: .65rem calc(var(--m-pad-x) + var(--safe-r)) .65rem calc(var(--m-pad-x) + var(--safe-l));
    gap: 10px;
height:80px
  }
  .app-titlebar h1{
    font-size: 20px;
    line-height: 1.15;
  }

  .app-logos{ gap: 12px; }
  .app-logos img{ height: 18px; }
  .app-logos .app-logo-fws{ height: 36px; }

  /* Toolbar should not grow into a huge wrapped block */
  .toolbar{
    height: auto;
    padding: var(--m-pad-y) calc(var(--m-pad-x) + var(--safe-r)) var(--m-pad-y) calc(var(--m-pad-x) + var(--safe-l));
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap; /* stop wrapping chaos */
  }

  .sep{ display:none; }

  /* Keep icon buttons tappable 
  .icon-btn{
    width: 56px;
    min-height: 56px;
    padding: 6px 4px;
  } */
  .icon-btn .label{
    font-size: 10px;
    line-height: 1.15;
  }
}

/* Views padding */
@media (max-width: 520px){
  .view{ padding: var(--m-pad-y) var(--m-pad-x); }
}

/* ------------------------------
   Searchbar: wrap for iPhone
------------------------------ */
@media (max-width: 520px){
  .searchbar{
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
  }

  .searchbar input[type="text"],
  .searchbar input{
    flex: 1 1 100%;
    min-width: 0;
  }

  .searchbar select,
  .searchbar input[type="date"]{
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .searchbar button{
    flex: 1 1 100%;
  }
}

/* ------------------------------
   Panels + headers
------------------------------ */
@media (max-width: 520px){
  .panel-head{ flex-wrap: wrap; }
  .panel-title{ width:auto !important; }
}

/* ------------------------------
   TABLES (Briefr): keep tables, horizontal scroll, iPhone-friendly widths
   - Single source of truth (no duplicate conflicting blocks)
------------------------------ */
@media (max-width: 520px){
  .projects-shell{
    position: relative;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
  }

  /* scroll hint */
  .projects-shell::after{
    content:"";
    position: sticky;
    right: 0;
    top: 0;
    height: 100%;
    width: 22px;
    pointer-events: none;
    background: linear-gradient(to left, rgba(248,249,251,1), rgba(248,249,251,0));
  }

  table.projects{
    min-width: 980px;     /* iPhone-friendly: scrolls, but not absurd */
    width: max-content;
    border-collapse: separate;
    border-spacing: 0;
  }

  table.projects th,
  table.projects td{
    padding: 10px 12px;
    vertical-align: top;
  }

  /* Long title column wraps */
  table.projects td:nth-child(3){
    white-space: normal;
    word-break: break-word;
    min-width: 260px;
  }

  /* Actions/last column stays stable */
  table.projects td:last-child,
  table.projects th:last-child{
    white-space: nowrap;
  }

  /* zebra helps scanning */
  table.projects tbody tr:nth-child(even){
    background: rgba(0,0,0,0.02);
  }

  table.projects td input,
  table.projects td select,
  table.projects td textarea{
    max-width: 100%;
    font-size: 16px;
  }

  table.projects td .icon-btn{
    width: 48px !important;
    height: 48px !important;
padding: 0 !important;
  }

  /* Period totals pills wrap */
  #briefsTable .period-totals .pill{
    display: inline-flex;
    flex-wrap: wrap;
    margin-right: .35rem;
    margin-bottom: .35rem;
  }
}

/* ------------------------------
   MODALS: iPhone-friendly
------------------------------ */
@media (max-width: 520px){
  .modal{
    padding: 0;
    align-items: flex-end;
    justify-content: center;
  }

  .modal .card{
    width: 95vw;
    max-width: 95vw;
    min-width: 0 !important;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: calc(92vh - var(--safe-t));
    overflow: auto;
  }

  .modal header{ padding: 16px; font-size: 18px; }
  .modal section{ padding: 14px; }
  .modal footer{
    padding: 12px 14px calc(12px + var(--safe-b));
    gap: 8px;
    flex-wrap: wrap;
  }

  .modal .grid2{ grid-template-columns: 1fr !important; }
  .modal .grid2 .full{ grid-column: auto !important; }

  #briefViewBody{ max-height: none; }

.splash-inner {max-width:95vw;}

.card.pad {width:92vw !important;}
}

/* ------------------------------
   REPORTS: tighten for iPhone
------------------------------ */
@media (max-width: 520px){
  #reportsModal > .card.reports-modal{
    width: 95vw;
    border-radius: 16px 16px 0 0;
    margin: 0 auto;
  }

  #reportsModal .reports-grid{
    grid-template-columns: 1fr;
  }

  #reportsModal .reports-card-body{
    grid-template-columns: 120px 1fr;
  }
}

/* ------------------------------
   Toast + footer: safe area
------------------------------ */
@media (max-width: 520px){
  #toast{
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--safe-b));
    transform: translateY(20px);
    max-width: calc(100% - 24px);
  }
  #toast.show{ transform: translateY(0); }

  .foundry-footer-status{
    left: 12px;
    bottom: calc(10px + var(--safe-b));
  }
}

/* =========================================================
   MOBILE MENU: show burger, hide messy toolbars (Briefr)
   - burger lives inside .toolbar .right.actions-wrap
   - left icon cluster hidden entirely on mobile
========================================================= */
.mobile-only{ display:none; }
.desktop-only{ display:inherit; }

@media (max-width: 520px){

  /* Hide the left icon bar (New Brief / Add User / Usage etc.) */
  .toolbar .left.actions-wrap{
    display:none !important;
  }

  /* Force right container to be the only visible toolbar content */
  .toolbar .right.actions-wrap{
    display:flex !important;
    align-items:center;
    justify-content:flex-end;
    gap:8px;
    width:100%;
  }

  /* Hide desktop controls in the right bar */
  .toolbar .right.actions-wrap #tabGroup,
  .toolbar .right.actions-wrap #importBtn,
  .toolbar .right.actions-wrap #exportBtn,
  .toolbar .right.actions-wrap #refreshBtn,
  .toolbar .right.actions-wrap #btnSignOut,
  .toolbar .right.actions-wrap #saveStatus,
.toolbar .right.actions-wrap #issue {
    display:none !important;
  }

  /* Show burger (hard force) */
  .toolbar .right.actions-wrap #mobileMenuBtn{
    display:inline-flex !important;
    visibility:visible !important;
    opacity:1 !important;
    pointer-events:auto !important;
    position:relative;
    z-index:9999;
    width:56px;
    min-height:56px;
    margin-left:auto;
  }

  /* icon-only is cleaner on iPhone */
  .toolbar .right.actions-wrap #mobileMenuBtn .label{
    display:none !important;
  }

  /* If you want Issue only inside the menu, uncomment:
     #issue{ display:none !important; }
  */

  /* Menu modal bottom sheet */
  #mobileMenuModal.modal{ align-items:flex-end; }
	#mobileMenuModal .card {
		width: 95vw;
		max-width: 95vw;
		min-width: 0 !important;
		border-radius: 16px 16px 0 0;
		max-height: 92vh;
		overflow: auto;
		border-radius: 16px 16px 0 0;
	}


  #mobileMenuModal header{ padding:16px; font-size:18px; background: var(--brand1); color: #f3f5f2;}
  #mobileMenuModal section{ padding:10px 12px; display:block; }
  #mobileMenuModal footer{ padding:12px 14px calc(12px + var(--safe-b)); }

	.mobile-menu .m-item {
		width: 100%;
		text-align: left;
		padding: 14px 14px;
		border: none;
		background: #fff;
		font-size: 16px;
		color: var(--brand1);
	}

  .mobile-menu .m-item:active{ background:rgba(0,0,0,.06); }
  .mobile-menu .m-item.danger{
    border-color: rgba(255,92,122,.45);
    color: #d61f44;
  }
  .mobile-menu .m-divider{
    height:1px;
    margin:10px 4px;
    background: rgba(0,0,0,.1);
  }
}