/* ==========================================================================
   ThinkNCollab - Universal Responsive Design System
   Breakpoints: Mobile (<= 576px), Tablet (<= 768px), Laptop (<= 1024px), Desktop (> 1024px)
   ========================================================================== */

/* ── Universal Smooth Box-Sizing & Viewport Guards ── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

img, video, iframe, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* ── Universal Logo 5:8 Aspect Ratio Standard (612x373 Natural Ratio) ── */
.logo img,
.nav-logo img,
.sb-logo img,
.brand-title img,
.gh-logo img,
.brand img,
.brand-icon img,
.footer-logo img,
.fb-logo img {
  height: 28px !important;
  width: auto !important;
  max-height: 28px !important;
  aspect-ratio: 612 / 373 !important;
  object-fit: contain !important;
  border-radius: 4px !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
}



/* ── Mobile Sidebar Drawer & Overlay ── */
.mob-sidebar-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--surface2, #1e1e2f);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  color: var(--text, #ffffff);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 100;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}
.mob-sidebar-toggle:hover {
  background: var(--greens, rgba(0, 255, 136, 0.1));
  color: var(--green, #00ff88);
}

.mob-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.mob-sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Responsive Data Tables Wrapper ── */
.table-responsive, .table-wrap, .table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}
.table-responsive table {
  min-width: 600px;
}

/* ── Global Adaptive Grid Layouts ── */
.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.grid-auto-fill {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* ==========================================================================
   LAPTOP & SMALL DESKTOP BREAKPOINT (max-width: 1200px)
   ========================================================================== */
@media (max-width: 1200px) {
  .room-grid {
    grid-template-columns: 280px 1fr !important;
    gap: 16px !important;
  }
  .dash-grid, .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 14px !important;
  }
  .devops-grid, .server-grid, .pipeline-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }
  .branch-drawer-panel {
    width: 340px !important;
    max-width: 48% !important;
  }
}

/* ==========================================================================
   TABLET LANDSCAPE & COMPACT LAPTOPS (max-width: 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .room-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .room-left-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
  }
  .dash-grid, .stats-grid, .grid-4, .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  .devops-summary-cards {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .board-canvas {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .terminal-wrap {
    height: calc(100vh - 120px) !important;
    min-height: 480px !important;
  }
  .status-page .status-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   TABLET PORTRAIT & MOBILE (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .mob-sidebar-toggle {
    display: inline-flex !important;
  }

  /* ── Mobile Sidebar Drawer ── */
  .sidebar, aside.sidebar, .workspace-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: -290px !important;
    width: 280px !important;
    height: 100vh !important;
    z-index: 9999 !important;
    background: var(--bg2, #0a0b12) !important;
    border-right: 1px solid var(--border2, rgba(255, 255, 255, 0.15)) !important;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.6) !important;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
  .sidebar.mobile-open, aside.sidebar.mobile-open, .sidebar.open, .workspace-sidebar.open {
    transform: translateX(290px) !important;
  }

  /* ── Main Workspace Containers ── */
  .workspace {
    flex-direction: column !important;
    min-height: auto !important;
    padding: 0 !important;
  }
  .main, main, .main-content {
    width: 100% !important;
    max-width: 100vw !important;
    padding: 12px 10px !important;
    margin-left: 0 !important;
  }

  /* ── Page Header & Action Toolbars ── */
  .page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }
  .ph-actions, .header-actions, .toolbar-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: flex-start !important;
  }
  .ph-btn, .action-btn {
    flex: 1 1 auto !important;
    min-width: 120px !important;
    justify-content: center !important;
  }

  /* ── Chat & Team Rooms ── */
  .chat-wrap {
    height: calc(100vh - 100px) !important;
    min-height: 480px !important;
    position: static !important;
    border-radius: 10px !important;
  }
  .chat-head {
    padding: 8px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .chat-head-r {
    width: 100% !important;
    justify-content: space-between !important;
    gap: 6px !important;
  }
  .chat-online-pill {
    display: none !important;
  }
  .chat-msgs {
    padding: 12px 10px !important;
  }
  .chat-msg-row {
    gap: 8px !important;
  }
  .msg-avatar {
    width: 30px !important;
    height: 30px !important;
  }
  .chat-input-wrap {
    padding: 6px 8px !important;
  }
  .chat-input-container {
    padding: 6px 8px !important;
  }

  /* ── Fullscreen Thread Drawer on Mobile ── */
  .branch-drawer-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    border-left: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  /* ── DevOps Wall, CI/CD & Active Servers ── */
  .devops-grid, .server-grid, .pipeline-grid, .devops-summary-cards {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .pipeline-stage-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .stage-connector {
    width: 2px !important;
    height: 20px !important;
    margin: 4px auto !important;
  }
  .server-telemetry-row {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* ── Terminal & Shell Users ── */
  .terminal-wrap, .cli-window {
    height: calc(100vh - 120px) !important;
    min-height: 420px !important;
    border-radius: 8px !important;
  }
  .terminal-head {
    padding: 8px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .shell-users-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .shell-user-card {
    padding: 12px !important;
  }

  /* ── Kanban Board & Timelines ── */
  .board-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .board-filter-bar {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .board-columns-wrap, .board-columns {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 12px !important;
    padding-bottom: 12px !important;
  }
  .board-col, .board-column {
    min-width: 82vw !important;
    max-width: 85vw !important;
    scroll-snap-align: center;
    flex-shrink: 0 !important;
  }

  /* ── Status & Notification Center ── */
  .status-header {
    flex-direction: column !important;
    text-align: center !important;
    gap: 10px !important;
  }
  .uptime-pill-row {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px !important;
  }
  .notif-center-wrap {
    grid-template-columns: 1fr !important;
  }

  /* ── Grids & Card Metrics ── */
  .stats-grid, .dash-grid, .grid-2, .grid-3, .grid-4, .cards-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* ── Modals & Dialogs ── */
  .modal, .modal-box, .modal-dialog {
    width: 95% !important;
    max-width: 95% !important;
    margin: 12px auto !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    padding: 16px !important;
  }
}

/* ==========================================================================
   SMALL SMARTPHONES (max-width: 480px)
   ========================================================================== */
@media (max-width: 480px) {
  .ph-title {
    font-size: 1.25rem !important;
  }
  .card-body, .card {
    padding: 10px !important;
  }
  .chat-wrap {
    height: calc(100vh - 70px) !important;
    min-height: 400px !important;
    border-radius: 8px !important;
  }
  .chat-head-sub {
    display: none !important;
  }
  .chat-input-tools {
    gap: 4px !important;
  }
  .chat-tool-icon-btn {
    width: 26px !important;
    height: 26px !important;
    font-size: 0.72rem !important;
  }
  .auth-card, .login-box, .signup-box {
    width: 100% !important;
    padding: 20px 14px !important;
    border-radius: 12px !important;
  }
  .btn, .btn-primary, .btn-green {
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
  }
}
