/* ═══════════════════════════════════════
   THOT — mobile.css  v2
   Sidebar collassata, layout colonna unica
   ottimizzato per touch e piccoli schermi
═══════════════════════════════════════ */

/* ── BOTTOM NAV ──────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--t-fast), background var(--t-fast);
  border: none;
  background: none;
  min-width: 48px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bnav-item:hover,
.bnav-item.active { color: var(--accent); }
.bnav-item svg { width: 20px; height: 20px; }

/* Quick capture fab */
.bnav-capture {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--accent);
  color: white !important;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 3px 14px rgba(58,122,140,.40);
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  margin-bottom: 6px;
}
.bnav-capture:hover,
.bnav-capture.active { background: var(--accent-dk); color: white; }
.bnav-capture:active  { transform: scale(.92); box-shadow: 0 1px 6px rgba(58,122,140,.3); }
.bnav-capture svg     { width: 22px; height: 22px; }

/* Badge */
.bnav-badge {
  position: absolute;
  top: 2px; right: 4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ── TABLET (≤ 1024px): sidebar narrower ── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }

  .two-col {
    grid-template-columns: 1fr;
  }
  .col-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

/* ── MOBILE (≤ 768px): sidebar come drawer, layout unica colonna ── */
@media (max-width: 768px) {

  /* ── Sidebar: drawer laterale ── */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(var(--sidebar-w), 82vw);
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 300;
    border-right: 1px solid var(--border);
    transition: transform var(--t-slow), box-shadow var(--t-slow);
    /* Safe area on notched devices */
    padding-top: env(safe-area-inset-top, 0);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 40px rgba(42,37,32,.18);
  }

  /* Overlay scuro quando sidebar aperta */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(42,37,32,.32);
    z-index: 299;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar-overlay.open {
    display: block;
    animation: fadeIn var(--t-fast);
  }

  /* ── Main: colonna unica, padding per bottom nav ── */
  .main {
    flex: 1;
    min-width: 0;
  }

  /* Hamburger visibile */
  .btn-menu { display: inline-flex; }

  /* Topbar */
  .topbar {
    padding: 0 12px;
    height: var(--header-h);
  }
  .topbar-actions .status-pill {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Content paddings — bottom extra per bottom nav */
  .page-content {
    padding: 20px 18px 90px;
  }
  .today-view,
  .inbox-view,
  .archive-view,
  .search-view {
    padding: 20px 18px 90px;
  }

  /* Tutto in colonna unica */
  .two-col      { grid-template-columns: 1fr !important; }
  .col-side     { grid-template-columns: 1fr !important; }

  /* Title */
  .page-title-input { font-size: 26px; }
  .today-title      { font-size: 24px; }

  /* Bottom nav visibile */
  .bottom-nav { display: flex; }

  /* Quick capture modal */
  .qc-modal { top: 8%; }

  /* Modals: slide-up dal basso */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    animation: slideUp var(--t-slow);
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Todo detail panel: full screen su mobile */
  .tdp-overlay {
    background: rgba(42,37,32,.18);
  }
  .tdp {
    width: 100% !important;
    max-width: 100% !important;
    min-width: unset !important;
    border-left: none !important;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    bottom: 0;
    top: auto;
    height: 85vh;
    overflow-y: auto;
    animation: slideUp var(--t-slow);
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }

  /* Block headers: più spazio touch */
  .block-header {
    padding: 12px 14px;
    min-height: 46px;
  }

  /* Dropdown: più largo su mobile */
  .dropdown {
    min-width: 200px;
    font-size: 14px;
  }
  .dropdown-item {
    padding: 11px 14px;
    min-height: 44px;
  }

  /* Touch: azioni sempre visibili (no hover) */
  .space-actions,
  .page-actions,
  .todo-item-actions,
  .link-delete,
  .file-delete,
  .subpage-actions,
  .inbox-item-actions {
    opacity: 1 !important;
  }
}

/* ── SMALL MOBILE (≤ 420px) ────────── */
@media (max-width: 420px) {
  .page-content { padding: 16px 14px 90px; }
  .today-view, .inbox-view, .archive-view { padding: 16px 14px 90px; }
  .page-title-input { font-size: 22px; }
  .today-title { font-size: 20px; }

  /* Breadcrumb: mostra solo pagina corrente */
  .bc-space { display: none; }
  .bc-sep   { display: none; }

  /* Status pill: solo icona */
  .status-pill span { display: none; }
  .status-pill { padding: 5px 7px; border-radius: 50%; min-width: 30px; justify-content: center; }

  /* Bottom nav: nasconde label */
  .bnav-item span { display: none; }
  .bnav-item { min-width: 38px; padding: 8px 6px; }

  /* Icon picker grid: 4 colonne */
  .icon-picker { grid-template-columns: repeat(4,1fr) !important; }

  /* QC modal */
  .qc-modal { top: 4%; left: 8px; right: 8px; }
}

/* ── LARGE (≥ 1400px): più spazio ─── */
@media (min-width: 1400px) {
  .two-col { grid-template-columns: 1fr 380px; }
  .page-content { padding: 40px 52px 80px; }
}

/* ── EXTRA LARGE (≥ 1800px) ─────── */
@media (min-width: 1800px) {
  :root { --sidebar-w: 280px; }
  .page-content { padding: 44px 64px 80px; }
}

/* ── TOUCH: hover disabilitati ─────── */
@media (hover: none) {
  .space-actions,
  .page-actions,
  .todo-item-actions,
  .link-delete,
  .file-delete,
  .subpage-actions,
  .inbox-item-actions {
    opacity: 1;
  }
  .space-row:hover,
  .page-row:hover,
  .sidebar-today:hover {
    background: none;
  }
}

/* ── ANIMAZIONI ─────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── PRINT ─────────────────────────── */
@media print {
  .sidebar, .topbar, .bottom-nav,
  .qc-modal, .qc-backdrop,
  .sidebar-overlay { display: none !important; }
  .main  { overflow: visible; }
  .view  { overflow: visible; }
  .app   { display: block; height: auto; }
  body   { overflow: auto; }
  .page-content { padding: 0; }
}

/* ── REDUCED MOTION ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
