/* ==========================================================================
   ANYONE VINA HRMS - PWA & Mobile App Styles
   ========================================================================== */

/* Topbar Mobile Install & Push Buttons */
.pwa-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.pwa-topbar-btn:hover {
  background: rgba(14, 165, 233, 0.25);
  border-color: #38bdf8;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

.pwa-topbar-btn.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #34d399;
}

/* Floating Bottom Install Banner */
.mobile-install-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  width: calc(100% - 32px);
  max-width: 520px;
  background: linear-gradient(135deg, rgba(8, 27, 51, 0.96), rgba(15, 43, 72, 0.98));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.15);
  padding: 14px 16px;
  z-index: 99999;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

.mobile-install-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.install-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.install-banner-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  object-fit: contain;
}

.install-banner-info {
  flex: 1;
  min-width: 0;
}

.install-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-banner-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.3;
}

.install-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.install-banner-btn-primary {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

.install-banner-btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.install-banner-btn-close {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.install-banner-btn-close:hover {
  color: #f1f5f9;
}

/* iOS Safari & Mobile Install Guide / Push Notification Modal */
.ios-guide-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  z-index: 100050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  box-sizing: border-box;
}

.ios-guide-modal.open {
  opacity: 1;
  pointer-events: auto;
}

/* Khóa cuộn trang nền khi mở modal để không bị kẹt gesture cuộn trên mobile */
body.modal-open {
  overflow: hidden !important;
  touch-action: none;
}

.ios-guide-card {
  background: #081b33;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 20px;
  max-width: 480px;
  width: 100%;
  max-height: calc(100dvh - 24px);
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 24px rgba(56, 189, 248, 0.15);
  animation: iosCardPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

@keyframes iosCardPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.ios-guide-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  margin-bottom: 0;
}

.ios-guide-header img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}

.ios-guide-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.25;
}

.ios-guide-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin: 2px 0 0;
  line-height: 1.3;
}

.ios-guide-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
  margin-left: auto;
}

.ios-guide-close-btn:hover,
.ios-guide-close-btn:active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: scale(1.05);
}

.install-guide-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 18px 0;
  background: transparent;
  flex-shrink: 0;
  box-sizing: border-box;
}

.install-tab-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.install-tab-btn.active {
  background: #0866c6;
  color: #fff;
  box-shadow: 0 4px 12px rgba(8, 102, 198, 0.35);
}

.install-tab-btn:not(.active) {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.install-tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}

/* Thân modal: Cuộn mượt mà trên cảm ứng di động, độc lập không làm đơ trang */
.ios-guide-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 14px 18px;
  box-sizing: border-box;
}

.ios-guide-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.ios-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
}

.ios-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #0284c7;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.ios-step-text {
  font-size: 12.5px;
  color: #e2e8f0;
  line-height: 1.45;
}

.ios-step-icon {
  display: inline-flex;
  vertical-align: middle;
  color: #38bdf8;
  margin: 0 3px;
}

.ios-guide-footer {
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #081b33;
  flex-shrink: 0;
  box-sizing: border-box;
}

