/* ==========================================================================
   css/responsive.css — Responsive Layout & Mobile Action Stack Standard
   ========================================================================== */

/* Desktop & Default Styles */
.project-actions-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.project-management-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.project-checkin-action-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.project-checkin-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Mobile Layout (< 768px) */
@media (max-width: 767px) {
  .project-actions-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 14px;
  }

  /* Management buttons */
  .btn-mgmt-action {
    width: 100% !important;
    height: 42px !important;
    min-height: 42px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 13px;
    box-sizing: border-box;
  }

  .project-management-actions-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .project-checkin-action-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  /* 50/50 Balanced Check-in Control Row */
  .project-checkin-controls-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }

  .project-checkin-controls-row .checkin-cycle-pill,
  .project-checkin-controls-row .checkin-toggle-bar {
    width: 100% !important;
    height: 42px !important;
    min-height: 42px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 10px;
    font-size: 13px;
    padding: 0 12px;
  }

  .project-checkin-controls-row .checkin-toggle-bar {
    justify-content: space-between;
  }

  /* Full-width primary CTA at bottom */
  .btn-checkin-today-full {
    width: 100% !important;
    height: 44px !important;
    min-height: 44px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    box-sizing: border-box;
  }
}

/* ==========================================================================
   MOBILE-ONLY UI HOTFIX: REMOVE EXCESS PADDING ON GROUP PROJECT PAGE
   Scope: Mobile View Only (max-width: 640px) - Zero Desktop Impact
   ========================================================================== */
@media (max-width: 640px) {
  /* Remove outer layout side padding when inside project detail to preserve clean 8px margin */
  #app-main:has(#view-project-detail.active),
  #app-main.project-detail-active {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  #view-project-detail {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* 1. ขยาย Main Container ของหน้าโปรเจกต์กลุ่มให้กว้างเกือบเต็มจอ */
  .project-detail-container,
  .workspace-page,
  .project-view-wrapper,
  .project-detail-view-wrap,
  .project-detail-wrapper {
    padding-left: 8px !important;
    padding-right: 8px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 2. ลด Padding ภายในการ์ดแต่ละใบ */
  .project-card,
  .deliverables-card,
  .workspace-card,
  .project-header-card,
  .deliverables-summary-card,
  .deliverables-members-card,
  .audit-log-card {
    padding: 12px 10px !important;
    border-radius: 12px !important;
    margin-bottom: 12px !important;
    box-sizing: border-box !important;
  }

  /* 3. ปุ่ม Passcode และแถบ Action ปรับให้เต็มความกว้างการ์ด */
  .project-actions-row,
  .checkin-action-btn,
  .project-actions-container,
  .btn-checkin-today-full {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  #btn-copy-passcode,
  .btn-copy-passcode {
    width: 100% !important;
    display: inline-flex !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  /* ==========================================================================
     MOBILE-ONLY UI HOTFIX: FULL-WIDTH EDGE-TO-EDGE TIMEBLOCK CALENDAR
     ========================================================================== */
  /* Remove outer layout side padding when inside calendar to allow true 100% edge-to-edge table */
  #app-main:has(#view-calendar.active),
  #app-main.calendar-active {
    padding: 0 !important;
    overflow: hidden !important;
  }

  #view-calendar.active,
  #view-calendar {
    padding: 0 !important;
    width: 100% !important;
    overflow: hidden !important;
  }

  /* 1. คอนเทนเนอร์หลักของปฏิทิน: ฟิตพอดี 1 หน้าจอ ไม่ต้อง Scroll จบเหนือกึ่งกลาง Floating Chat Button */
  .calendar-page-container,
  .timeblock-calendar-wrapper,
  .calendar-module-container {
    padding: 0 !important;
    margin: 0 !important;
    height: calc(100dvh - 52px - 54px) !important;
    height: calc(100vh - 52px - 54px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 2. Header Bar กะทัดรัด */
  .calendar-header-bar {
    margin: 0 8px 4px 8px !important;
    border-radius: 12px !important;
    padding: 6px 10px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
  }

  /* 3. ตารางปฏิทินกว้างเต็มจอ 100% ยืดเต็มพื้นที่ที่เหลือ */
  .calendar-grid-container,
  .calendar-table,
  .calendar-grid-card,
  .calendar-grid {
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
  }

  /* 4. หัวตารางวันในสัปดาห์ (อา. - ส.) */
  .calendar-days-header {
    flex-shrink: 0 !important;
    padding: 3px 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
  }

  .calendar-day-header,
  .calendar-day-col-header {
    padding: 2px 0 !important;
    font-size: 0.7rem !important;
    box-sizing: border-box !important;
  }

  /* 5. Matrix เซลล์ปฏิทิน: แบ่งอัตราส่วนความสูงเท่ากันทุกแถว (grid-auto-rows: 1fr) */
  .calendar-cells-matrix {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    grid-auto-rows: 1fr !important;
    box-sizing: border-box !important;
  }

  /* 6. เซลล์แต่ละวัน: min-height: 0 และมีสัดส่วนเท่ากันทุกแถว */
  .calendar-day-cell,
  .cal-day-cell,
  .calendar-grid-cell,
  .calendar-cell {
    min-height: 0 !important;
    height: 100% !important;
    padding: 1px 1.5px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    border: 1px solid #f1f5f9 !important;
  }

  .calendar-cell-top {
    padding: 1px 0 !important;
    margin-bottom: 1px !important;
  }

  .calendar-date-number {
    font-size: 10px !important;
    line-height: 1 !important;
  }

  .today-badge {
    width: 16px !important;
    height: 16px !important;
    font-size: 9px !important;
  }

  /* 7. แถบชื่องานในปฏิทิน: กะทัดรัด ตัดคำแบบ clip */
  .cal-task-chip {
    height: 15px !important;
    margin-bottom: 1px !important;
    padding: 0 2px !important;
  }

  .cal-task-chip span:first-child,
  .cal-task-chip .task-chip-title,
  .task-chip-title {
    font-size: 9px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: clip !important;
  }
}

/* ==========================================================================
   MOBILE-ONLY UI HOTFIX: REPOSITION & ENLARGE NEW TASK BUTTON IN SIDEBAR
   Scope: Mobile View Only (max-width: 640px) - Zero Desktop Impact
   ========================================================================== */
@media (max-width: 640px) {
  /* 1. จัด Layout เมนู Sidebar ให้ไหลต่อเนื่อง ไม่ดันปุ่มไปล่างสุด */
  .sidebar-nav-container,
  .mobile-drawer-content {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important; /* ไม่ใช้ space-between เพื่อไม่ให้ดันไปขอบล่าง */
    padding: 16px 12px !important;
    gap: 8px !important;
  }

  /* 2. คอนเทนเนอร์ปุ่มสร้างภารกิจ */
  .sidebar-cta-wrapper,
  .btn-new-task-container {
    margin-top: 14px !important; /* เว้นระยะห่างจาก 'เพิ่มเติม' เล็กน้อย */
    margin-bottom: 24px !important;
    width: 100% !important;
  }

  /* 3. ขยายขนาดปุ่มให้ใหญ่และกดง่าย (Ergonomic Touch Target) */
  .btn-new-task,
  .sidebar-cta-wrapper button {
    width: 100% !important;
    height: 48px !important; /* ความสูงมาตรฐานปุ่มกดบนมือถือ */
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25) !important;
  }

  /* Compatibility & continuous layout flow for GraviTask sidebar elements */
  #sidebar {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    padding: 16px 12px !important;
  }

  #sidebar .sidebar-nav,
  #sidebar .sidebar-nav-container,
  .sidebar-nav {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    padding: 0 !important;
    gap: 8px !important;
    flex: initial !important;
  }

  .sidebar-cta-wrap {
    margin-top: 14px !important;
    margin-bottom: 24px !important;
    width: 100% !important;
  }

  .btn-sidebar-add,
  .sidebar-cta-wrap button {
    width: 100% !important;
    height: 48px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25) !important;
  }
}

