/* ==========================================================================
   SCORE.ROBOTMAKER - SHARED STYLESHEET (W3C COMPLIANT)
   ========================================================================== */

/* Universal Smooth Transitions for Theme & Color shifts */
*, *::before, *::after {
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease;
}

/* Tabular figures for numbers so scores and timers align perfectly */
.font-tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Dialog safeguard: closed dialogs must always be hidden regardless of any utility class */
dialog:not([open]) {
  display: none !important;
}

/* Universal Viewport & Overflow Protection for Mobile */
html, body {
  overflow-x: clip;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

/* Tournament Corner Ribbon Badge */
.ribbon-wrapper {
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  overflow: hidden;
  pointer-events: none;
  z-index: 30;
}

@media (max-width: 767px) {
  /* Hide corner ribbon on mobile to avoid overflow and blocking UI */
  .ribbon-wrapper {
    display: none !important;
  }
}

.ribbon-banner {
  position: absolute;
  top: 22px;
  right: -36px;
  width: 160px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
  color: #ffffff;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}

/* Touch-optimized Signature Canvas */
.signature-canvas {
  touch-action: none;
  cursor: crosshair;
}

/* Modern Minimalist Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}

.dark ::-webkit-scrollbar-thumb {
  background: #334155;
}

/* Subtle Active Pulse Animation */
@keyframes soft-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.animate-soft-pulse {
  animation: soft-pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Font Awesome Icon Alignment Helper */
i[class*="fa-"]:not(.hidden) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
}

/* Ensure hidden elements and theme toggle icons are strictly hidden */
.hidden,
[hidden],
html:not(.dark) .theme-icon-sun,
html.dark .theme-icon-moon {
  display: none !important;
}

html.dark .theme-icon-sun {
  display: inline-flex !important;
}

html:not(.dark) .theme-icon-moon {
  display: inline-flex !important;
}

/* ==========================================================================
   ANTI-DROP-WORD (TRÁNH RỚT CHỮ) & MOBILE OPTIMIZATIONS
   ========================================================================== */

/* Universal no-wrap helpers */
.whitespace-nowrap,
.nowrap,
.btn-nowrap,
.badge-nowrap,
th,
.badge {
  white-space: nowrap;
}

/* Table cells: Badges, Sân đấu, Bảng thi, Lượt, Khung giờ, Rank, Điểm số */
table th {
  white-space: nowrap !important;
}

table td span[class*="rounded"],
table td span[class*="badge"],
table td .badge,
table td .font-tabular,
table td .font-mono {
  white-space: nowrap !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Prevent action buttons from breaking into separate lines awkwardly */
button,
a[class*="px-"][class*="rounded"] {
  letter-spacing: 0.01em;
}

/* Ensure smooth horizontal scroll on touch screens */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Mobile responsive inputs and touch ergonomics */
@media (max-width: 640px) {
  input:not(#directScoreInput):not(#noTaskScoreInput), select, textarea {
    font-size: 14px !important;
  }
}

/* Responsive native dialogs */
dialog {
  margin: auto !important;
  max-width: calc(100vw - 2rem) !important;
  max-height: calc(100vh - 2rem) !important;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Prevent text dropping inside buttons, badges and interactive chips */
button,
a[class*="rounded"],
span[class*="rounded"],
.badge {
  word-break: keep-all;
}

/* Mobile responsive constraints */
@media (max-width: 767px) {
  select, input {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Fixed Bottom Navigation Menu */
body.has-bottom-nav,
.has-bottom-nav {
  padding-bottom: 76px !important;
}

@media (min-width: 640px) {
  body.has-bottom-nav,
  .has-bottom-nav {
    padding-bottom: 84px !important;
  }
}

.bottom-nav-bar {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap !important;
  min-width: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  position: relative;
}

.bottom-nav-item span {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}

@media (max-width: 390px) {
  .bottom-nav-item {
    font-size: 10.5px;
    padding: 5px 2px;
  }
}

.bottom-nav-item i {
  font-size: 17px;
  margin-bottom: 3px;
  transition: transform 0.2s ease;
}

.bottom-nav-item:hover i {
  transform: translateY(-2px);
}

.bottom-nav-item.active {
  background-color: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.dark .bottom-nav-item.active {
  background-color: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

/* Laptop Responsive Optimizations (1024px - 1440px) */
@media (min-width: 1024px) and (max-width: 1440px) {
  .laptop-grid-5 {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
  }
  .laptop-select {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Prevent background scrolling when dialog modal is open ("chặn lướt nội dung phía sau") */
html.modal-open,
body.modal-open {
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

/* Dialog Backdrop with deep blur effect ("phía sau mờ") */
dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.8) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
}

#finishProofModal {
  max-width: 28rem !important;
  width: 95% !important;
  margin: auto !important;
  border: none !important;
  background: transparent !important;
  outline: none !important;
  overscroll-behavior: contain !important;
}

#finishProofModal > div {
  overscroll-behavior: contain !important;
}

#finishProofModal .overflow-y-auto {
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch;
}

#finishProofModal::backdrop {
  background-color: rgba(2, 6, 23, 0.85) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

/* ==========================================================================
   PRINT OPTIMIZATION FOR ACCREDITATION BADGE (THẺ ĐEO THI ĐẤU)
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #0f172a !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 12pt;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  header, footer, nav, #fixedBottomNav, .no-print, .theme-toggle-btn, .lang-toggle-btn {
    display: none !important;
  }

  main {
    padding: 0 !important;
    margin: 0 auto !important;
    max-width: 100% !important;
  }

  #printableBadge {
    box-shadow: none !important;
    border: 2px solid #7c3aed !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin: 20px auto !important;
    max-width: 440px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* ==========================================================================
   HORIZONTAL SWIPE / CHIPS CONTAINER WITHOUT SCROLLBAR
   ========================================================================== */
.no-scrollbar::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
.no-scrollbar {
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
  -webkit-overflow-scrolling: touch;
}

/* Mobile Sidebar Off-Canvas Guarantee */
.-translate-x-full {
  transform: translateX(-100%) !important;
}
.translate-x-0 {
  transform: translateX(0) !important;
}
