﻿/* Default: hide mobile optimize bar on desktop */
.mobile-optimize-bar{ display:none; }

/* Precision Film Systems™ responsive overrides (mobile/tablet)
   Extracted from base.css for easier editing.
   Load AFTER base.css and theme-*.css.
*/

@media (max-width: 768px){
  /* Extra bottom space so the footer clears the sticky mobile optimize bar */
  body{ padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
  .mobile-optimize-bar{
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:6px;
    position:fixed;
    left:10px;
    right:10px;
    bottom:10px;
    z-index:60;
    padding:10px;
    border-radius:20px;
    border:1px solid var(--border);
    background:color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: blur(12px);
    box-shadow:var(--shadow-lg);
  }
  .btn-mobile-optimize{
    width:100%;
    border:none;
    border-radius:16px;
    padding:16px 18px;
    font-weight:900;
    font-size:1.05rem;
    letter-spacing:.2px;
    cursor:pointer;
    color:#fff;
    background:linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow:0 12px 22px -12px rgba(37,99,235,.65);
  }
  .btn-mobile-optimize:active{ transform: translateY(1px); }
  .opt-usage-note-mobile{
    display:block;
    width:100%;
    text-align:center;
    margin-top:2px;
    line-height:1.25;
  }
  .opt-usage-note-mobile .opt-usage-line{
    display:block;
  }
}

@media (max-width:900px){
  .main-content{ grid-template-columns:1fr; }
}

@media (max-width:900px){
  .input-section,.results-section{ grid-column:1; }
}

@media (max-width: 640px){
  .job-details-grid{ grid-template-columns:1fr; }
}

@media (max-width:1024px){
  .select-wrapper{ max-width:100%; }
}

@media (max-width: 520px){
  /* Mobile: these controls are hidden (Optimize Film lives in the bottom bar).
     Keep this block so older caches don't reintroduce sticky spacing. */
  .main-actions{ display:none !important; }
}

/* Mobile/tablet: hide desktop "Optimize Roll Size" + "Clear All" block entirely so it
   doesn't reserve space or overlap sections. */
@media (max-width: 768px){
  .main-actions{ display:none !important; }
}

@media (max-width: 900px){
  .job-output-buttons{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px){
  .fy-form-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 900px){
  .fy-quote-grid{ grid-template-columns: 1fr; }
}

@media (max-width:900px){
  .footer-content{ grid-template-columns:1fr; }
}

@media (max-width: 768px){
  footer{ padding:18px; }
  .footer-content{ gap:16px; }
  .footer-bottom{ font-size:.85rem; padding-top:14px; }

  /* App footer: mobile-only override to avoid legacy boxed footer card look */
  #appFooter{
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  #appFooter .footer{
    margin-top: 8px;
    padding: 8px 0 calc(108px + env(safe-area-inset-bottom, 0px));
    border-top: 0;
    background: transparent;
  }
  #appFooter .footer-inner.container{
    padding-left: 16px;
    padding-right: 16px;
  }
  #appFooter .footer-inner{
    justify-content: center;
    text-align: center;
    gap: 6px;
  }
  #appFooter .footer-left{
    width: 100%;
    align-items: center;
    text-align: center;
    gap: 2px;
  }
  #appFooter .footer-links{
    width: 100%;
    justify-content: center;
    text-align: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 8px;
    overflow: hidden;
  }
  #appFooter .footer-links a{
    margin: 0;
    font-size: 10px;
    letter-spacing: 0;
  }
  #appFooter .footer-right{
    width: 100%;
    align-items: flex-end;
    text-align: right;
  }
  #appFooter .footer-help{
    width: 100%;
    text-align: right;
  }
 }

/* Mobile/tablet: keep the Window controls buttons within the container width (no horizontal scroll). */
@media (max-width: 768px){
  .window-controls-bottom{
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
    padding:10px 0 0;
    overflow:visible;
  }
  .window-controls-bottom .btn-add-window,
  .window-controls-bottom button{
    width:100%;
    margin:0;
    white-space:normal;
  }
}

@media (max-width:768px){
  .results-grid{ grid-template-columns:1fr; }

  .modal-content{ padding:20px; margin:10px; }

  .film-selection,.film-selection-row{
    flex-direction:column;
    align-items:stretch;
  }

  .film-select-wrapper{ min-width:auto; }

  .main-actions{ flex-direction:column; }

  .selection-controls{
    flex-direction:column;
    gap:10px;
    align-items:stretch;
  }

  .selection-buttons{ flex-wrap:wrap; }

  .btn-select-all,.btn-deselect,.btn-group-selected{
    flex:1;
    min-width:100px;
  }

  /* Compact table tighter */
  .table-header,.window-row{
    grid-template-columns:30px 50px 70px 70px 90px 40px;
    gap:6px;
  }

  .table-header{ padding:8px 10px; font-size:.8rem; }
  .window-row{ padding:6px 10px; }

  .window-input,.window-quantity-input{ padding:5px 6px; font-size:.85rem; }
  .window-group-badge{ font-size:.7rem; padding:2px 6px; max-width:80px; }
  .btn-remove-window{ width:28px; height:28px; font-size:.9rem; }

  .btn-clear{ font-size:.95rem; padding:12px 15px; }
}