/* ==========================================================================
   GROUP PROJECTS TOOLBAR: MOBILE & DESKTOP DUAL-MODE LAYOUT
   ========================================================================== */

/* Mobile (< 768px): 2-Row Grid
   Row 1: [เลือกโปรเจกต์...] คู่กับ [สร้างโปรเจกต์กลุ่ม]
   Row 2: [ใส่ Passcode เข้าร่วม] คู่กับ [แสดงที่ซ่อนอยู่] */
@media (max-width: 767.98px) {
  .group-projects-top-bar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }

  .group-projects-title-col {
    width: 100% !important;
  }

  .group-projects-actions-container {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Row 1, Col 1: Dropdown "เลือกโปรเจกต์..." */
  #group-project-select {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    padding: 0 10px !important;
    font-size: 0.82rem !important;
    border: 1.5px solid #CBD5E1 !important;
    border-radius: 10px !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
  }

  /* Row 1, Col 2: ปุ่ม "สร้างโปรเจกต์กลุ่ม" */
  #btn-group-create-project {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 0 8px !important;
    font-size: 0.82rem !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
  }

  /* Row 2, Col 1: ปุ่ม "ใส่ Passcode เข้าร่วม" */
  #btn-group-join-project {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 0 8px !important;
    font-size: 0.82rem !important;
    border: 1.5px solid #CBD5E1 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
  }

  /* Row 2, Col 2: ปุ่ม "แสดงที่ซ่อนอยู่" */
  #btn-group-toggle-hidden {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 0 8px !important;
    font-size: 0.82rem !important;
    border: 1.5px solid #CBD5E1 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin: 0 !important;
  }
}

