/* ==========================================================================
   Shared responsive shell for full-screen MODULE DETAIL views
   --------------------------------------------------------------------------
   One pattern for every full-screen module overlay (To-Do, Reminders, Notes,
   Calendar, …) instead of per-screen hacks:

     • <=640px  → keep the existing MOBILE layout (single column + corner FAB).
     • >640px   → DESKTOP: fill the width up to a sensible max, with real
                   padding — no phone-width column floating in a huge gutter —
                   and a labeled "New" button in the header instead of the FAB.

   Loaded LAST (after styles.css / calendar.css), so these single-class rules
   win over each module's own `.*-focus-inner { max-width: 760px }` base rule
   without needing !important. Each module opts in by adding `module-detail` to
   its root <section> and `module-detail-inner` to its inner container.
   ========================================================================== */

/* ---- Header "New/Add" button: hidden on mobile (the FAB takes over) ------- */
.module-new-btn {
  display: none;               /* mobile: corner FAB is used instead */
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px 0 13px;
  border: 0;
  border-radius: 999px;
  background: var(--cw-accent);
  color: var(--cw-surface);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
  box-shadow: 0 2px 10px rgba(12, 139, 94, .26);
}
.module-new-btn svg { width: 18px; height: 18px; flex: 0 0 18px; }
.module-new-btn:hover { background: var(--cw-accent-active); box-shadow: 0 4px 14px rgba(12, 139, 94, .32); }
.module-new-btn:active { transform: translateY(1px); }

/* ==========================  DESKTOP ( >640px )  ========================== */
@media (min-width: 641px) {
  /* Fill the width up to a sensible app width — kills the narrow phone column
     and the empty gutter. min() keeps real side padding on mid screens. */
  .module-detail-inner {
    max-width: min(1320px, calc(100vw - 112px)) !important;
    padding-left: clamp(28px, 4vw, 56px);
    padding-right: clamp(28px, 4vw, 56px);
  }

  /* Flex/grid children must be allowed to shrink so columns lay out cleanly. */
  .module-detail-inner > * { min-width: 0; }

  /* Swap the corner FAB for the in-header "New" button. These ids are the
     module FABs we convert; email/lists/attachi keep their own behaviour. */
  #openTodoNew,
  #openReminderNew,
  #openNoteNew,
  #calNewEvent { display: none !important; }

  .module-new-btn { display: inline-flex; }

  /* Roomy, never-truncated edit/add forms on desktop: let the inline editors
     breathe instead of crushing into one cramped row. */
  .module-detail .todo-row.is-editing,
  .module-detail .reminder-row.is-editing { min-width: 0; }
  .module-detail .todo-edit-meta .todo-topic-input,
  .module-detail .todo-edit-meta .todo-due-input { flex-basis: 220px; }
  .module-detail input,
  .module-detail select,
  .module-detail textarea { min-width: 0; max-width: 100%; }
}

/* =====================================================================
   Page-chrome consistency backstop. module-shell.css is the LAST stylesheet
   linked in index.html, so these win by load order for every SPA surface —
   the place to enforce app-wide chrome so this class of bug stops recurring.
   ===================================================================== */

/* Pure-white page surface everywhere. The lilac canvas is removed at source
   (theme.css --bg-canvas), and the neutral grid/sheen texture layers are
   retired here so the page reads flat white like the mockup. */
html::before { background: #fff !important; }
body::before, body::after { display: none !important; }
html, body, #appShell, .shell { background: #fff !important; }

/* ---- Shared back button (.cw-back) — the canonical Notes-style chevron.
   One look everywhere: compact icon-only circle, top-left, brand hover. ---- */
.cw-back {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--cw-text, #262433);
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.cw-back svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cw-back > span { display: none; }   /* icon-only, even if markup keeps a label */
.cw-back:hover {
  color: var(--cw-accent-text, #4F52B2);
  background: rgba(91, 95, 199, .09);
}

/* Promote the existing divergent back affordances to the .cw-back look without
   re-marking-up every view: text-pill / inline / link variants collapse to the
   same icon-only chevron circle. (The inline module backs —
   .notes-focus-back / .todo-focus-back / .reminder-focus-back / .cal-focus-back
   / .email-back — already match this design.) */
.assistant-back-btn,
.module-route-back,
.vaia-back,
.vx-mindmap-back,
.people-back-link,
.people-mobile-back {
  width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  gap: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: none !important;
  box-shadow: none !important;
  color: var(--cw-text, #262433) !important;
  display: inline-grid !important;
  place-items: center !important;
}
.assistant-back-btn > span,
.module-route-back > span,
.vaia-back > span,
.vx-mindmap-back > span { display: none !important; }
.assistant-back-btn svg,
.module-route-back svg,
.vaia-back svg,
.vx-mindmap-back svg,
.people-back-link svg,
.people-mobile-back svg {
  width: 26px !important;
  height: 26px !important;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.assistant-back-btn:hover,
.module-route-back:hover,
.vaia-back:hover,
.vx-mindmap-back:hover,
.people-back-link:hover,
.people-mobile-back:hover {
  color: var(--cw-accent-text, #4F52B2) !important;
  background: rgba(91, 95, 199, .09) !important;
}