.ios-guide-btn-done {
  width: 100%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.ios-guide-btn-done:hover,
.ios-guide-btn-done:active {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Push Notification Test & Status Panel */
.push-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.push-status-chip.enabled {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.push-status-chip.disabled {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* iOS In-App Dynamic Push Banner (Island Style) */
.inapp-push-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  width: calc(100% - 24px);
  max-width: 440px;
  background: linear-gradient(135deg, rgba(8, 27, 51, 0.95), rgba(15, 43, 72, 0.97));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 24px rgba(56, 189, 248, 0.25);
  z-index: 100002;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
}

.inapp-push-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.inapp-push-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.inapp-push-app {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inapp-push-app img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.inapp-push-app-name {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.inapp-push-time {
  font-size: 11px;
  color: #94a3b8;
}

.inapp-push-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 2px;
}

.inapp-push-body {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.4;
}

/* iOS Specific Info Box in Push Modal */
.ios-notice-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.ios-notice-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fbbf24;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.ios-notice-body {
  font-size: 12px;
  color: #fde68a;
  line-height: 1.45;
  margin: 0;
}

/* ==========================================================================
   MOBILE TOPBAR & USER MENU OVERHAUL (CLEAN, LOGICAL, NO DUPLICATES)
   ========================================================================== */

/* 1. Thương hiệu & Tên công ty đáp ứng */
.company-brand-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  border-radius: 6px;
  letter-spacing: 0.5px;
  margin-right: 6px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.company-name-full {
  display: inline;
}

.company-name-short {
  display: none;
}

/* 2. Banner Cài Đặt Thông Báo Đẩy trong Dropdown Thông Báo */
.notification-push-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #f0f7ff, #e0effe);
  border-bottom: 1px solid #bfdbfe;
  font-size: 12px;
  color: #1e40af;
}

.notification-push-banner .npb-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  line-height: 1.35;
}

.notification-push-banner .npb-icon {
  width: 17px;
  height: 17px;
  color: #0284c7;
  flex-shrink: 0;
}

.notification-push-banner .npb-action {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.notification-push-banner .npb-action:hover {
  background: #0369a1;
  transform: translateY(-1px);
}

.notification-close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.notification-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* 3. Lớp nền mờ cho Popup/Dropdown Mobile */
.mobile-dropdown-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-dropdown-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* 4. Menu Tài Khoản & Tiện Ích Di Động (User Profile Sheet) */
.user-profile-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.25);
  z-index: 100000;
  padding: 18px 20px 28px;
  max-width: 480px;
  margin: 0 auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-profile-menu.open {
  transform: translateY(0);
}

.upm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}

.upm-avatar-wrap .upm-avatar {
  width: 46px !important;
  height: 46px !important;
  font-size: 16px !important;
  background: linear-gradient(135deg, #0284c7, #2563eb) !important;
  color: #ffffff !important;
}

.upm-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.upm-user-info strong {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.upm-user-info small {
  font-size: 12.5px;
  color: #64748b;
  margin-top: 2px;
}

.upm-close-btn {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.upm-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.upm-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 14px;
}

.upm-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #1e293b;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.upm-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.upm-item.danger {
  color: #dc2626;
  background: #fef2f2;
}

.upm-item.danger:hover {
  background: #fee2e2;
  border-color: #fecaca;
}

.upm-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #e2e8f0;
  color: #334155;
  flex-shrink: 0;
}

.upm-item-icon.push-icon { background: #eff6ff; color: #2563eb; }
.upm-item-icon.install-icon { background: #f0fdf4; color: #16a34a; }
.upm-item-icon.sync-icon { background: #f5f3ff; color: #7c3aed; }
.upm-item-icon.key-icon { background: #fefce8; color: #ca8a04; }
.upm-item-icon.logout-icon { background: #fee2e2; color: #dc2626; }

.upm-item-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.upm-item-copy span {
  font-size: 13.5px;
  font-weight: 600;
  color: inherit;
}

.upm-item-copy small {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 2px;
}

.upm-arrow {
  width: 16px;
  height: 16px;
  color: #94a3b8;
}

/* ==========================================================================
   RESPONSIVE OVERRIDES CHO DI ĐỘNG (SCREEN <= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* Khắc phục lỗi topbar cắt xén popup */
  .topbar {
    overflow: visible !important;
    padding: 0 12px !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
  }

  /* Đổi tên công ty ngắn gọn không bị tràn */
  #topbarCompany span.company-name-full,
  .company span.company-name-full {
    display: none !important;
  }

  #topbarCompany span.company-name-short,
  .company span.company-name-short {
    display: inline-block !important;
    font-size: 15px !important;
    font-weight: 800 !important;
    color: #082d61 !important;
    letter-spacing: -0.2px !important;
    white-space: nowrap !important;
  }

  /* Ẩn các nút desktop dàn hàng ngang thừa thãi trên topbar di động */
  body.admin-session #syncDataHrButton,
  body[data-role="admin"] #syncDataHrButton,
  body #syncDataHrButton,
  #syncDataHrButton,
  .topbar-actions #syncDataHrButton,
  .desktop-only-action,
  .desktop-only-btn {
    display: none !important;
  }

  .topbar-actions {
    gap: 8px !important;
  }

  /* Định vị Notification Dropdown căn giữa màn hình di động, không bị lệch */
  .notification-dropdown {
    position: fixed !important;
    top: 60px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100vh - 120px) !important;
    z-index: 100000 !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35) !important;
  }

  .session-user {
    cursor: pointer !important;
    padding: 2px !important;
    border-radius: 50% !important;
    transition: transform 0.15s ease !important;
  }

  .session-user:active {
    transform: scale(0.92) !important;
  }
}

/* Định vị menu hồ sơ thành popup thả xuống góc trên bên phải trên desktop */
@media (min-width: 769px) {
  .user-profile-menu {
    position: fixed !important;
    top: 64px !important;
    right: 20px !important;
    bottom: auto !important;
    left: auto !important;
    width: 320px !important;
    max-width: 320px !important;
    border-radius: 14px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.22) !important;
    transform: translateY(-8px) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .user-profile-menu.open {
    transform: translateY(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

/* Giao diện nút Avatar thu nhỏ (chỉ hiển thị icon tròn cho cả admin và nhân viên) */
.session-user.session-user-icon-only {
  cursor: pointer !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  background: transparent !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  box-sizing: border-box !important;
  transition: transform 0.15s ease, filter 0.15s ease !important;
}

.session-user.session-user-icon-only:hover {
  transform: scale(1.08) !important;
  filter: brightness(1.08) !important;
}

.session-user.session-user-icon-only:active {
  transform: scale(0.92) !important;
}

.session-user.session-user-icon-only .session-copy {
  display: none !important;
}

.session-user.session-user-icon-only .session-avatar {
  width: 38px !important;
  height: 38px !important;
  border-radius: 50% !important;
  box-shadow: 0 2px 8px rgba(8, 102, 198, 0.25) !important;
  border: 2px solid #ffffff !important;
  outline: 1.5px solid #c9def5 !important;
  display: grid !important;
  place-items: center !important;
  font-weight: 800 !important;
  font-size: 13.5px !important;
  background: #0866c6 !important;
  color: #ffffff !important;
  user-select: none !important;
}