@media (max-width: 420px) {
  :root {
    --window-cols: 28px 44px minmax(0, 1fr) minmax(0, 1fr) 34px;
    --window-gap: 6px;
  }
}

@media (min-width: 421px) and (max-width: 768px) {
  :root {
    --window-cols: 32px 52px minmax(0, 1fr) minmax(0, 1fr) 40px;
    --window-gap: 8px;
  }
}

@media (max-width: 768px) {
  body { padding: 10px; }
  header{ top: 10px; padding: 12px 12px; }
  header, footer, .card { width: 100%; }
  .card{ padding: 16px; }
  .app-logo{ height: 38px; }
  .main-content { gap: 14px; }
}

@media (max-width: 768px) {
  input,
  select,
  textarea,
  .window-input,
  .window-quantity-input,
  .select-wrapper select {
    font-size: 16px !important;
  }
}

@media (max-width: 768px) {
  /* Move padding responsibility to the container */
  body {
    padding: 0 !important;
  }

  .container {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    box-sizing: border-box;
  }

  
  /* Mobile-first spacing: keep everything aligned and prevent "right edge" feel */
  header, footer { padding: 16px; }
  .card { padding: 16px; overflow-x: hidden; }
  .main-content { gap: 16px; }
/* Never allow cards/header/footer to exceed the container */
  header,
  footer,
  .card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Prevent inner grids from forcing card wider */
  .windows-section,
  .windows-list,
  .table-header,
  .window-row {
    max-width: 100%;
  }
}

@media (max-width: 520px) {
  .summary-row {
    grid-template-columns: 52px 1fr;
    grid-auto-rows: auto;
  }
  .summary-row > div:nth-child(3),
  .summary-row > div:nth-child(4) {
    grid-column: 1 / -1;
    color: var(--muted);
  }
  .summary-row.summary-head {
    display: none;
  }
}

@media (max-width: 520px){
  /* Keep job-actions scrollable (some layouts have many buttons),
     but DO NOT allow the Window controls row to force horizontal scrolling. */
  .job-actions.job-actions-centered{
    flex-wrap:nowrap;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    padding-bottom:4px;
    scrollbar-width:none;
  }
  .job-actions.job-actions-centered::-webkit-scrollbar{ display:none; }

  /* Window controls: stack to fit the container width (no sideways scrolling). */
  .window-controls-bottom{
    display:grid;
    grid-template-columns:1fr;
    gap:10px;
    padding:10px 0 0;
    overflow:visible;
  }
  .window-controls-bottom .btn-add-window,
  .window-controls-bottom button{
    width:100%;
    margin:0;
    padding:12px 14px;
    font-size:14px;
    border-radius:14px;
    white-space:normal;
  }
}

@media (max-width: 640px) {
  .job-details-grid.customer-grid{
    grid-template-columns: 1fr;
  }
  .job-details-grid.customer-grid .field-customer,
  .job-details-grid.customer-grid .field-phone,
  .job-details-grid.customer-grid .field-street,
  .job-details-grid.customer-grid .field-email,
  .job-details-grid.customer-grid .field-city,
  .job-details-grid.customer-grid .field-state,
  .job-details-grid.customer-grid .field-zip{
    grid-column: 1 / -1;
  }
}
@media (max-width: 640px){
  .summary-meta-inline{
    font-size:.78rem;
    max-width: 55vw;
    white-space: normal;
    text-align:right;
  }
}

@media (max-width: 640px){
  .meta-inline{
    max-width: 55vw;
    font-size:.78rem;
  }
}

