/**
 * @license
 * SPDX-License-Identifier: Apache-2.0
 * 
 * WINFAST LUCKY DRAW - CENTRAL STYLING THEME SHEET (cPanel-ready)
 * Implements strict brand guidelines: Deep Teal, Vibrant Orange, Off-White body, Inter font.
 */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap");

:root {
  --winfast-primary: #0b7a7e;
  --winfast-primary-dark: #06585b;
  --winfast-secondary: #f97316;
  --winfast-secondary-dark: #ea580c;
  --winfast-bg: #fafafa;
  --winfast-card: #ffffff;
  --winfast-text: #1e293b;
  --winfast-text-muted: #64748b;
  --winfast-border: #e2e8f0;
  --winfast-shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.05);
  --winfast-shadow:
    0 4px 12px -2px rgba(15, 23, 42, 0.04),
    0 2px 6px -1px rgba(15, 23, 42, 0.02);
  --winfast-shadow-lg:
    0 12px 24px -4px rgba(15, 23, 42, 0.06),
    0 4px 12px -2px rgba(15, 23, 42, 0.03);
  --winfast-radius-sm: 8px;
  --winfast-radius: 20px; /* Rebuilt to exactly 20px per rules */
  --winfast-radius-lg: 24px;
}

/* Base resets & typography */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--winfast-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Chamber Physics Style Elements */
.keno-chamber-sphere {
  user-select: none;
}
.bouncy-ball {
  position: absolute;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 900;
  font-size: 9px;
  font-family: var(--font-mono, monospace);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow:
    inset -3px -3px 6px rgba(0, 0, 0, 0.4),
    inset 3px 3px 6px rgba(255, 255, 255, 0.3),
    1px 2px 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.05s linear;
}
@keyframes pulseGlow {
  0% {
    transform: scale(0.85);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 10px #22c55e;
  }
  100% {
    transform: scale(0.85);
    opacity: 0.6;
  }
}

/* CORE CHAMBER GRAPHICS */
.pulse-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulseGlow 1.5s infinite;
}

.keno-chamber {
  width: 250px;
  height: 250px;
  background: rgba(255, 255, 255, 0.04);
  border: 6px solid rgba(11, 122, 126, 0.5);
  border-radius: 50%;
  box-shadow:
    inset 0 0 35px rgba(255, 255, 255, 0.1),
    0 0 25px rgba(11, 122, 126, 0.2),
    inset 0 15px 30px rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
}

.keno-tube {
  width: 44px;
  height: 70px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  border-right: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
  margin-top: -3px;
  position: relative;
  display: flex;
  justify-content: center;
  border-radius: 0 0 8px 8px;
}

.keno-light {
  position: absolute;
  bottom: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #475569;
  box-shadow: 0 0 5px #475569;
  transition: all 0.3s;
}

/* CELEBRATION CARDS */
@keyframes conf {
  0% {
    transform: translateY(-50px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .live-draw-grid {
    grid-template-columns: 1fr !important;
  }
}
@media (max-width: 960px) {
  .live-draw-grid-wrapper {
    grid-template-columns: 1fr !important;
  }
}

/* PWA Installation Overlay Button */
@keyframes winfastBounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}
@keyframes winfastPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(11, 122, 126, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(11, 122, 126, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(11, 122, 126, 0);
  }
}
.winfast-pwa-install-btn-container {
  position: fixed;
  bottom: 85px; /* Shifted upward to float cleanly above the mobile bottom navigation bar */
  right: 18px;
  z-index: 10000;
  display: none; /* Hidden by default - programmatically shown only when direct installation is fully supported */
  animation:
    winfastBounce 6s infinite,
    winfastPulse 3s infinite;
}
.winfast-pwa-install-btn {
  background-color: var(--winfast-primary);
  color: #ffffff;
  font-family: var(--font-sans, sans-serif);
  width: 44px; /* Small, touch-target friendly circular layout */
  height: 44px;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--winfast-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}
.winfast-pwa-install-btn:hover {
  background-color: var(--winfast-primary-dark);
  transform: scale(1.05);
}
.winfast-pwa-installed-status {
  position: fixed;
  bottom: 85px; /* Shifted upward to match the install button position */
  right: 18px;
  z-index: 10000;
  background-color: #e2e8f0;
  color: #475569;
  font-family: var(--font-sans, sans-serif);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  display: none; /* Hide by default and show when installed */
  align-items: center;
  gap: 6px;
  opacity: 0.85;
}

/* Base Form Control resets */
input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 100%;
  margin: 0;
}

