/* ─── module-lib.css (v10.19) ───────────────────────────────────────
   Shared panel + sub-modal + folder picker chrome. Self-sufficient so
   modules can render on the dashboard (which has no chat-client CSS)
   or on chat (which loads styles.css). Loaded on BOTH index.php and
   chat.php to keep behavior consistent. */

/* ── full module panel ─────────────────────────────────────────── */
.ml-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer;
}
.ml-panel-inner {
  background: var(--bg, #0a0d0a);
  border: 1px solid var(--accent, #b0e6b0);
  width: 100%;
  max-width: 720px;
  height: 90vh;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  cursor: default;
  padding: 0;
  position: relative;
  font-family: var(--mono, Menlo, Consolas, Monaco, monospace);
  /* v10.27: always reserve room for the iOS status bar in standalone PWA
     mode. In a normal browser env(safe-area-inset-top) is 0 so this is a
     no-op. In standalone PWA mode it returns ~47-59px (notch / Dynamic
     Island) and pushes the panel head below the system bar. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}
.ml-panel-wide .ml-panel-inner {
  max-width: 1000px;
}
.ml-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--accent2, #4a6a4a);
  flex-shrink: 0;
}
.ml-panel-title {
  margin: 0;
  color: var(--accent, #b0e6b0);
  font-size: 1.05em;
  font-weight: normal;
}
.ml-panel-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ml-panel-head-action {
  cursor: pointer;
  color: var(--dim, #6b8a6b);
  text-decoration: none;
  padding: 4px 8px;
  font-size: 1.1em;
  border-radius: 2px;
}
.ml-panel-head-action:hover {
  color: var(--accent, #b0e6b0);
  background: rgba(176,230,176,0.08);
}
.ml-panel-close {
  font-size: 1.5em;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--dim, #6b8a6b);
  text-decoration: none;
}
.ml-panel-close:hover {
  color: var(--fg, #cfe8cf);
  background: rgba(176,230,176,0.1);
}
.ml-panel-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  min-height: 0;
}

/* ── sub-modal (upload, settings, etc) ─────────────────────────── */
.ml-submodal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
  overflow-y: auto;
  cursor: pointer;
}
.ml-submodal-inner {
  background: var(--bg, #0a0d0a);
  border: 1px solid var(--accent, #b0e6b0);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 60px);
  cursor: default;
  font-family: var(--mono, Menlo, Consolas, Monaco, monospace);
  /* v10.27: standalone PWA safe-area (no-op in normal browser) */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}
.ml-submodal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--accent2, #4a6a4a);
}
.ml-submodal-title {
  margin: 0;
  color: var(--accent, #b0e6b0);
  font-size: 1em;
  font-weight: normal;
}
.ml-submodal-close {
  font-size: 1.5em;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--dim, #6b8a6b);
  text-decoration: none;
}
.ml-submodal-close:hover {
  color: var(--fg, #cfe8cf);
  background: rgba(176,230,176,0.1);
}
.ml-submodal-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  color: var(--fg, #cfe8cf);
}
.ml-submodal-body .field {
  margin-bottom: 10px;
}
.ml-submodal-body .field label {
  display: block;
  color: var(--dim, #6b8a6b);
  font-size: 0.82em;
  margin-bottom: 3px;
}
.ml-submodal-body input[type="text"],
.ml-submodal-body input[type="password"],
.ml-submodal-body input[type="number"],
.ml-submodal-body input[type="date"],
.ml-submodal-body select,
.ml-submodal-body textarea {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  border: 1px solid var(--accent2, #4a6a4a);
  color: var(--fg, #cfe8cf);
  padding: 6px 8px;
  font-family: var(--mono, monospace);
  font-size: 0.92em;
}

/* ── folder picker ─────────────────────────────────────────────── */
.ml-picker .ml-submodal-inner { max-width: 460px; }
.ml-picker-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ml-picker-list li {
  padding: 0;
}
.ml-picker-item {
  display: block;
  padding: 6px 10px;
  color: var(--fg, #cfe8cf);
  text-decoration: none;
  font-family: var(--mono, monospace);
  font-size: 0.92em;
  cursor: pointer;
  border-radius: 2px;
  white-space: pre;
}
.ml-picker-item:hover {
  background: rgba(176,230,176,0.1);
  color: var(--accent, #b0e6b0);
}

/* tiny utility classes the modules may reference */
.ml-dim { color: var(--dim, #6b8a6b); }

/* ─── v10.26+v10.27: mobile full-bleed panel ─────────────────────────
   On phones the centered lightbox wastes a lot of space to the dimmed
   surround. Let panels go full-screen so modules have the whole viewport
   to work with. Sub-modals also become full-screen for the same reason.
   Safe-area-inset is applied on .ml-panel-inner / .ml-submodal-inner
   (base rule above), so the head + body inherit it via padding-top.    */
@media (max-width: 700px) {
  .ml-panel {
    padding: 0;
    align-items: stretch;
  }
  .ml-panel-inner {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: 100vh;
    max-height: 100dvh;
    border: none;
    border-radius: 0;
  }
  .ml-submodal {
    padding: 0;
    align-items: stretch;
  }
  .ml-submodal-inner {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: 100vh;
    max-height: 100dvh;
    border: none;
    border-radius: 0;
  }
}
