/* V38.24 TARGETED — PC WHATSAPP CHAT HEADER & SETTINGS/SYSTEM ICONS
 * Scope: >=768px (PC & Tablet). Mobile (<=767px) is completely untouched.
 * NO logic/data/Firebase/auth changes.
 */

@media (min-width: 768px) {
  /* ============================================================
     1) SEAMLESS WHATSAPP-STYLE CHAT HEADER (PC/TABLET >= 768px)
     ============================================================ */
  .chat-main .chat-header,
  .chat-header {
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    padding: 0 18px !important;
    background: var(--bg-header) !important;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    z-index: 25 !important;
    transition: background 0.25s ease, border-color 0.25s ease !important;
  }

  :root[data-theme="dark"] .chat-main .chat-header,
  :root[data-theme="dark"] .chat-header {
    background: #202c33 !important; /* Authentic WhatsApp Web Dark Header */
    border-bottom: 1px solid rgba(134, 150, 160, 0.15) !important;
  }

  :root[data-theme="light"] .chat-main .chat-header,
  :root[data-theme="light"] .chat-header {
    background: #f0f2f5 !important; /* Authentic WhatsApp Web Light Header */
    border-bottom: 1px solid rgba(11, 20, 26, 0.08) !important;
  }

  .chat-header-left {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  /* Avatar styling - WhatsApp smooth circle */
  .chat-header-left #headerAvt,
  .chat-header-left .room-avt {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    letter-spacing: normal !important;
    user-select: none !important;
    cursor: pointer !important;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, filter 0.2s ease !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    flex-shrink: 0 !important;
    border: none !important;
    background: linear-gradient(135deg, #00a884, #008f6f) !important;
    color: #ffffff !important;
  }

  .chat-header-left #headerAvt:hover,
  .chat-header-left .room-avt:hover {
    transform: scale(1.06) !important;
    filter: brightness(1.08) !important;
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.3) !important;
  }

  /* When showing idle '#' state (no room selected) */
  .chat-header-left #headerAvt:empty,
  .chat-header-left #headerAvt.is-private {
    background: color-mix(in srgb, #00a884 15%, var(--bg-main)) !important;
    color: #00a884 !important;
    border: 1.5px solid color-mix(in srgb, #00a884 40%, transparent) !important;
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.12) !important;
  }

  :root[data-theme="dark"] .chat-header-left #headerAvt.is-private {
    background: rgba(0, 168, 132, 0.14) !important;
    color: #25d366 !important;
    border-color: rgba(37, 211, 102, 0.35) !important;
  }

  /* Room Name & Info - WhatsApp typography */
  .chat-header-left .chat-header-name,
  #currentRoomName {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--text-main) !important;
    line-height: 1.3 !important;
    letter-spacing: -0.01em !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    transition: color 0.18s ease !important;
  }

  :root[data-theme="dark"] #currentRoomName {
    color: #e9edef !important;
  }
  :root[data-theme="light"] #currentRoomName {
    color: #111b21 !important;
  }

  .chat-header-left .chat-header-status {
    font-size: 12.5px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    color: var(--text-sub) !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin-top: 1px !important;
  }

  :root[data-theme="dark"] .chat-header-left .chat-header-status {
    color: #8696a0 !important;
  }
  :root[data-theme="light"] .chat-header-left .chat-header-status {
    color: #667781 !important;
  }

  /* WhatsApp online indicator dot */
  .chat-header-left .chat-header-status::before {
    content: '' !important;
    width: 7px !important;
    height: 7px !important;
    min-width: 7px !important;
    border-radius: 50% !important;
    background: #00a884 !important;
    box-shadow: 0 0 6px rgba(0, 168, 132, 0.7) !important;
    display: inline-block !important;
  }

  /* ============================================================
     2) WHATSAPP-STYLE RIGHT ACTION CONTROLS (SEARCH & INFO)
     ============================================================ */
  .chat-header-right {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
  }

  /* Search wrapper */
  .chat-header-right .msg-search-wrapper {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  /* Replace ugly '⌕' text glyph with sharp SVG WhatsApp magnifying glass */
  .chat-header-right .msg-search-wrapper::before {
    content: '' !important;
    width: 16px !important;
    height: 16px !important;
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    pointer-events: none !important;
    z-index: 3 !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
  }

  .chat-header-right .msg-search-wrapper:hover::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300a884' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
  }

  /* Search input pill */
  .chat-header-right .msg-search-box {
    width: 190px !important;
    height: 36px !important;
    min-height: 36px !important;
    border-radius: 18px !important;
    padding: 0 14px 0 36px !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    border: 1px solid transparent !important;
    box-sizing: border-box !important;
    outline: none !important;
    cursor: text !important;
    transition: width 0.26s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.2s ease,
                background 0.2s ease,
                box-shadow 0.2s ease !important;
  }

  :root[data-theme="dark"] .chat-header-right .msg-search-box {
    background: #111b21 !important;
    border-color: rgba(134, 150, 160, 0.16) !important;
    color: #e9edef !important;
  }
  :root[data-theme="dark"] .chat-header-right .msg-search-box::placeholder {
    color: #8696a0 !important;
  }

  :root[data-theme="light"] .chat-header-right .msg-search-box {
    background: #ffffff !important;
    border-color: rgba(11, 20, 26, 0.12) !important;
    color: #111b21 !important;
  }
  :root[data-theme="light"] .chat-header-right .msg-search-box::placeholder {
    color: #667781 !important;
  }

  .chat-header-right .msg-search-box:hover {
    border-color: rgba(134, 150, 160, 0.35) !important;
  }

  .chat-header-right .msg-search-box:focus {
    width: 250px !important;
    border-color: #00a884 !important;
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.22) !important;
  }

  /* Right toggle / Info button */
  .chat-header-right #rightToggleBtn,
  .chat-header-right .collapse-circle-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 50% !important;
    display: flex;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-sub) !important;
    font-size: 16px !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }

  .chat-header-right #rightToggleBtn[style*="display: none"],
  .chat-header-right #rightToggleBtn[style*="display:none"] {
    display: none !important;
  }
  .chat-header-right #rightToggleBtn[style*="display: flex"],
  .chat-header-right #rightToggleBtn[style*="display:flex"] {
    display: flex !important;
  }

  :root[data-theme="dark"] .chat-header-right #rightToggleBtn {
    color: #aebac1 !important;
  }
  :root[data-theme="light"] .chat-header-right #rightToggleBtn {
    color: #54656f !important;
  }

  .chat-header-right #rightToggleBtn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-main) !important;
    transform: scale(1.06) !important;
  }
  :root[data-theme="light"] .chat-header-right #rightToggleBtn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
    color: #111b21 !important;
  }

  /* ============================================================
     3) WHATSAPP-STYLE BOTTOM-LEFT RAIL ICONS (SETTINGS & SYSTEM)
     ============================================================ */
  .sidebar-bottom {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
    padding-bottom: 8px !important;
    width: 100% !important;
    position: relative !important;
  }

  /* Respect dynamic admin visibility from app-core */
  .sidebar-bottom #adminPanelBtn[style*="display: none"],
  .sidebar-bottom #adminPanelBtn[style*="display:none"] {
    display: none !important;
  }
  .sidebar-bottom #adminPanelBtn[style*="display: flex"],
  .sidebar-bottom #adminPanelBtn[style*="display:flex"] {
    display: flex !important;
  }

  /* Unified circular button geometry */
  .sidebar-bottom #adminPanelBtn,
  .sidebar-bottom #settingsNavBtn,
  .sidebar-icon .sidebar-bottom .icon-btn,
  .sidebar-icon .sidebar-bottom .nav-icon {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    border-radius: 50% !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative !important;
    color: #8696a0 !important;
    transition: background 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.22s ease !important;
    box-shadow: none !important;
  }

  .sidebar-bottom #settingsNavBtn {
    display: flex !important;
  }

  :root[data-theme="dark"] .sidebar-bottom #adminPanelBtn,
  :root[data-theme="dark"] .sidebar-bottom #settingsNavBtn {
    color: #aebac1 !important;
  }
  :root[data-theme="light"] .sidebar-bottom #adminPanelBtn,
  :root[data-theme="light"] .sidebar-bottom #settingsNavBtn {
    color: #54656f !important;
  }

  /* Force pristine SVG stroke rendering (override V27 stroke:none!important) */
  .sidebar-bottom #adminPanelBtn svg,
  .sidebar-bottom #settingsNavBtn svg {
    width: 22px !important;
    height: 22px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    shape-rendering: geometricPrecision !important;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                stroke 0.2s ease !important;
  }

  /* Hover micro-interactions */
  .sidebar-bottom #adminPanelBtn:hover,
  .sidebar-bottom #settingsNavBtn:hover {
    background: rgba(255, 255, 255, 0.09) !important;
    color: #e9edef !important;
    transform: scale(1.08) !important;
  }

  :root[data-theme="light"] .sidebar-bottom #adminPanelBtn:hover,
  :root[data-theme="light"] .sidebar-bottom #settingsNavBtn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
    color: #111b21 !important;
  }

  /* WhatsApp settings gear smooth rotation on hover */
  .sidebar-bottom #settingsNavBtn:hover svg {
    transform: rotate(35deg) scale(1.05) !important;
  }

  /* System icon smooth pulse on hover */
  .sidebar-bottom #adminPanelBtn:hover svg {
    transform: scale(1.1) !important;
  }

  /* Tactile active / click feedback */
  .sidebar-bottom #adminPanelBtn:active,
  .sidebar-bottom #settingsNavBtn:active {
    transform: scale(0.92) !important;
    background: rgba(255, 255, 255, 0.14) !important;
  }

  /* Sleek WhatsApp floating tooltips */
  .sidebar-bottom #adminPanelBtn::after,
  .sidebar-bottom #settingsNavBtn::after {
    position: absolute !important;
    left: calc(100% + 12px) !important;
    top: 50% !important;
    transform: translateY(-50%) scale(0.92) !important;
    background: #111b21 !important;
    color: #e9edef !important;
    border: 1px solid rgba(134, 150, 160, 0.2) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    padding: 5px 10px !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    z-index: 1002 !important;
  }

  :root[data-theme="light"] .sidebar-bottom #adminPanelBtn::after,
  :root[data-theme="light"] .sidebar-bottom #settingsNavBtn::after {
    background: #ffffff !important;
    color: #111b21 !important;
    border-color: rgba(11, 20, 26, 0.15) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
  }

  .sidebar-bottom #adminPanelBtn::after {
    content: 'Hệ thống' !important;
  }

  .sidebar-bottom #settingsNavBtn::after {
    content: 'Cài đặt' !important;
  }

  .sidebar-bottom #adminPanelBtn:hover::after,
  .sidebar-bottom #settingsNavBtn:hover::after {
    opacity: 1 !important;
    transform: translateY(-50%) scale(1) !important;
  }

  /* Settings popup menu position polish */
  .settings-popup-menu {
    left: 68px !important;
    bottom: 8px !important;
    border-radius: 12px !important;
    border: 1px solid rgba(134, 150, 160, 0.2) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(12px) !important;
  }
}
