/* responsive.css
   ALL media queries + responsive overrides live here (Approach 1)
*/

/* Drawer backdrop (paired with drawer) */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.4);
  z-index: 20;
}

/* Desktop modal (Chat rename/delete) */
.das-modal-overlay[hidden] {
  display: none;
}
.das-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.35);
}
@media (min-width: 1025px) {
  .das-modal-overlay {
    backdrop-filter: blur(8px);
  }
}

.das-modal {
  width: min(520px, 100%);
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 18px 14px;
}

.das-modal__title {
  margin: 0 0 8px;
  font-size: 16px;
}
.das-modal__message {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.das-modal__input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: var(--text);
}
.das-modal__input[hidden] {
  display: none;
}
.das-modal__input:focus {
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.18);
}

.das-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.das-modal__btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}

.das-modal__btn--ghost {
  background: rgba(2, 6, 23, 0.04);
  border-color: rgba(2, 6, 23, 0.08);
  color: var(--text);
}

.das-modal__btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.das-modal__btn--danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.das-modal__btn:focus-visible {
  outline: 3px solid rgba(15, 76, 129, 0.28);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
  }

  /* Mobile/iPad: show logo in topbar, hide page title */
  .topbar-page {
    display: none;
  }
  .topbar-brand {
    display: inline-flex;
  }

  .topbar {
    padding: calc(8px + var(--safe-top)) 12px 8px; /* old: 12px sides */
    gap: 0; /* old: gap 0 */
  }
  .menu-toggle {
    margin-right: 12px; /* old: 12px */
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(var(--sb-w), 88vw);
    transform: translateX(-110%);
    transition: transform 0.22s ease;
    z-index: 30;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Mobile/iPad: chats live under "..." panel, not inside sidebar */
  #sidebar .sb-section {
    display: none;
  }

  /* Mobile/iPad: hide profile name + picture (keep on desktop) */
  #sidebar .userchip {
    display: none;
  }

  /* Mobile/iPad: hide New chat + Search chats in hamburger (they live in header/panel) */
  #sidebar [data-action="newChat"],
  #sidebar [data-action="search"] {
    display: none;
  }

  .chats-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 88vw);
    background: #fff;
    transform: translateX(110%);
    transition: transform 0.22s ease;
    z-index: 40;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
  }
  .chats-panel.open {
    transform: translateX(0);
  }

  .chats-panel-head {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
  }
  .chats-panel-title {
    font-size: 14px;
    font-weight: 650;
    color: rgba(15, 23, 42, 0.92);
  }
  .chats-panel-body {
    min-height: 0;
    overflow: hidden;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  #chatsPanelContent {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .chats-search {
    width: 100%;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 0 12px;
    font-size: 16px; /* avoids mobile zoom */
    outline: none;
    background: #fff;
  }

  /* avoid double title inside the moved block */
  .chats-panel .sb-section {
    margin-top: 0;
  }
  .chats-panel .sb-section-title {
    display: none;
  }

  .sb-chatmenu-pop {
    min-width: 200px;
  }
}

@media (min-width: 1025px) {
  :root {
    --sb-w: 260px; /* slimmer sidebar on desktop only */
  }

  #hamburger,
  .menu-toggle {
    display: none;
  }

  .backdrop {
    display: none !important;
  }

  /* Desktop: hide + and ... in topbar */
  .topbar-actions {
    display: none;
  }

  /* Desktop: hide Search chats completely (keep iPad/mobile) */
  .sb-nav .sb-btn[data-action="search"],
  #sidebar [data-action="search"],
  .chats-search {
    display: none !important;
  }

  /* Desktop only: remove underline + subtle hover for Profile/Settings links */
  .sb-nav a.sb-btn {
    text-decoration: none;
    color: inherit;
  }
  .sb-nav a.sb-btn:hover {
    background: rgba(15, 76, 129, 0.08);
  }

  /* Desktop: use more horizontal space + shift content left */
  .msg {
    width: min(980px, 100%);
    margin: 0;
  }

  .composer {
    width: min(980px, 100%);
    margin: 0;
  }
}

@media (pointer: fine) {
  .sb-chatmenu {
    opacity: 0;
    pointer-events: none;
    transform: translateY(1px);
  }

  .sb-chatrow:hover .sb-chatmenu,
  .sb-chatrow:focus-within .sb-chatmenu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

@media (pointer: coarse) {
  .sb-chatmenu {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
  .iconbtn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }
  .roundbtn {
    width: 46px;
    height: 46px;
  }
}