/* Card Elements */
.winfast-card {
  background: var(--winfast-card);
  border: 1px solid rgba(15, 23, 42, 0.04);
  border-radius: var(--winfast-radius);
  box-shadow: var(--winfast-shadow);
  padding: clamp(14px, 4vw, 20px); /* Exact 16-20px based on critical rules */
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.winfast-card:hover {
  box-shadow: var(--winfast-shadow-lg);
}

/* Button UI with Large Touch Targets */
.winfast-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--winfast-radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  text-align: center;
  min-height: 48px; /* Safe mobile touch target height */
  outline: none;
  box-sizing: border-box;
}
.winfast-btn-primary {
  background-color: var(--winfast-primary);
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(11, 122, 126, 0.15);
}
.winfast-btn-primary:hover {
  background-color: var(--winfast-primary-dark);
}
.winfast-btn-secondary {
  background-color: var(--winfast-secondary);
  color: #ffffff !important;
  box-shadow: 0 4px 10px rgba(249, 115, 22, 0.15);
}
.winfast-btn-secondary:hover {
  background-color: var(--winfast-secondary-dark);
}
.winfast-btn-muted {
  background-color: #f1f5f9;
  color: var(--winfast-text);
  border: 1px solid #e2e8f0;
}
.winfast-btn-muted:hover {
  background-color: #e2e8f0;
}

/* Navigation & Status Indicators */
.winfast-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  border-radius: 9999px;
  text-transform: uppercase;
}
.winfast-badge-pending {
  background-color: #fef3c7;
  color: #d97706;
}
.winfast-badge-approved {
  background-color: #d1fae5;
  color: #059669;
}
.winfast-badge-rejected {
  background-color: #fee2e2;
  color: #dc2626;
}
.winfast-badge-soldout {
  background-color: #f3f4f6;
  color: #4b5563;
}
.winfast-badge-drawing {
  background-color: #dbeafe;
  color: #2563eb;
}

/* Form Controls with Clear Highlighting */
.winfast-form-group {
  margin-bottom: 20px;
}
.winfast-form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--winfast-text);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.winfast-form-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  font-size: 14px;
  color: var(--winfast-text);
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--winfast-radius-sm);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  min-height: 48px;
}
.winfast-form-input:focus {
  border-color: var(--winfast-primary);
  box-shadow: 0 0 0 3px rgba(11, 122, 126, 0.1);
  outline: none;
}

/* Grid & Layout Helpers (Bootstrap 5 Grid-Safe Alignments) */
.winfast-container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
}
.winfast-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) {
  .winfast-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .winfast-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .winfast-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  .md-grid-cols-3 {
    grid-template-columns: 2fr 1fr !important;
  }
  .md-grid-1-6 {
    grid-template-columns: 1fr 1.6fr !important;
  }
  .md-grid-1-2 {
    grid-template-columns: 1fr 2fr !important;
  }
  .md-grid-1-5-1 {
    grid-template-columns: 1.5fr 1fr !important;
  }
}

/* NUMBER GRID SYSTEM REBUILD style rules */
.lottery-grid-container,
.lottery-grid-container-keno {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
  margin: 15px 0;
  box-sizing: border-box;
}

@media (min-width: 360px) {
  .lottery-grid-container {
    grid-template-columns: repeat(6, 1fr);
  }
}
@media (min-width: 480px) {
  .lottery-grid-container {
    grid-template-columns: repeat(8, 1fr);
  }
}
@media (min-width: 768px) {
  .lottery-grid-container,
  .lottery-grid-container-keno {
    grid-template-columns: repeat(10, 1fr);
  }
}

/* Number Tile States style rules */
.number-tile {
  aspect-ratio: 1; /* Make tiles square naturally */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: auto;
  min-height: 40px;
  font-size: clamp(11px, 3.5vw, 16px);
  font-weight: 800;
  border-radius: clamp(4px, 1.5vw, 12px);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 2px solid #e2e8f0;
  background: #ffffff;
  color: #1e293b;
  box-sizing: border-box;
}

/* State: Available */
.number-tile.available {
  background: #ffffff;
  color: #1e293b;
  border-color: #e2e8f0;
}
.number-tile.available:hover {
  border-color: var(--winfast-primary);
  background: rgba(11, 122, 126, 0.05);
}