@media (max-width: 640px){
  .roll-size-selected{
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 980px){
  .job-board{ grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}

@media (max-width: 560px){
  .job-board{ grid-template-columns: 1fr; }
}

@media (max-width: 820px){
  .job-list-row, .job-arch-row{ flex-direction:column; align-items:flex-start; }
  .job-list-actions, .job-arch-actions{ justify-content:flex-start; }
}

@media (max-width: 820px){
  .jobpick-row{ flex-direction:column; align-items:flex-start; }
  .jobpick-row-actions{ justify-content:flex-start; }
}

@media (min-width: 520px){
  .fy-form-grid{
    grid-template-columns: 1fr 1fr;
  }
  .fy-field-inline{
    grid-column: 1 / -1;
  }
}

@media (min-width: 900px){
  .fy-quote-grid{
    grid-template-columns: 1fr 1fr;
  }
  .fy-quote-summary{
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px){
  .fy-film-prices{ grid-template-columns: repeat(3, minmax(90px, 1fr)); }
}

@media (max-width: 520px){
  .fy-film-prices{ grid-template-columns: repeat(2, minmax(90px, 1fr)); }
}
/* --- Custom mobile tweaks (Dec 2025) --- */
@media (max-width: 768px) {
  /* Hide desktop-only actions on mobile; use the sticky bottom Optimize Film button instead. */
  .btn-optimize-roll,
  .btn-clear {
    display: none !important;
  }
}

/* When Settings is open, never show the mobile optimize bar */
body.settings-open .mobile-optimize-bar{
  display:none !important;
}

/* Keep mobile tap targets reliably clickable */
@media (max-width: 768px){
  .navbar{
    margin-left: -4px;
    margin-right: -4px;
  }
  .navbar{
    position:sticky;
    top:0;
    z-index:150;
    pointer-events:auto;
    padding: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(12, 17, 27, 0.9);
    backdrop-filter: blur(8px);
  }
  .navbar *{
    pointer-events:auto;
  }
  .nav-inner{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    height: 64px;
    min-height: 64px;
    padding: 0 14px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .logo{
    flex:1 1 auto;
    min-width:0;
  }
  .logo img{
    width: 40px;
    height: 40px;
  }
  .logo .brand{
    min-width:0;
  }
  .logo .brand-name,
  .logo .brand-tagline{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .logo .brand-tagline{
    display: none;
  }
  .nav-actions{
    flex:0 0 auto;
    position:relative;
    z-index:130;
    pointer-events:auto;
    gap: 8px;
  }
  .header-menu,
  .menu-btn{
    position:relative;
    z-index:131;
    pointer-events:auto;
    touch-action:manipulation;
  }
  .menu-btn,
  .bug-btn{
    width:40px;
    min-width:40px;
    height:40px;
    min-height:40px;
    padding:0;
    gap:0;
    justify-content:center;
  }
  .menu-btn .btn-label,
  .bug-btn .btn-label{
    display:none !important;
  }
  .menu-btn .btn-icon,
  .bug-btn .btn-icon{
    display:inline-block !important;
  }
  .mobile-optimize-bar{
    z-index:140;
    pointer-events:auto;
  }
  .mobile-optimize-bar *{
    pointer-events:auto;
  }
  .btn-mobile-optimize{
    position:relative;
    z-index:141;
    touch-action:manipulation;
  }
}

/* Settings > Films catalog layout */
@media (max-width: 820px){
  .fy-films-catalog{ display: block; }
  .fy-films-stack{ padding: 10px; }
  .fy-films-toolbar{
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
  .fy-films-toolbar .fy-field{
    grid-column: 1 / -1;
  }
  .fy-films-toolbar .fy-btn{
    width: 100%;
    justify-content: center;
  }
  .fy-films-film-list{
    max-height: 36vh;
  }
  .fy-film-item{
    width: 100%;
    min-width: 0;
    padding: 9px;
    gap: 8px;
  }
  .fy-film-item-actions{
    justify-content: flex-end;
  }
  .fy-film-item-main{
    width: 100%;
  }
  .fy-film-item-name{
    white-space: normal;
  }
  .fy-film-editor-grid{ grid-template-columns: 1fr; }
  .fy-warranty-inline{
    flex-wrap: wrap;
    gap: 8px 10px;
  }
  .fy-warranty-label{
    min-width: 88px;
  }
  .fy-roll-card{
    margin-top: 10px;
    padding: 0;
  }
  .fy-roll-grid-header, .fy-roll-row{
    grid-template-columns: 48px minmax(0,1fr) minmax(0,1fr) 52px;
    min-width: 0;
    gap: 6px;
  }
  .fy-roll-grid-header{
    font-size: 11px;
    padding: 0;
  }
  .fy-roll-cell input{
    width: 100%;
    box-sizing: border-box;
    padding: 9px 6px;
    min-width: 0;
  }
  .fy-film-editor .fy-field input,
  .fy-film-editor .fy-field select{
    width: calc(100% - 8px);
    box-sizing: border-box;
    min-width: 0;
    margin-right: 8px;
  }
  .fy-film-editor .fy-field textarea{
    width: calc(100% - 8px);
    box-sizing: border-box;
    min-width: 0;
    margin-right: 8px;
  }
}


@media (max-width: 900px){
  .fy-quote-layout{
    grid-template-columns: 1fr;
  }
  .fy-quote-wide{
    grid-column: auto;
  }
}