/* Desktop (>= 768px): Single Row / flex-row items-center gap-3 (12px)
   Order: [เลือกโปรเจกต์...] -> [แสดงที่ซ่อนอยู่] -> [ใส่ Passcode เข้าร่วม] -> [สร้างโปรเจกต์กลุ่ม] */
@media (min-width: 768px) {
  .group-projects-top-bar {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 16px !important;
    margin-bottom: 20px !important;
  }

  .group-projects-actions-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 12px !important; /* gap-3 */
    flex-wrap: nowrap !important;
    width: auto !important;
    box-sizing: border-box !important;
  }

  /* Order 1: [เลือกโปรเจกต์...] */
  #group-project-select {
    order: 1 !important;
    width: auto !important;
    min-width: 150px !important;
    max-width: 220px !important;
    height: 38px !important;
    border: 1.5px solid #CBD5E1 !important;
    border-radius: 10px !important;
    padding: 6px 12px !important;
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  /* Order 2: [แสดงที่ซ่อนอยู่] */
  #btn-group-toggle-hidden {
    order: 2 !important;
    width: auto !important;
    height: 38px !important;
    padding: 8px 12px !important;
    font-size: 0.82rem !important;
    border: 1.5px solid #CBD5E1 !important;
    border-radius: 10px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
  }

  /* Order 3: [ใส่ Passcode เข้าร่วม] */
  #btn-group-join-project {
    order: 3 !important;
    width: auto !important;
    height: 38px !important;
    padding: 8px 14px !important;
    font-size: 0.82rem !important;
    border: 1.5px solid #CBD5E1 !important;
    border-radius: 10px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
  }

  /* Order 4: [สร้างโปรเจกต์กลุ่ม] */
  #btn-group-create-project {
    order: 4 !important;
    width: auto !important;
    height: 38px !important;
    padding: 8px 16px !important;
    font-size: 0.82rem !important;
    border-radius: 10px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
  }
}

/* ==========================================================================
   PROJECT DETAIL (#project-detail): MOBILE RESPONSIVE ENHANCEMENTS
   ========================================================================== */