/* State: Selected (by user) */
.number-tile.selected {
  background: var(--winfast-secondary);
  color: #ffffff !important;
  border-color: var(--winfast-secondary-dark);
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.35);
  transform: scale(1.05);
}

/* State: Sold */
.number-tile.sold {
  background: #f1f5f9;
  color: #94a3b8 !important;
  border-color: #e2e8f0;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.65;
}

/* State: Winning */
.number-tile.winning {
  background: var(--winfast-primary);
  color: #ffffff !important;
  border-color: var(--winfast-primary-dark);
  animation: winningPulse 1.5s infinite alternate;
  font-size: 16px;
  font-weight: 900;
}

/* State: Reserved / Blocked */
.number-tile.reserved {
  background: #fff7ed;
  color: #c2410c !important;
  border-color: #fdba74;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.8;
}

/* State: Purchased by me (Mine) */
.number-tile.mine {
  background: #10B981;
  color: #FFFFFF !important;
  border-color: #059669;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
  font-weight: 800;
  cursor: default;
}

@keyframes winningPulse {
  from {
    box-shadow:
      0 0 4px var(--winfast-primary),
      inset 0 0 2px rgba(255, 255, 255, 0.2);
  }
  to {
    box-shadow:
      0 0 16px rgba(11, 122, 126, 0.65),
      inset 0 0 4px rgba(255, 255, 255, 0.4);
    transform: scale(1.03);
  }
}

/* FIXED MOBILE BOTTOM NAVIGATION STYLE RULES */
.bottom-nav-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  background-color: #ffffff;
  border-top: 1px solid #e2e8f0;
  z-index: 9999; /* Ensure visible above pages */
  display: flex !important;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px)) 0; /* Exact Safe area support */
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

@media (min-width: 769px) {
  .bottom-nav-fixed {
    display: none !important; /* Hide on wider screen layout */
  }
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #64748b;
  font-weight: 700;
  font-size: 10px;
  padding: 4px 0;
  flex: 1;
  min-height: 48px; /* Large touch target for perfect mobile UX */
  transition: all 0.15s ease;
}

.bottom-nav-btn.active {
  color: var(--winfast-primary);
}

.bottom-nav-icon {
  font-size: 20px;
  margin-bottom: 2px;
  display: block;
}

/* Prevent double margins on container root */
html,
body {
  box-sizing: border-box;
}

div[style*="max-width: 1200px"] {
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  box-sizing: border-box !important;
}

/* General table design override rules for mobile spacing responsiveness */
.winfast-responsive-table {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 15px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.winfast-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.winfast-table th,
.winfast-table td {
  padding: 12px 14px;
}

/* Mobile responsive layout overrides: clean stacking */
@media (max-width: 600px) {
  .mobile-flex-col {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .mobile-w-full {
    width: 100% !important;
  }
  .winfast-card {
    border-radius: 16px;
    padding: 16px; /* Perfect tight mobile margins */
  }
  /* Prevent any massive fixed sizes in child items */
  img,
  svg,
  canvas {
    max-width: 100% !important;
  }
}

/* Responsive Flex Layout Helpers */
.flex-responsive {
  display: flex !important;
  flex-direction: column !important;
}
@media (min-width: 768px) {
  .flex-responsive {
    flex-direction: row !important;
  }
}

.flex-responsive-sm {
  display: flex !important;
  flex-direction: column !important;
}
@media (min-width: 576px) {
  .flex-responsive-sm {
    flex-direction: row !important;
  }
}

.align-center-responsive {
  align-items: stretch !important;
}
@media (min-width: 768px) {
  .align-center-responsive {
    align-items: center !important;
  }
}

.align-flex-end-responsive {
  align-items: stretch !important;
}
@media (min-width: 768px) {
  .align-flex-end-responsive {
    align-items: flex-end !important;
  }
}

.align-center-responsive-sm {
  align-items: stretch !important;
}
@media (min-width: 576px) {
  .align-center-responsive-sm {
    align-items: center !important;
  }
}

.text-right-responsive {
  text-align: center !important;
}
@media (min-width: 768px) {
  .text-right-responsive {
    text-align: right !important;
  }
}

.align-self-responsive {
  align-self: center !important;
}
@media (min-width: 768px) {
  .align-self-responsive {
    align-self: auto !important;
  }
}

/* Responsive Grid Helpers */
.grid-responsive-2-1 {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 20px;
}
@media (min-width: 1024px) {
  .grid-responsive-2-1 {
    grid-template-columns: 2fr 1fr !important;
  }
}
