/* Europe Grass CRM — mobiel en tablet
   Ontworpen voor de buitendienst: duim-bereikbare tabbalk onderin, grote aanraakvlakken,
   relaties als kaarten in plaats van brede tabellen, formulieren zonder inzoomen op iPhone. */

.tabbar { display: none; }
.quick-reach { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.quick-link { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--eg-blue); font-weight: 600; font-size: 13px; text-decoration: none; }
.quick-link svg { width: 18px; height: 18px; color: var(--eg-green); }
.quick-link:hover { border-color: var(--eg-green); }
.contact-person { padding: 10px 0; border-bottom: 1px solid var(--line); }
.contact-person:last-of-type { border-bottom: 0; }
.contact-person .reach { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; }
.reach-link { color: var(--eg-blue2); font-weight: 500; text-decoration: none; border-bottom: 1px solid var(--eg-green); }
.relations-table tbody tr { cursor: pointer; }
.relations-table tbody tr:hover td { background: #f7f9fa; }
.more-menu { display: grid; gap: 8px; margin-top: 14px; }
.more-menu button { justify-content: flex-start; gap: 12px; min-height: 52px; font-size: 15px; width: 100%; }
.more-menu button svg { color: var(--eg-blue2); }
.tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--eg-green); color: var(--eg-blue); font: 700 10px/1 var(--font-body); font-style: normal; }
.tab-badge.inline { margin-left: 6px; vertical-align: 1px; }
.table-scroll { overflow-x: auto; }
.signal-report-hint { margin: 4px 0 0; }
.signal-report-hint button.link { margin-left: 4px; text-decoration: underline; }
#codeform { margin-top: 14px; }
body.auth .tabbar { display: none !important; }
aside .sidefoot { display: grid; gap: 8px; }
aside .sidefoot .sidefoot-admin.active { background: var(--eg-green); color: var(--eg-blue); font-weight: 700; }

