/* ============================================================
   SSO Button & User Bar — DOAE Risk Map
   พอร์ตจาก GEOPLOTS login.css ปรับ palette ให้เข้าธีม Risk Map
   ดีไซน์: docs/SSO_LOGIN_AND_CROSS_SYSTEM_LINKS_DESIGN.md §4.3.5
   ============================================================ */

/* ปุ่ม SSO หลัก (login modal + landing) */
.sso-btn {
  width: 100%;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  font-family: 'Sarabun', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #1a6349 0%, #0d3b2c 100%);
  border: 0;
  border-radius: 14px;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 6px 14px -4px rgba(13, 59, 44, .5);
  cursor: pointer;
  transition: filter .18s ease, transform .1s ease;
}
.sso-btn:hover { filter: brightness(1.08); color: #fff; transform: translateY(-1px); }
.sso-btn:active { filter: brightness(.97); transform: translateY(1px); }
.sso-btn__icon { width: 24px; height: 24px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }

/* แถบสถานะผู้ใช้บน landing — อยู่ใน layout flow เป็นแถวบนสุด (ชิดขวา) ไม่ใช่ absolute ลอยทับการ์ด
   → ปุ่มเข้าสู่ระบบ/ออกจากระบบ ไม่มีทางซ้อนปุ่มดาวน์โหลดคู่มือของการ์ดในทุกขนาดจอ */
.user-bar { display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  width: 100%; flex-shrink: 0; margin-bottom: 4px; z-index: 20; }
.user-bar .sso-btn { width: auto; padding: 0 20px; height: 40px; font-size: .85rem; }
/* ปุ่มดาวน์โหลดคู่มือและปุ่มแผนผังเว็บไซต์ในแถบบน — flex item จริงในแถวเดียวกับปุ่มเข้าสู่ระบบ (ไม่ใช้ absolute → ไม่มีทับกัน) */
.manual-btn-top, .sitemap-btn-top { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; color: #e2e8f0; text-decoration: none;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .35);
  backdrop-filter: blur(12px); transition: all .2s ease; cursor: pointer; }
.manual-btn-top:hover, .sitemap-btn-top:hover { background: rgba(255, 255, 255, .16); color: #fff; transform: translateY(-1px); }
/* ============================================================
   GEOPLOTS-style User & Level Pills
   ============================================================ */
.navbar-tool-item {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* ============================================================
   Visitor Counter Pills (Top-Right Counters)
   ============================================================ */

/* 1. Landing Page Counter (Dark Glassmorphism Theme) */
.visitor-counter-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.visitor-counter-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
}
.visitor-counter-pill .visitor-label {
  color: #cbd5e1;
  font-size: 0.82rem;
}
.visitor-counter-pill .visitor-count {
  font-size: 0.95rem;
  font-weight: 700;
  color: #34d399; /* Emerald Green */
  font-family: 'Sarabun', -apple-system, sans-serif;
  letter-spacing: 0.3px;
}

/* 2. Hazard / Disaster Pages Counter (Light Header Pill) */
.page-visitor-pill {
  background: #ffffff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
  line-height: 1.2;
}
.page-visitor-pill:hover {
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.page-visitor-pill i {
  color: #10b981;
  font-size: 13px;
}
.page-visitor-pill .visitor-label {
  font-weight: 500;
  color: #64748b;
  font-size: 12px;
}
.page-visitor-pill .visitor-count {
  font-weight: 700;
  color: #0f172a;
  font-family: 'Sarabun', -apple-system, sans-serif;
  letter-spacing: 0.2px;
}

/* User Badge Pill (GEOPLOTS Style) */
.user-pill-container {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(25, 118, 210, 0.32);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 0.84rem;
  color: #0d47a1;
  font-weight: 600;
  white-space: nowrap;
  max-width: 240px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
}

.user-pill-container:hover {
  background: #f8fafc;
  border-color: rgba(25, 118, 210, 0.55);
}

.user-pill-container .user-icon {
  font-size: 0.95rem;
  color: #1976d2;
  margin-right: 6px;
}

.user-pill-container .user-dp-input {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
  line-height: 1.3;
}

/* User Level Badge Pill (GEOPLOTS Style) */
.user-level-pill-container {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 0.84rem;
  color: #4338ca;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
}

.user-level-pill-container:hover {
  background: #f8fafc;
  border-color: rgba(99, 102, 241, 0.6);
}

/* ป้ายระดับสิทธิ์แบบคลิกได้ (เช่น เปิดโมดัลจำลองสิทธิ์แบบ GEOPLOTS) */
.user-level-pill-container--clickable {
  cursor: pointer;
  user-select: none;
}

.user-level-pill-container--clickable:hover {
  background: #eef2ff;
  border-color: rgba(99, 102, 241, 0.75);
  transform: translateY(-1px);
}

.user-level-pill-container--clickable:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.45);
  outline-offset: 2px;
}

.user-level-chevron {
  font-size: 0.62rem;
  opacity: 0.7;
}

/* ระหว่างจำลองสิทธิ์: ป้ายเป็นสีส้มและยังคลิกได้ (เปิดโมดัลเพื่อคืนค่า/เปลี่ยนระดับ) */
.user-level-pill-container--simulating {
  background: linear-gradient(135deg, #b45309, #d97706) !important;
  border-color: #b45309 !important;
  color: #ffffff !important;
}

.user-level-pill-container--simulating .level-icon,
.user-level-pill-container--simulating .user-level-input,
.user-level-pill-container--simulating .user-level-chevron {
  color: #ffffff !important;
}

.user-level-pill-container .level-icon {
  font-size: 0.9rem;
  color: #4f46e5;
  margin-right: 6px;
}

.user-level-pill-container .user-level-prefix {
  font-weight: 500;
  color: #4338ca;
  opacity: 0.85;
  margin-right: 5px;
}

.user-level-pill-container .user-level-input {
  display: inline-block;
  font-weight: 700;
  line-height: 1.3;
}

/* Logout Button */
.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #c1121f;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(193, 18, 31, 0.3);
  transition: all 0.2s ease;
}

.btn-logout:hover {
  color: #fff;
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* ปุ่มออกจากระบบแบบไอคอนอย่างเดียว (landing) — คงรูปทรงกลมและแตะง่าย */
.btn-logout--icon {
  padding: 0;
  width: 34px;
  height: 34px;
  justify-content: center;
  border-radius: 50%;
}

.btn-logout--icon i {
  font-size: 0.95rem;
  line-height: 1;
}

@media (max-width: 575.98px) {
  .btn-logout--icon {
    width: 30px;
    height: 30px;
  }
}

/* ส่วน "ระบบที่เกี่ยวข้อง" บน landing — แถบ chip กระชับ 1 แถว ให้พอดี 1 จอ (ไม่ต้องเลื่อน) */
.external-section { margin: 0 0 6px; width: 100%; max-width: 1400px; padding: 0 20px; }
.external-strip { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.external-label { color: #94a3b8; font-size: .78rem; margin-right: 2px; }
.external-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.external-chip, .external-chip:visited { 
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(12px);
  color: #e2e8f0; font-size: .8rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: all .2s ease; 
}
.external-chip:hover, .external-chip:focus, .external-chip:active { 
  background: rgba(255, 255, 255, .16); color: #fff; transform: translateY(-1px); text-decoration: none; 
}
.external-chip__icon { font-size: .95rem; }

@media (max-width: 768px) {
    .user-bar { 
        gap: 6px; 
        margin-bottom: 8px; 
        justify-content: flex-end; 
        flex-wrap: wrap; 
        width: 100%;
    }
    .user-bar .sso-btn { 
        height: 38px; 
        padding: 0 14px; 
        font-size: .8rem; 
        border-radius: 12px; 
        gap: .45rem; 
    }
    .user-bar .sso-btn__icon { 
        width: 20px; 
        height: 20px; 
    }
    .manual-btn-top, .sitemap-btn-top { 
        width: 38px; 
        height: 38px; 
    }
    .manual-btn-top svg, .sitemap-btn-top svg { 
        width: 16px; 
        height: 16px; 
    }
    .visitor-counter-pill {
        height: 36px;
        padding: 0 12px;
        font-size: 0.78rem;
        gap: 5px;
    }
    .visitor-counter-pill .visitor-label { font-size: 0.74rem; }
    .visitor-counter-pill .visitor-count { font-size: 0.85rem; }

    .page-visitor-pill {
        padding: 4px 10px;
        font-size: 12px;
        gap: 5px;
    }
    .page-visitor-pill .visitor-label { font-size: 11px; }
    .page-visitor-pill .visitor-count { font-size: 12px; }
    .user-pill-container { max-width: 140px; font-size: .74rem; padding: 4px 8px; }
    .user-level-pill-container { font-size: .74rem; padding: 4px 8px; }
    .btn-logout { font-size: .72rem; padding: 5px 10px; }

    .external-section { 
        margin: 6px 0 20px; 
        padding: 0 4px; 
    }
    .external-strip { 
        flex-direction: column; 
        align-items: center; 
        gap: 8px; 
    }
    .external-label { 
        display: block; 
        font-size: 0.78rem; 
        font-weight: 600; 
        color: #94a3b8; 
        text-align: center; 
    }
    .external-chip { 
        font-size: .75rem; 
        padding: 6px 13px; 
        gap: 5px; 
    }
}

/* แถบผู้ใช้และลิงก์ภายนอกสำหรับสมาร์ทโฟนแนวนอน */
@media (orientation: landscape) and (max-height: 550px) {
    .user-bar { 
        gap: 6px; 
        margin-bottom: 4px; 
        justify-content: flex-end; 
        flex-wrap: wrap; 
        width: 100%;
    }
    .user-bar .sso-btn { 
        height: 34px; 
        padding: 0 12px; 
        font-size: .78rem; 
        border-radius: 10px; 
        gap: .4rem; 
    }
    .user-bar .sso-btn__icon { 
        width: 18px; 
        height: 18px; 
    }
    .manual-btn-top, .sitemap-btn-top { 
        width: 34px; 
        height: 34px; 
    }
    .manual-btn-top svg, .sitemap-btn-top svg { 
        width: 15px; 
        height: 15px; 
    }
    .user-pill-container { max-width: 140px; font-size: .72rem; padding: 3px 8px; }
    .user-level-pill-container { font-size: .72rem; padding: 3px 8px; }
    .btn-logout { font-size: .7rem; padding: 4px 9px; }

    .external-section { 
        margin: 4px 0 16px; 
        padding: 0 8px; 
    }
    .external-strip { 
        flex-direction: row; 
        align-items: center; 
        justify-content: center;
        gap: 10px; 
        flex-wrap: wrap;
    }
    .external-label { 
        display: inline-block; 
        font-size: 0.76rem; 
        font-weight: 600; 
        color: #94a3b8; 
        text-align: center; 
    }
    .external-chip { 
        font-size: .72rem; 
        padding: 5px 12px; 
        gap: 4px; 
    }
}

/* ปุ่ม SSO ย่อสำหรับแถบเมนูหน้าย่อย (.hazard-menu) */
.hazard-menu { flex-wrap: wrap; row-gap: 8px; } /* กันเมนูล้นแนวนอนเมื่อเพิ่ม item SSO + ระบบภายนอก — item ที่ไม่พอจะขึ้นบรรทัดใหม่แทนที่จะทับส่วนอื่น */
.sso-mini-btn { background: #0d3b2c; color: #fff; padding: 6px 14px; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: .8rem; white-space: nowrap; }
.sso-mini-btn:hover { color: #fff; filter: brightness(1.15); }
.sso-mini-btn--logout { background: #c1121f; }

/* ปุ่มไอคอนอย่างเดียว (เช่น ออกจากระบบ) — ให้เหมือนปุ่มบนหน้า landing */
.sso-mini-btn--icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}
.sso-mini-btn--icon svg { width: 14px; height: 14px; }
.hazard-item.sso-item { display: flex; align-items: center; gap: 8px; cursor: default; }
.sso-user-chip { background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .78rem; color: #1b4332; white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* ── 🆕 Dropdown "🔗 ระบบอื่นๆ" ใน .hazard-menu หน้าย่อย (v1.1) ────────────────
   ปุ่มเดียวเปิดรายการระบบภายนอกทั้งหมดจาก external_services.js (authUrl = ประตู SSO ของระบบนั้น)
   ตำแหน่งเป็น position:fixed — คำนวณใน toggleExtServicesMenu (glob_func.js) ตอนเปิด
   → ไม่โดน overflow-x:auto ของ .hazard-menu บนมือถือตัดขอบ */
.ext-dropdown-wrap { position: relative; }
.ext-trigger { cursor: pointer; user-select: none; }
.ext-trigger:hover { filter: brightness(1.08); }
/* badge ✓ บนปุ่ม — แสดงเมื่อมี session (SSO/EC) = คลิกผ่านเข้าระบบอื่นได้ทันที (ซ่อนไว้ก่อน รอ initSsoMenuItem เปิด) */
.ext-sso-badge { display: none; align-items: center; justify-content: center; margin-left: 5px;
  width: 15px; height: 15px; border-radius: 50%; background: #2d6a4f; color: #fff;
  font-size: .58rem; font-weight: 800; line-height: 1; vertical-align: middle; }
.ext-dropdown { display: none; position: fixed; z-index: 9999; width: 300px; max-width: calc(100vw - 16px);
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 8px;
  box-shadow: 0 18px 44px rgba(2, 12, 8, .22); font-family: 'Sarabun', sans-serif; }
.ext-dropdown.open { display: block; }
.ext-dropdown__head { font-size: .72rem; font-weight: 700; color: #64748b;
  padding: 6px 10px 8px; border-bottom: 1px solid #f1f5f9; margin-bottom: 6px; }
.ext-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  text-decoration: none; color: #1f2937; transition: background .15s ease; }
.ext-link:hover { background: #f0fdf4; color: #14543f; }
.ext-link__icon { font-size: 1.25rem; flex-shrink: 0; }
.ext-link__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ext-link__name { font-weight: 700; font-size: .84rem; line-height: 1.3; }
.ext-link__desc { font-size: .7rem; color: #64748b; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext-link__arrow { color: #94a3b8; font-size: .8rem; flex-shrink: 0; }