/**
 * DocuSense — Mobile & Responsive Styles (Gap 16)
 * Bottom tab bar, drawer panels, touch targets, mobile layout
 */

/* ─────────────────────────────────────────────
   MOBILE BOTTOM NAV BAR
───────────────────────────────────────────── */
.ds-mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  height: 56px;
  flex-direction: row;
  align-items: stretch;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.10);
}

.ds-mob-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--c-text-muted);
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 500;
  padding: 6px 4px;
  transition: color 0.15s;
  min-width: 44px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.ds-mob-tab svg {
  width: 20px;
  height: 20px;
}

.ds-mob-tab.active {
  color: var(--c-primary);
}

.ds-mob-tab.active svg {
  stroke: var(--c-primary);
}

/* Floating Action Button in mobile nav */
.ds-mob-fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--c-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  top: -10px;
}

.ds-mob-fab:active { transform: scale(0.93); box-shadow: 0 1px 6px rgba(0,0,0,0.2); }

.ds-mob-fab svg {
  width: 22px;
  height: 22px;
  stroke: #fff;
}

/* ─────────────────────────────────────────────
   QUICK HELP SLIDE-IN PANEL
───────────────────────────────────────────── */
.ds-quick-help {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100vh;
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.13);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.22s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.ds-quick-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--c-border-light);
  font-family: var(--font-ui);
  font-size: 13px;
}

.ds-quick-help-search {
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border-light);
}

.ds-quick-help-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--border-r-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  background: var(--c-surface-2);
  color: var(--c-text);
  box-sizing: border-box;
}

.ds-quick-help-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.qh-section {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border-light);
}

.qh-section:last-of-type { border-bottom: none; }

.qh-section h4 {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-primary);
  margin: 0 0 5px;
}

.qh-section p {
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: var(--c-text);
  line-height: 1.55;
  margin: 0;
}

.qh-section a {
  color: var(--c-primary);
  text-decoration: none;
}

/* ─────────────────────────────────────────────
   DICTIONARY TAG CLOUD
───────────────────────────────────────────── */
.dict-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 2px 8px 2px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text);
  margin: 2px;
}

/* ─────────────────────────────────────────────
   TABLET: 768px – 1100px
   Two-panel layout, comments as overlay
───────────────────────────────────────────── */
@media (max-width: 1100px) {
  /* Shrink left sidebar slightly */
  #panel-left {
    width: 220px;
    min-width: 180px;
  }

  /* Reduce font sizes in sidebar */
  #panel-left .ds-section-title {
    font-size: 10px;
  }
}

/* ─────────────────────────────────────────────
   MOBILE: ≤ 768px
   Bottom tab navigation, full-screen panels
───────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Show bottom nav */
  .ds-mobile-nav { display: flex; }

  /* Add bottom padding so content isn't hidden behind nav */
  .ds-workspace {
    padding-bottom: 56px;
  }

  /* Stack layout: hide non-active panels */
  .ds-workspace {
    display: block;
    height: calc(100vh - var(--topbar-h, 48px) - 56px);
    overflow: hidden;
  }

  /* Left panel becomes full-screen drawer */
  #panel-left {
    position: fixed;
    top: var(--topbar-h, 48px);
    left: 0;
    bottom: 56px;
    width: 100vw;
    max-width: 100vw;
    z-index: 800;
    background: var(--c-surface);
    border-right: none;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  #panel-left[data-mob-visible="1"] {
    transform: translateX(0);
  }

  /* Center (document) panel */
  .ds-center {
    position: fixed;
    top: var(--topbar-h, 48px);
    left: 0;
    bottom: 56px;
    width: 100vw;
    z-index: 700;
    background: var(--c-bg);
    overflow-y: auto;
    display: none;
  }

  .ds-center[data-mob-visible="1"] {
    display: block;
  }

  /* Right panel (comments) — slide in from right */
  #panel-right {
    position: fixed;
    top: var(--topbar-h, 48px);
    right: 0;
    bottom: 56px;
    width: 100vw;
    max-width: 100vw;
    z-index: 800;
    background: var(--c-surface);
    border-left: none;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.22s ease;
  }

  #panel-right[data-mob-visible="1"] {
    transform: translateX(0);
  }

  /* Default visible panel: center */
  .ds-center { display: block; }

  /* Make all panels default to hidden on mobile; JS controls visibility */
  #panel-left:not([data-mob-visible="1"])  { transform: translateX(-100%); }
  #panel-right:not([data-mob-visible="1"]) { transform: translateX(100%); }

  /* Increase all tap targets */
  button, .ds-btn, .ds-btn-xs, input[type="checkbox"], input[type="radio"],
  select, .ds-ai-mode-card, .ds-tab-btn {
    min-height: 44px;
  }

  .ds-btn-xs {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Header: hide desktop-only elements */
  .ds-topbar .ds-breadcrumb { display: none; }

  /* Header buttons compress */
  .ds-topbar-actions { gap: 4px; }
  .ds-topbar-actions .ds-btn { padding: 6px 10px; font-size: 11px; }

  /* Modals: full screen on mobile */
  .ds-modal {
    max-width: 100vw !important;
    width: 100vw;
    margin: 0;
    border-radius: 0;
    height: 100vh;
    max-height: 100vh;
  }

  .ds-modal-overlay {
    align-items: flex-end;
  }

  /* Comment cards: larger touch targets */
  .ds-comment-card {
    padding: 12px 14px;
  }

  /* Doc viewer: larger font for readability */
  #doc-viewer {
    font-size: 15px;
    padding: 16px;
  }

  /* Template split: stack vertically */
  .ds-template-split {
    flex-direction: column;
  }

  .ds-template-split .ds-split-pane {
    width: 100%;
    height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
  }

  /* Quick help: full screen on mobile */
  .ds-quick-help {
    width: 100vw;
    border-left: none;
  }

  /* Check selection button: larger */
  #btn-check-selection {
    min-height: 36px;
    font-size: 11px;
  }

  /* Hide resize handles on mobile */
  .ds-resize-handle { display: none; }
}

/* ─────────────────────────────────────────────
   SMALL MOBILE: ≤ 480px
───────────────────────────────────────────── */
@media (max-width: 480px) {
  .ds-topbar { padding: 0 8px; }

  .ds-topbar-actions .ds-btn span { display: none; } /* icon-only buttons */

  #doc-viewer { font-size: 14px; padding: 12px; }

  .ds-comment-card { padding: 10px 12px; }

  /* AI mode cards stack */
  .ds-ai-mode-grid {
    grid-template-columns: 1fr 1fr;
  }
}
