/* ============================================================
   DÒ VÉ SỐ ONLINE - PWA MODERN STYLESHEET
   Nguồn dữ liệu: minhngoc.net.vn/do-ve-so.html
   ============================================================ */

:root {
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
  
  /* Dark Theme Default */
  --bg-app: #0b0f19;
  --bg-card: #151d2e;
  --bg-card-hover: #1c263b;
  --bg-input: #1a2336;
  --border-color: #27354f;
  --border-light: rgba(255, 255, 255, 0.08);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --red-lottery: #dc2626;
  --red-lottery-dark: #991b1b;
  --red-glow: rgba(220, 38, 38, 0.4);
  --gold-primary: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.4);
  --green-win: #10b981;
  --green-glow: rgba(16, 185, 129, 0.35);
  --blue-accent: #3b82f6;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-light: rgba(0, 0, 0, 0.06);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ================= HEADER ================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 25, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
}
[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.92);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px var(--red-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  flex-shrink: 0;
}
.brand-icon img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-text .source-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--blue-accent);
}

.btn-install {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  border: none;
  box-shadow: 0 2px 10px var(--red-glow);
}

/* ================= MAIN CONTAINER ================= */
.main-container {
  flex: 1;
  padding: 24px 16px 48px;
}

/* ================= CHECKER FORM CARD ================= */
.checker-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.checker-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #dc2626, #f59e0b, #dc2626);
}

.checker-header {
  text-align: center;
  margin-bottom: 24px;
}
.badge-title {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(220, 38, 38, 0.15);
  color: #ef4444;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.checker-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.checker-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.ticket-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}
.day-indicator {
  color: var(--gold-primary);
  font-weight: 800;
  font-size: 0.82rem;
}
.station-count-tag {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.hint-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s;
}
.form-input:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px var(--red-glow);
}

.date-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quick-dates {
  display: flex;
  gap: 6px;
}
.btn-chip {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.btn-chip.active {
  background: var(--blue-accent);
  color: #fff;
  border-color: var(--blue-accent);
}

.select-wrapper {
  position: relative;
}
.form-select {
  cursor: pointer;
  font-weight: 600;
}

/* Big Number Input */
.number-input-box {
  position: relative;
  display: flex;
  align-items: center;
}
.ticket-number-input {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-align: center;
  color: var(--gold-primary);
  padding: 14px 60px 14px 20px;
}

.btn-paste, .btn-clear {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-paste {
  right: 48px;
}
.btn-clear {
  right: 12px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.btn-paste:hover, .btn-clear:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Keypad */
.keypad-toggle-bar {
  display: flex;
  justify-content: flex-end;
}
.btn-text {
  background: transparent;
  border: none;
  color: var(--blue-accent);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.virtual-keypad {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 4px;
}
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.num-key {
  height: 48px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.1s;
}
.num-key:active {
  background: var(--border-color);
  transform: scale(0.96);
}
.key-clear {
  color: #ef4444;
}
.key-back {
  color: var(--gold-primary);
}

/* Submit Button */
.btn-submit {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--red-glow);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}
.btn-submit:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 6px 20px var(--red-glow);
}
.btn-submit:active {
  transform: translateY(0);
}

/* ================= RESULT CARD ================= */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-bottom: 24px;
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Winning Status */
.result-header-win {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(245, 158, 11, 0.25));
  border-bottom: 2px solid var(--green-win);
  padding: 24px;
  text-align: center;
}
.win-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--green-win);
  color: #fff;
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  padding: 4px 16px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
  box-shadow: 0 4px 12px var(--green-glow);
}
.win-prize-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.win-prize-value {
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold-primary);
  letter-spacing: 0.02em;
  text-shadow: 0 0 20px var(--gold-glow);
}

/* Lose Status */
.result-header-lose {
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-color);
  padding: 24px;
  text-align: center;
}
.lose-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-secondary);
}
.lose-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Query Info Box */
.result-query-info {
  padding: 16px 20px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-light);
  font-size: 0.85rem;
  line-height: 1.6;
}
.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.info-row:last-child {
  margin-bottom: 0;
}
.info-label {
  color: var(--text-muted);
}
.info-val {
  font-weight: 700;
  color: var(--text-primary);
}

/* Sample Ticket Photo */
.ticket-photo-box {
  padding: 16px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
}
.ticket-photo-box h4 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.ticket-photo-box img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* Full Station Prize Table */
.station-table-box {
  padding: 20px;
}
.station-table-box h4 {
  font-size: 0.95rem;
  color: #ef4444;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.full-prize-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.full-prize-table tr {
  border-bottom: 1px solid var(--border-light);
}
.full-prize-table td {
  padding: 8px 12px;
  vertical-align: middle;
}
.col-label {
  width: 90px;
  font-weight: 700;
  color: var(--text-secondary);
}
.col-numbers {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
}
.col-reward {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.row-db .col-numbers {
  color: #ef4444;
  font-size: 1.35rem;
  font-weight: 900;
}
.row-db .col-reward {
  color: var(--gold-primary);
  font-weight: 800;
}

/* Result Actions */
.result-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: var(--bg-input);
  border-top: 1px solid var(--border-light);
}
.btn-action-half {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--blue-accent);
}
.btn-solid {
  background: var(--blue-accent);
  border: none;
  color: #fff;
}
.btn-solid:hover {
  filter: brightness(1.1);
}

/* ================= RECENT HISTORY CARD ================= */
.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.history-header h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}
.text-danger {
  color: #ef4444;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.history-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--blue-accent);
}
.history-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-num {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gold-primary);
}
.history-details {
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.history-badge-win {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.2);
  color: var(--green-win);
  font-size: 0.72rem;
  font-weight: 800;
}
.history-badge-lose {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ================= OFFLINE & MODAL ================= */
.offline-banner {
  background: #dc2626;
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  display: none;
}
.offline-banner.visible {
  display: block;
}

.install-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.install-modal-backdrop.open {
  display: flex;
}
.install-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}
.install-guide-box {
  text-align: left;
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin: 16px 0 20px;
}

/* ================= FOOTER ================= */
.app-footer {
  margin-top: auto;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
  text-align: center;
  font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 480px) {
  .checker-card {
    padding: 20px 16px;
  }
  .ticket-number-input {
    font-size: 1.5rem;
    padding-right: 50px;
  }
  .win-prize-value {
    font-size: 1.6rem;
  }
}