/* Mobile (< 768px) */
@media (max-width: 767.98px) {
  /* Line 1 & Line 2: Header Title, Status Badge, Role Badge & Passcode */
  .project-header-role-badge-desktop {
    display: none !important;
  }
  .project-header-role-badge-mobile {
    display: inline-flex !important;
  }
  .project-header-title-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  .project-header-subrow {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    margin-top: 4px !important;
  }

  /* Row 1: Line 3 (Owner, Members, Action Icons) & Line 4 (Dates Full Width) */
  .project-detail-row-1 {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  /* Flatten meta tags container on mobile using display: contents */
  .project-detail-row-1 > div.project-detail-meta-tags,
  .project-detail-meta-tags {
    display: contents !important;
  }

  /* Cut redundant role badge in metadata */
  .project-detail-meta-role-badge {
    display: none !important;
  }

  /* Line 3: Project Owner (ไม่ถูกบีบหาย ตัดไอคอนมงกุฎออก) */
  .meta-item-owner {
    order: 1 !important;
    flex: 1 1 auto !important;
    flex-shrink: 1 !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 0 8px !important;
    font-size: 0.75rem !important;
    overflow: hidden !important;
    display: inline-flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
  }
  .meta-item-owner svg {
    display: none !important;
  }
  .meta-item-owner span {
    display: block !important;
    width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Line 3: Members Count (width: fit-content; flex-shrink: 0;) */
  .meta-item-members {
    order: 2 !important;
    width: fit-content !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    padding: 0 8px !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    box-sizing: border-box !important;
  }

  /* Line 3: Action Icons (Edit / Delete) - ชิดขวาสุดในแถวเดียวกัน ไม่ตกบรรทัด */
  .project-detail-action-icons {
    order: 3 !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
  }
  .project-detail-action-icons button {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
  }

  /* Line 4: Dates Full Width */
  .meta-item-dates,
  .project-detail-row-1 .meta-item-dates {
    order: 4 !important;
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-basis: 100% !important;
    flex: 0 0 100% !important;
    clear: both !important;
    margin: 8px 0 !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    box-sizing: border-box !important;
  }

  /* Row 2: Line 5 (Search, Hide, Complete) & Line 6 (Cycle, Toggle, Checkin) */
  .project-detail-row-2 {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  /* Line 5: 3-part Control Bar in a Single Row (Search, Hide, Complete) */
  .project-detail-row-2-left {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    width: 100% !important;
    gap: 6px !important;
    align-items: center !important;
    box-sizing: border-box !important;
  }
  .project-member-search-wrap {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 0 8px !important;
    height: 36px !important;
    min-height: 36px !important;
    display: flex !important;
    align-items: center !important;
  }
  .project-member-search-input {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 0.72rem !important;
  }
  #btn-toggle-hide-workspace {
    display: inline-flex !important;
    visibility: visible !important;
    width: 100% !important;
    min-height: 36px !important;
    height: 36px !important;
    padding: 0 4px !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #btn-toggle-project-completed {
    display: inline-flex !important;
    visibility: visible !important;
    width: 100% !important;
    min-height: 36px !important;
    height: 36px !important;
    padding: 0 4px !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .hide-btn-text-desktop {
    display: none !important;
  }
  .hide-btn-text-mobile {
    display: inline !important;
  }
  .complete-btn-text-desktop {
    display: none !important;
  }
  .complete-btn-text-mobile {
    display: inline !important;
  }

  /* Member Cards: Status Badge & Action Buttons (Approve / Reject pushed to far right) */
  .member-deliverable-status-actions {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
    gap: 8px !important;
  }
  .deliverable-status-badge {
    flex: 0 0 auto !important;
  }
  .deliverable-action-buttons-group {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin-left: auto !important;
    flex: 0 0 auto !important;
  }

  /* Audit Log Header on Mobile (< 768px): 2 Lines */
  .audit-log-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    width: 100% !important;
  }
  .audit-log-subtitle {
    display: block !important;
    padding-left: 26px !important;
    font-size: 0.75rem !important;
    color: #94a3b8 !important;
  }

  /* Line 6 */
  .project-detail-row-2-right {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 6px !important;
  }
  #btn-open-eval-window-badge,
  .checkin-cycle-pill {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    justify-content: center !important;
    padding: 0 6px !important;
    font-size: 0.75rem !important;
    text-align: center !important;
  }
  .checkin-toggle-bar {
    flex: 0 0 auto !important;
    padding: 0 8px !important;
    font-size: 0.75rem !important;
  }
  #btn-quick-checkin-today {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    justify-content: center !important;
    padding: 0 6px !important;
    font-size: 0.75rem !important;
    text-align: center !important;
  }

  /* Member Cards: Check-in Footer */
  .member-card-checkin-footer {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .member-card-checkin-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }
  .member-card-progress-bar {
    width: 100% !important;
    max-width: 100% !important;
  }
  .cadence-text-desktop {
    display: none !important;
  }
  .cadence-text-mobile {
    display: inline !important;
    white-space: nowrap !important;
  }
}

/* Desktop (>= 768px) */
@media (min-width: 768px) {
  .project-detail-row-1 {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 12px !important;
    flex-wrap: nowrap !important;
  }
  .project-detail-meta-tags {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    width: auto !important;
    order: initial !important;
  }
  .project-detail-meta-role-badge {
    display: inline-flex !important;
  }
  .meta-item-owner,
  .meta-item-members,
  .meta-item-dates {
    order: initial !important;
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: none !important;
    margin-top: 0 !important;
  }
  #view-project-detail .project-detail-action-icons,
  .project-detail-view-wrap .project-detail-action-icons,
  .project-detail-row-1 .project-detail-action-icons,
  .project-detail-action-icons,
  #view-project-detail .project-detail-action-icons:has(#btn-project-leave),
  .project-detail-action-icons:has(#btn-project-leave) {
    order: initial !important;
    flex: 0 0 auto !important;
    margin-left: auto !important;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    gap: 8px !important;
  }

  #view-project-detail #btn-project-leave,
  .btn-project-leave-desktop {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: 36px !important;
  }

  /* Project Detail Row 2 (Operational Controls Bar): Single Flex Row Restoration */
  #view-project-detail #project-detail-row-2,
  #view-project-detail .project-detail-row-2,
  .project-detail-view-wrap .project-detail-row-2,
  .project-detail-row-2 {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
    grid-template-columns: none !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  #view-project-detail .project-detail-row-2::-webkit-scrollbar,
  .project-detail-view-wrap .project-detail-row-2::-webkit-scrollbar,
  .project-detail-row-2::-webkit-scrollbar {
    display: none !important;
  }

  /* Left sub-container: [1. ช่องค้นหาสมาชิก] [2. ซ่อนจากหน้าหลัก] [3. จบโปรเจกต์] */
  #view-project-detail .project-detail-row-2-left,
  .project-detail-view-wrap .project-detail-row-2-left,
  .project-detail-row-2-left {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: auto !important;
    flex: 0 0 auto !important;
    gap: 8px !important;
    margin: 0 !important;
    grid-template-columns: none !important;
    box-sizing: border-box !important;
  }

  /* Right sub-container: [4. แถบรอบเช็กอิน] [5. สวิตช์เปิดเช็กอิน] [6. ปุ่มเช็กอินวันนี้] */
  #view-project-detail .project-detail-row-2-right,
  .project-detail-view-wrap .project-detail-row-2-right,
  .project-detail-row-2-right {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: auto !important;
    flex: 0 0 auto !important;
    gap: 8px !important;
    margin: 0 !important;
    grid-template-columns: none !important;
    box-sizing: border-box !important;
  }

  /* 1. ช่องค้นหาสมาชิก */
  #view-project-detail .project-member-search-wrap,
  .project-detail-view-wrap .project-member-search-wrap,
  .project-detail-row-2-left .project-member-search-wrap,
  .project-member-search-wrap {
    display: inline-flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 0 10px !important;
    height: 36px !important;
    min-height: 36px !important;
    box-sizing: border-box !important;
  }
  #view-project-detail .project-member-search-input,
  .project-detail-view-wrap .project-member-search-input,
  .project-detail-row-2-left .project-member-search-input,
  .project-member-search-input {
    width: 120px !important;
    min-width: 80px !important;
    font-size: 0.75rem !important;
  }

  /* 2. ปุ่มซ่อนจากหน้าหลัก (Archive) */
  #view-project-detail #btn-toggle-hide-workspace,
  .project-detail-view-wrap #btn-toggle-hide-workspace,
  .project-detail-row-2-left #btn-toggle-hide-workspace,
  #btn-toggle-hide-workspace {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    height: 36px !important;
    min-height: 36px !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    gap: 4px !important;
  }

  /* 3. ปุ่มทำเครื่องหมายว่าจบโปรเจกต์ */
  #view-project-detail #btn-toggle-project-completed,
  .project-detail-view-wrap #btn-toggle-project-completed,
  .project-detail-row-2-left #btn-toggle-project-completed,
  #btn-toggle-project-completed {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    height: 36px !important;
    min-height: 36px !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    gap: 4px !important;
  }

  /* 4. แถบรอบเช็กอิน */
  #view-project-detail #btn-open-eval-window-badge,
  .project-detail-view-wrap #btn-open-eval-window-badge,
  #view-project-detail .checkin-cycle-pill,
  .project-detail-view-wrap .checkin-cycle-pill,
  #btn-open-eval-window-badge,
  .checkin-cycle-pill {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    gap: 4px !important;
  }

  /* 5. สวิตช์เปิดเช็กอิน */
  #view-project-detail .checkin-toggle-bar,
  .project-detail-view-wrap .checkin-toggle-bar,
  .checkin-toggle-bar {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    align-items: center !important;
    justify-content: space-between !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    gap: 6px !important;
  }

  /* 6. ปุ่มเช็กอินวันนี้ */
  #view-project-detail #btn-quick-checkin-today,
  .project-detail-view-wrap #btn-quick-checkin-today,
  .project-detail-row-2-right #btn-quick-checkin-today,
  #btn-quick-checkin-today {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }

  /* Desktop (>= 768px): ซ่อนปุ่มออกจากโปรเจกต์บนมือถือ และแสดงปุ่มในแถว Master ด้านบน */
  #btn-project-leave-mobile,
  .btn-project-leave-mobile,
  #view-project-detail #btn-project-leave-mobile,
  .project-detail-view-wrap #btn-project-leave-mobile,
  .project-detail-row-2-left #btn-project-leave-mobile {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }
  #view-project-detail .project-detail-action-icons #btn-project-leave,
  .project-detail-view-wrap .project-detail-action-icons #btn-project-leave,
  .project-detail-row-1 .project-detail-action-icons #btn-project-leave,
  .project-detail-action-icons #btn-project-leave,
  #btn-project-leave,
  .btn-project-leave-desktop {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }
  .member-deliverable-status-actions {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    width: auto !important;
  }
  .deliverable-action-buttons-group {
    margin-left: 0 !important;
  }
  .audit-log-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
  }
  .audit-log-subtitle {
    padding-left: 0 !important;
  }
  .project-header-role-badge-desktop {
    display: inline-flex !important;
  }
  .project-header-role-badge-mobile {
    display: none !important;
  }
  .hide-btn-text-desktop {
    display: inline !important;
  }
  .hide-btn-text-mobile {
    display: none !important;
  }
  .complete-btn-text-desktop {
    display: inline !important;
  }
  .complete-btn-text-mobile {
    display: none !important;
  }
  .cadence-text-desktop {
    display: inline !important;
  }
  .cadence-text-mobile {
    display: none !important;
  }

  /* ==========================================================================
     DESKTOP FULL-WIDTH SYMMETRICAL MASTER LAYOUT (#project-detail)
     ========================================================================== */

  /* 1. แถวบน (แถวที่ 1: ข้อมูลสรุป + ปุ่มไอคอนจัดการ) */
  #view-project-detail .project-detail-row-1,
  .project-detail-view-wrap .project-detail-row-1,
  .project-detail-row-1 {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  #view-project-detail .project-detail-meta-tags,
  .project-detail-view-wrap .project-detail-meta-tags,
  .project-detail-meta-tags {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 1 1 auto !important;
  }

  #view-project-detail .project-detail-action-icons,
  .project-detail-view-wrap .project-detail-action-icons,
  .project-detail-action-icons {
    margin-left: auto !important;
    flex-shrink: 0 !important;
  }

  /* 2. แถวล่าง (แถวที่ 2: แถบควบคุมและการเช็กอิน) */
  #view-project-detail #project-detail-row-2,
  #view-project-detail .project-detail-row-2,
  .project-detail-view-wrap .project-detail-row-2,
  .project-detail-row-2 {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 12px !important;
  }

  #view-project-detail .project-detail-row-2-left,
  .project-detail-view-wrap .project-detail-row-2-left,
  .project-detail-row-2-left {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  #view-project-detail .project-member-search-wrap,
  .project-detail-view-wrap .project-member-search-wrap,
  .project-detail-row-2-left .project-member-search-wrap,
  .project-member-search-wrap {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 140px !important;
    max-width: none !important;
  }

  #view-project-detail .project-member-search-input,
  .project-detail-view-wrap .project-member-search-input,
  .project-detail-row-2-left .project-member-search-input,
  .project-member-search-input {
    width: 100% !important;
  }

  #view-project-detail #btn-toggle-hide-workspace,
  .project-detail-view-wrap #btn-toggle-hide-workspace,
  .project-detail-row-2-left #btn-toggle-hide-workspace,
  #btn-toggle-hide-workspace {
    flex-shrink: 0 !important;
    width: auto !important;
  }

  #view-project-detail #btn-toggle-project-completed,
  .project-detail-view-wrap #btn-toggle-project-completed,
  .project-detail-row-2-left #btn-toggle-project-completed,
  #btn-toggle-project-completed {
    flex-shrink: 0 !important;
    width: auto !important;
  }

  #view-project-detail .project-detail-row-2-right,
  .project-detail-view-wrap .project-detail-row-2-right,
  .project-detail-row-2-right {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
    margin-left: auto !important;
  }

  #view-project-detail #btn-project-leave,
  .btn-project-leave-desktop {
    flex-shrink: 0 !important;
    width: auto !important;
  }
}