/* Offline-melding */
.offline-banner { background: #fff6e0; border: 1px solid #f0d58a; color: #6b5310; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.savestate.offline { color: #b07a00; font-weight: 600; }

/* Foto's */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.photo { margin: 0; cursor: pointer; }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #e8edf0; }
.photo figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; }
.photo-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.photo-btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--eg-blue); font-weight: 600; cursor: pointer; }
.photo-btn.primary { background: var(--eg-green); border-color: var(--eg-green); color: #fff; }
.photo-btn svg { width: 22px; height: 22px; }
button.quick-link { cursor: pointer; font-family: inherit; }

@media (max-width: 750px) {
  /* Bovenbalk: alleen het logo; navigatie zit onderin */
  aside { position: sticky; top: 0; z-index: 30; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  aside nav, aside .workspace, aside .sidefoot { display: none !important; }
  aside .brand { min-height: 30px; background-size: auto 30px; }

  /* Tabbalk onderin, binnen duimbereik */
  .tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--eg-blue); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 18px rgba(16, 49, 76, .18); }
  .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 54px; padding: 4px 2px; border: 0; border-radius: 10px; background: transparent; color: #c4d0da; font-size: 10.5px; font-weight: 500; line-height: 1.1; }
  .tabbar button svg { width: 23px; height: 23px; }
  .tabbar button.active { color: var(--eg-green); background: rgba(255, 255, 255, .07); }
  .tabbar button.active span { color: #fff; font-weight: 700; }
  .tabbar .tab-badge { position: absolute; top: 4px; left: 50%; margin-left: 6px; }
  main { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); }

  /* Kop: compact, zoekveld over de volle breedte, uitloggen zit onder 'Meer' */
  header { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
  header h1 { font-size: 26px; margin: 0; }
  .toptools { width: 100%; flex-wrap: nowrap; }
  .toptools #search { width: 100%; flex: 1; }
  .savestate { position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 16px; z-index: 31; color: #c4d0da; font-size: 11px; }

  /* Geen inzoomen op iPhone: invoervelden minimaal 16px */
  input, select, textarea, .formgrid input:not([type="checkbox"]):not([type="radio"]), .formgrid select, .formgrid textarea { font-size: 16px !important; }
  button { min-height: 44px; }
  button.link { min-height: 0; }

  /* Overzicht */
  .home-welcome { padding: 4px 0; margin-bottom: 14px; }
  .home-welcome h2 { font-size: 26px !important; }
  .home-welcome p { font-size: 15px !important; }
  .home-top-grid .kpi { padding: 12px 14px; min-height: 0; }
  .home-top-grid .kpi strong { font-size: 24px; }
  .home-search-actions { gap: 10px; }
  .quick-contact-button { width: 100%; align-self: stretch !important; }

  /* Lijsten: tabs en filters horizontaal scrollen in plaats van stapelen */
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 14px -16px; padding: 0 16px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; white-space: nowrap; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
  .filters select, .filters input { width: 100%; }
  .bar { flex-wrap: wrap; }
  .bar > .actions { width: 100%; }
  .bar > .actions > button { flex: 1; }
  .card { padding: 16px; border-radius: 14px; }

  /* Klanten en prospects als kaarten */
  .relations-table, .relations-table tbody { display: block; }
  .relations-table thead { display: none; }
  .relations-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .relations-table tr:last-child { border-bottom: 0; }
  .relations-table td { display: block; padding: 0; border: 0; font-size: 13px; }
  .relations-table td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
  .relations-table .cell-name { grid-column: 1 / -1; }
  .relations-table .cell-name button.link { font-size: 16px; font-weight: 700; }
  .relations-table .cell-status { text-align: right; }
  .relations-table .cell-status::before { text-align: right; }
  .relations-table .cell-contact { display: none; }
  .relations-table .cell-am { display: none; }
  .filters .am-filter { grid-column: 1 / -1; }
  .scope-filters { grid-template-columns: 1fr; }
  .relations-table .cell-focus { grid-column: 1 / -1; }
  .relations-table tr:hover td { background: transparent; }
  .tablewrap { overflow: visible; }

  /* Dossier */
  .dossier-toolbar { grid-template-columns: 1fr; gap: 10px; }
  .dossier-toolbar > .actions { display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; }
  .dossier-toolbar > .actions > button { margin: 0; }
  .profile { padding: 16px !important; }
  .profile h2 { font-size: 22px !important; }
  .quick-reach { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .quick-link { justify-content: center; min-height: 46px; }
  .contact-stats { gap: 12px 20px; }
  .preparation-head > button { width: 100%; }
  .note > .actions button, .contact-note .actions button { min-height: 40px; }

  /* Opvolging en taken: knoppen naast elkaar over de volle breedte */
  .signal-row { gap: 10px; }
  .signal-actions { display: grid !important; grid-template-columns: 1.3fr 1fr 1fr; width: 100%; }
  .signal-actions > button { min-width: 0; padding: 8px 6px; }
  .taskitem .row { flex-direction: column; align-items: stretch; }
  .taskitem .actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }

  /* Formulieren als volledig scherm, met de knoppen altijd in beeld */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; padding: 0; }
  #modalbody { min-height: 100%; display: flex; flex-direction: column; }
  .dialogtop { position: sticky; top: 0; z-index: 2; background: #fff; padding: calc(14px + env(safe-area-inset-top)) 16px 12px; margin: 0; border-bottom: 1px solid var(--line); }
  .dialogtop h2 { font-size: 19px !important; }
  #modalbody > *:not(.dialogtop) { padding-left: 16px; padding-right: 16px; }
  #modalbody > form { flex: 1; display: flex; flex-direction: column; padding-top: 16px; }
  .formgrid { grid-template-columns: 1fr; gap: 14px; }
  .formactions { position: sticky; bottom: 0; margin: auto -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1.4fr; }
  .formactions > button { width: 100%; min-height: 48px; }
  .contactrow { grid-template-columns: 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .contact-company-label { padding-top: 14px; }

  /* Kaart */
  #crm-map { height: 58vh; border-radius: 14px; }
  .map-layout { gap: 12px; }
  .map-relations { max-height: none; }

  /* Beheer */
  table.members { display: block; overflow-x: auto; white-space: nowrap; }

  #toast { left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: none; }
  footer { display: none; }
}

/* Tablet: zijbalk smaller, meer ruimte voor inhoud */
@media (min-width: 751px) and (max-width: 1100px) {
  aside { width: 200px; padding: 26px 14px; }
  aside .brand { background-size: 150px auto; padding-top: 52px; }
  main { margin-left: 200px; padding: 24px; }
  .relations-table .cell-contact { display: none; }
  .relations-table th:nth-child(5) { display: none; }
}
