/* Hestini Writer — Responsive (Quiet Canvas breakpoints) */

/* Wide desktop: >= 1440px */
@media (min-width: 1440px) {
  :root {
    --left-panel-width: 300px;
    --right-panel-width: 360px;
  }
}

/* Standard desktop: 1024-1439px */
@media (max-width: 1439px) and (min-width: 1024px) {
  .right-panel { width: 300px; }
}

/* Tablet: < 1024px — overlay left panel */
@media (max-width: 1023px) {
  .workspace { position: relative; }
  .left-panel {
    position: fixed;
    left: 0; top: var(--topbar-height); bottom: 0;
    z-index: 70;
    box-shadow: var(--shadow-lg);
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex !important;
  }
  .left-panel.mobile-open {
    transform: translateX(0);
  }
  .left-panel.collapsed { transform: translateX(-100%); }

  /* Landscape tablet: side-by-side editor + chat */
  .right-panel {
    display: flex !important;
    width: 40% !important;
    max-width: 360px;
    min-width: 260px;
    position: relative;
    border-left: 1px solid var(--border-light);
  }

  /* Backdrop overlay for left panel */
  .mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: rgba(0, 0, 0, 0.3);
    z-index: 65;
  }
  .mobile-backdrop.visible { display: block; }
}

/* ── Portrait mobile: < 768px ── */
@media (max-width: 767px) {
  /* Welcome screen */
  .welcome-header { padding: 20px 16px 12px; }
  .welcome-title { font-size: 16px; }
  .project-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .project-card { padding: 14px 16px !important; }

  /* Home toolbar compact */
  .home-toolbar { padding: 0 16px 12px; gap: 6px; flex-wrap: wrap; }
  .home-search-wrap { width: 100%; order: -1; }
  .home-search { width: 100%; }
  .home-filter { font-size: 11px; flex: 1; min-width: 0; }
  .project-container { padding: 0 16px 20px; }

  /* New project form */
  .new-project-content {
    padding: 16px !important;
    max-width: 100% !important;
  }
  .new-project-heading { font-size: 18px !important; }
  .type-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .type-card { padding: 14px 10px !important; }
  .form-group { margin-bottom: 12px !important; }
  .form-input, .form-textarea {
    font-size: 14px !important;
    padding: 10px 12px !important;
  }
  .form-footer {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .form-footer .btn { width: 100%; justify-content: center; }

  /* Topbar compact */
  .topbar { padding: 0 8px; }
  .topbar-brand { font-size: 13px; }
  .topbar-action-btn span { display: none; } /* hide text, show only icon */

  /* Left panel: overlay drawer */
  .left-panel {
    position: fixed !important;
    left: 0; top: var(--topbar-height); bottom: 0;
    z-index: 70;
    width: 85vw !important;
    max-width: 320px;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex !important;
  }
  .left-panel.mobile-open {
    transform: translateX(0);
  }

  /* Right panel: BOTTOM SHEET */
  .right-panel {
    display: flex !important;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: 45vh;
    min-height: 200px;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    z-index: 60;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }
  .right-panel.mobile-chat-open {
    transform: translateY(0);
  }

  /* Bottom sheet drag handle */
  .bottom-sheet-handle {
    display: flex !important;
  }

  /* Mobile chat FAB */
  .mobile-chat-fab {
    display: flex !important;
  }

  /* Adjust editor when chat is open */
  .workspace.chat-open .editor-content {
    padding-bottom: 60px;
  }

  /* Statusbar adjustments */
  .statusbar { bottom: 12px; }
  .statusbar-pill { padding: 6px 14px; }
  .statusbar-group { padding: 0 8px; }
  .workspace.chat-open .statusbar { bottom: calc(45vh + 8px); transition: bottom 0.3s ease; }

  /* FAB moves when chat open */
  .workspace.chat-open .mobile-chat-fab { bottom: calc(45vh + 12px); transition: bottom 0.3s ease; }

  /* Editor content — less padding */
  .editor-content { padding: 16px 16px !important; max-width: 100% !important; }

  /* Hide action button text on mobile */
  .topbar-actions .topbar-action-btn { padding: 6px !important; gap: 0 !important; }
}

/* ── Mobile toggle buttons ── */
.mobile-toggle { display: none; }
@media (max-width: 1023px) {
  .mobile-toggle { display: inline-flex !important; font-size: 18px; }
}

/* ── Bottom sheet handle (hidden on desktop) ── */
.bottom-sheet-handle {
  display: none;
  justify-content: center;
  padding: 8px 0 4px;
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
}
.handle-bar {
  width: 36px;
  height: 4px;
  background: var(--text-hint);
  border-radius: 2px;
  opacity: 0.5;
}

/* ── Mobile chat FAB (hidden on desktop) ── */
.mobile-chat-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(4, 151, 175, 0.35);
  cursor: pointer;
  z-index: 55;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, bottom 0.3s ease;
}
.mobile-chat-fab:active { transform: scale(0.9); }
.mobile-chat-fab .fab-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent-red);
  border: 2px solid var(--bg-base);
}

/* ── Mobile backdrop ── */
.mobile-backdrop {
  display: none;
}

/* ── Small phone: < 425px ── */
@media (max-width: 424px) {
  .type-grid { grid-template-columns: 1fr !important; }
  .welcome-title { font-size: 14px; }
  .topbar { font-size: 12px; }
  .statusbar-label { display: none; }
  .right-panel { height: 50vh; }
}

/* ── Remove old minimum width warning ── */
.screen-warning { display: none !important; }