/* ==========================================================================
   MOBILE-ONLY (< 768px) HOTFIX: GROUP PROJECTS TOOLBAR/CARD FOOTER & PROJECT DETAIL HEADER
   Desktop (>= 768px) is untouched.
   ========================================================================== */
@media (max-width: 767.98px) {
  /* Group Projects toolbar: ensure Create button is visible, 2x2 grid */
  #btn-group-create-project {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
  }
  #group-project-select { grid-column: 1 !important; grid-row: 1 !important; }
  #btn-group-join-project { grid-column: 1 !important; grid-row: 2 !important; }
  #btn-group-toggle-hidden { grid-column: 2 !important; grid-row: 2 !important; }

  /* Group Projects card footer: Avatar + Owner on left, "เข้าสู่โปรเจกต์" pushed to far right */
  #group-projects-grid .proj-card-footer {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 8px !important;
  }
  #group-projects-grid .proj-card-footer .proj-card-owner-info {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  #group-projects-grid .proj-card-footer .btn-enter-group-project {
    margin-left: auto !important;
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }

  /* Project Detail header: Line 1 = Title + Status badge; Line 2 = Owner badge + Passcode */
  .project-header-title-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .project-header-title-row > h1 {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    overflow-wrap: anywhere !important;
  }
  .project-header-title-row > span {
    flex: 0 0 auto !important;
  }
  .project-header-subrow {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .project-header-role-badge-desktop { display: none !important; }
  .project-header-role-badge-mobile { display: inline-flex !important; flex: 0 0 auto !important; }
  .project-header-subrow .btn-copy-passcode { flex: 0 0 auto !important; }
}


/* ==========================================================================
   MOBILE-ONLY (< 768px): PROJECT DETAIL HEADER — status badge top-right, Passcode fit-content
   Desktop (>= 768px) is untouched.
   ========================================================================== */
@media (max-width: 767.98px) {
  .project-header-card { position: relative !important; }
  .project-header-title-row { padding-right: 96px !important; }
  .project-header-title-row > .project-header-status-badge {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    margin: 0 !important;
    z-index: 1 !important;
  }
  .project-header-subrow {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
  }
  .project-header-subrow .btn-copy-passcode,
  #btn-copy-passcode {
    display: inline-flex !important;
    width: fit-content !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }
}

/* ==========================================================================
   MOBILE-ONLY (< 768px): PROJECT DETAIL MIDDLE ZONE (ROW 3, ROW 4, ROW 5)
   Desktop (>= 769px) is untouched 100%.
   ========================================================================== */
@media (max-width: 767px) {
  /* คอนเทนเนอร์หลักของแถวที่ 3 และ 4 */
  #view-project-detail .project-detail-row-1,
  .project-detail-view-wrap .project-detail-row-1,
  .project-detail-row-1 {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    white-space: normal !important;
  }

  /* คลาย Wrapper meta-tags ให้ลูกๆ เข้าสู่แถว flex ของ row-1 โดยตรง */
  #view-project-detail .project-detail-row-1 > div.project-detail-meta-tags,
  #view-project-detail .project-detail-row-1 > .project-detail-meta-tags,
  #view-project-detail .project-detail-meta-tags,
  .project-detail-view-wrap .project-detail-row-1 > .project-detail-meta-tags,
  .project-detail-view-wrap .project-detail-meta-tags,
  .project-detail-row-1 > div.project-detail-meta-tags,
  .project-detail-row-1 > .project-detail-meta-tags,
  .project-detail-row-1 .project-detail-meta-tags,
  .project-detail-meta-tags {
    display: contents !important;
  }

  /* ซ่อน badge สถานะที่ซ้ำซ้อนใน metadata */
  #view-project-detail .project-detail-meta-role-badge,
  .project-detail-row-1 .project-detail-meta-role-badge,
  .project-detail-meta-role-badge {
    display: none !important;
  }

  /* ==========================================================================
     1. บรรทัดที่ 3 (ข้อมูลเจ้าของ + สมาชิก + ปุ่มจัดการ) แนวนอนแถวเดียวกัน ไม่ตกบรรทัด
     ========================================================================== */
  /* ส่วนที่ 1 (ซ้ายสุด): ป้าย "Project Owner: [ชื่อ]" แสดงข้อความชัดเจน ไม่ถูกบีบหาย ตัดไอคอนมงกุฎออก */
  #view-project-detail .meta-item-owner,
  .project-detail-view-wrap .meta-item-owner,
  .project-detail-row-1 .meta-item-owner,
  .meta-item-owner {
    order: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    flex: 1 1 auto !important;
    flex-shrink: 1 !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 36px !important;
    padding: 0 8px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }
  #view-project-detail .meta-item-owner svg,
  .project-detail-view-wrap .meta-item-owner svg,
  .project-detail-row-1 .meta-item-owner svg,
  .meta-item-owner svg {
    display: none !important;
  }
  #view-project-detail .meta-item-owner span,
  .project-detail-view-wrap .meta-item-owner span,
  .project-detail-row-1 .meta-item-owner span,
  .meta-item-owner span {
    display: block !important;
    width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 0.75rem !important;
  }

  /* ส่วนที่ 2 (กลาง): ป้าย "4 สมาชิก" (width: fit-content; flex-shrink: 0;) */
  #view-project-detail .meta-item-members,
  .project-detail-view-wrap .meta-item-members,
  .project-detail-row-1 .meta-item-members,
  .meta-item-members {
    order: 2 !important;
    display: inline-flex !important;
    align-items: center !important;
    width: fit-content !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    height: 36px !important;
    padding: 0 8px !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    font-size: 0.75rem !important;
    gap: 4px !important;
  }
  #view-project-detail .meta-item-members svg,
  .project-detail-view-wrap .meta-item-members svg,
  .project-detail-row-1 .meta-item-members svg,
  .meta-item-members svg {
    width: 13px !important;
    height: 13px !important;
    flex-shrink: 0 !important;
  }

  /* ส่วนที่ 3 (ขวาสุด): ปุ่มไอคอน [ดินสอแก้ไข] และ [ถังขยะลบ] ดึงขึ้นมาวางต่อท้าย 4 สมาชิก ชิดขวาสุดในแถวนี้ทันที ไม่ตกบรรทัด */
  #view-project-detail .project-detail-action-icons,
  .project-detail-view-wrap .project-detail-action-icons,
  .project-detail-row-1 .project-detail-action-icons,
  .project-detail-action-icons {
    order: 3 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    white-space: nowrap !important;
  }
  #view-project-detail .project-detail-action-icons button,
  .project-detail-view-wrap .project-detail-action-icons button,
  .project-detail-row-1 .project-detail-action-icons button,
  .project-detail-row-1 .project-detail-action-icons .btn-edit-project-meta,
  .project-detail-row-1 .project-detail-action-icons .btn-delete-project-meta,
  .project-detail-action-icons button {
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }

  /* ==========================================================================
     2. บรรทัดที่ 4 (ระยะเวลาโปรเจกต์): แถวเดี่ยว 100% ขอบซ้าย-ขวายาวเสมอกับการ์ดพอดี
     ========================================================================== */
  #view-project-detail .meta-item-dates,
  .project-detail-view-wrap .meta-item-dates,
  .project-detail-row-1 .meta-item-dates,
  .meta-item-dates {
    order: 4 !important;
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    flex-basis: 100% !important;
    clear: both !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    margin: 8px 0 !important;
    height: 36px !important;
    padding: 0 10px !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }

  /* 3. แถวควบคุม 3 ช่อง (แถวที่ 5: ค้นหา / ซ่อน / จบโปรเจกต์):
     - ปรับ Container ของแถวควบคุม:
       display: grid !important;
       grid-template-columns: 1fr 1fr 1fr !important;
       width: 100% !important;
       gap: 6px !important; */
  #view-project-detail .project-detail-row-2-left,
  .project-detail-view-wrap .project-detail-row-2-left,
  .project-detail-row-2 .project-detail-row-2-left,
  .project-detail-row-2-left {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    width: 100% !important;
    gap: 6px !important;
    align-items: center !important;
    box-sizing: border-box !important;
  }

  /* ช่องซ้าย: Input "ค้นหาสมาชิก..." (height เท่ากับปุ่มแถวล่าง) */
  #view-project-detail .project-member-search-wrap,
  .project-detail-row-2-left .project-member-search-wrap,
  .project-member-search-wrap {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
    height: 36px !important;
    min-height: 36px !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 8px !important;
    gap: 4px !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
  }
  #view-project-detail .project-member-search-input,
  .project-detail-row-2-left .project-member-search-input,
  .project-member-search-input {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    font-size: 0.72rem !important;
    box-sizing: border-box !important;
  }

  /* ช่องกลาง: ปุ่ม "ซ่อนจากหน้าหลัก"
     - #btn-toggle-hide-workspace { display: inline-flex !important; visibility: visible !important; width: 100% !important; min-height: 36px !important; } */
  #view-project-detail #btn-toggle-hide-workspace,
  .project-detail-view-wrap #btn-toggle-hide-workspace,
  .project-detail-row-2-left #btn-toggle-hide-workspace,
  #btn-toggle-hide-workspace {
    display: inline-flex !important;
    visibility: visible !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 36px !important;
    height: 36px !important;
    flex: none !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 0 4px !important;
    font-size: 0.72rem !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
    gap: 4px !important;
    opacity: 1 !important;
  }
  #btn-toggle-hide-workspace svg {
    flex-shrink: 0 !important;
    width: 12px !important;
    height: 12px !important;
  }
  #btn-toggle-hide-workspace .hide-btn-text-desktop {
    display: none !important;
  }
  #btn-toggle-hide-workspace .hide-btn-text-mobile {
    display: inline !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* ช่องขวา: ปุ่ม "จบโปรเจกต์" (ดึงกลับมาแสดงผล)
     - #btn-toggle-project-completed { display: inline-flex !important; visibility: visible !important; width: 100% !important; min-height: 36px !important; } */
  #view-project-detail #btn-toggle-project-completed,
  .project-detail-view-wrap #btn-toggle-project-completed,
  .project-detail-row-2-left #btn-toggle-project-completed,
  #btn-toggle-project-completed {
    display: inline-flex !important;
    visibility: visible !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 36px !important;
    height: 36px !important;
    flex: none !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 0 4px !important;
    font-size: 0.72rem !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
    gap: 4px !important;
    opacity: 1 !important;
  }
  #btn-toggle-project-completed svg {
    flex-shrink: 0 !important;
    width: 12px !important;
    height: 12px !important;
  }
  #btn-toggle-project-completed .complete-btn-text-desktop {
    display: none !important;
  }
  #btn-toggle-project-completed .complete-btn-text-mobile {
    display: inline !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* ช่องขวา (มุมมองสมาชิก): ปุ่ม "ออกจากโปรเจกต์"
     - width: 100% !important; height: 36px !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; white-space: nowrap !important; */
  #view-project-detail #btn-project-leave-mobile,
  .project-detail-view-wrap #btn-project-leave-mobile,
  .project-detail-row-2-left #btn-project-leave-mobile,
  #btn-project-leave-mobile,
  .btn-project-leave-mobile {
    display: inline-flex !important;
    visibility: visible !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 36px !important;
    height: 36px !important;
    flex: none !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    padding: 0 4px !important;
    font-size: 0.72rem !important;
    box-sizing: border-box !important;
    border-radius: 12px !important;
    gap: 4px !important;
    opacity: 1 !important;
  }
  #btn-project-leave-mobile svg,
  .btn-project-leave-mobile svg {
    flex-shrink: 0 !important;
    width: 12px !important;
    height: 12px !important;
  }
  #btn-project-leave-mobile span,
  .btn-project-leave-mobile span {
    display: inline !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* บน Mobile ซ่อนปุ่มออกจากโปรเจกต์จากแถวข้อมูลด้านบน (Row 1 / Line 3) */
  #view-project-detail .project-detail-action-icons #btn-project-leave,
  .project-detail-action-icons #btn-project-leave,
  .btn-project-leave-desktop {
    display: none !important;
  }
  #view-project-detail .project-detail-action-icons:has(#btn-project-leave:only-child),
  .project-detail-action-icons:has(#btn-project-leave:only-child) {
    display: none !important;
  }

  /* ตรวจสอบความสูงปุ่มแถวล่าง (Line 6) ให้เท่ากัน 36px พอดี */
  .project-detail-row-2-right #btn-quick-checkin-today {
    height: 36px !important;
    min-height: 36px !important;
    box-sizing: border-box !important;
  }
}
