/* assets/css/frontend.css */
.tl-wrap {
  --tl-border: #e5e7eb;
  --tl-muted: #6b7280;
  --tl-chip-bg: #ffffff;
  --tl-chip-border: #d1d5db;
  --tl-card-bg: #fff;
  --tl-num: #0f172a;
  background: #fff;
  border: 1px solid var(--tl-border);
  border-radius: 12px;
  padding: 18px;
}

@media (prefers-color-scheme: dark) {
  .tl-wrap {
    --tl-border: #334155;
    --tl-muted: #94a3b8;
    --tl-chip-bg: #0b1220;
    --tl-chip-border: #1e293b;
    --tl-card-bg: #0b1220;
    --tl-num: #e2e8f0;
    background: #0b1220;
    color: #e5e7eb;
  }
}

.tl-head {
  margin-bottom: 4px;
}

.tl-headline {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 20px;
}

.tl-date {
  font-size: 13px;
  color: var(--tl-muted);
  margin-bottom: 12px;
}

/* Top tiles */
.tl-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.tl-tile {
  border: 1px solid var(--tl-border);
  border-radius: 12px;
  background: var(--tl-card-bg);
  padding: 12px;
}

.tl-tile-title {
  font-size: 12px;
  color: var(--tl-muted);
  margin-bottom: 6px;
}

.tl-tile-number {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #0f172a;
}

@media (prefers-color-scheme: dark) {
  .tl-tile-number {
    color: var(--tl-num);
  }
}

.tl-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tl-chip {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--tl-chip-border);
  border-radius: 10px;
  background: var(--tl-chip-bg);
  font-weight: 700;
}

.tl-chip--muted {
  opacity: 0.6;
}

/* Cards (rank 3–5) */
.tl-card {
  border: 1px solid var(--tl-border);
  border-radius: 12px;
  background: var(--tl-card-bg);
  padding: 12px;
  margin-bottom: 12px;
}

.tl-card-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.tl-card-meta {
  font-size: 12px;
  color: var(--tl-muted);
  margin-bottom: 8px;
}

/* Grid of numbers inside card */
.tl-grid {
  display: grid;
  gap: 8px 18px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.tl-num {
  font-weight: 700;
}

/* Notice */
.tl-alert {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
}

@media (prefers-color-scheme: dark) {
  .tl-alert {
    color: #fecaca;
    background: #3f1515;
    border-color: #7f1d1d;
  }
}

/* ===== Thai Lotto Simple (cardbox layout) ===== */
.tle-cardbox {
  background: #0c0c0c;
  border: 2px solid #f29f32;
  border-radius: 14px;
  overflow: hidden;
  color: #eaeaea;
  max-width: 680px;
  margin: 0 auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  font-family: "Prompt", "Sarabun", sans-serif;
}

.tle-cardbox__head {
  background: #f2a32f;
  /* ส้ม */
  padding: 16px 18px;
  text-align: center;
}

.tle-cardbox__title {
  color: #19e3cf;
  /* ฟ้าเขียว */
  font-weight: 700;
  font-size: 22px;
  line-height: 1.25;
}

.tle-cardbox__date {
  color: #ffe7c2;
  margin-top: 6px;
  font-weight: 600;
}

.tle-cardbox__body {
  padding: 18px;
}

.tle-cardbox__inner {
  border: 2px solid #e6e6e6;
  border-radius: 10px;
  padding: 14px;
}

.tle-row {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.tle-flex-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.tle-col {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 14px;
  margin-bottom: 14px;
}

.tle-col-last-two {
  height: 100%;
}

.last-two {
  display: block;
  gap: 14px;
  margin-bottom: 14px;
  width: 100%;
}

.tle-cell {
  border: 2px solid #e6e6e6;
  border-radius: 10px;
  padding: 14px;
  background: #121212;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90px;
}

.tle-cell--full {
  grid-column: 1 / -1;
}

.tle-cell--highlight {
  background: #1a1a1a;
}

.tle-num {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
  color: #f2a32f;
  /* ส้ม */
  text-align: center;
}

.tle-num--xl {
  font-size: 44px;
}

.tle-num--lg {
  font-size: 38px;
}

.tle-sub {
  color: #9ca3af;
  margin-top: 6px;
  font-size: 14px;
}

.tle-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
}

.tle-btn {
  display: inline-block;
  background: #f2a32f;
  color: #101010;
  padding: 12px 26px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.06s ease-in-out, filter 0.12s ease-in-out;
}

.tle-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

/* Mobile */
@media (max-width: 640px) {
  .tle-row {
    grid-template-columns: 1fr;
  }

  .tle-num--xl {
    font-size: 36px;
  }

  .tle-num--lg {
    font-size: 32px;
  }
}

.tle-wrap {
  background: #0c0c0c;
  color: #fff;
  border: 1px solid #2f2f2f;
  border-radius: 12px;
  padding: 18px;
}

.tle-title {
  color: #19e3cf;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  font-size: 22px;
}

.tle-row.ctl {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.tle-select {
  appearance: none;
  background: #1a1a1a;
  border: 1px solid #444;
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  min-width: 260px;
}

.tle-input input {
  width: 100%;
  min-width: 380px;
  background: #fff;
  border-radius: 10px;
  border: 0;
  padding: 12px 14px;
  color: #111;
}

.tle-btn {
  background: #e23aae;
  color: #f2e6f7;
  border: 1px solid #e23aae;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
}

.tle-history__title {
  color: #19e3cf;
  text-align: center;
  font-weight: 700;
  margin: 18px 0;
}

.tle-history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.tle-card {
  background: #111;
  border-radius: 10px;
  border: 1px solid #ddd;
  padding: 12px;
  position: relative;
}

.tle-card.loading {
  height: 160px;
  opacity: 0.5;
}

.tle-card .date-tag {
  position: absolute;
  left: 12px;
  top: 12px;
  background: #f6a62e;
  color: #111;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}

.tle-card .date-tag .day {
  font-size: 20px;
  font-weight: 800;
}

.tle-card .date-tag .mon {
  font-size: 12px;
}

.tle-card .card-head {
  margin-left: 84px;
  color: #f6a62e;
  font-weight: 700;
}

.tle-card .grid {
  margin-top: 8px;
  margin-left: 84px;
  display: grid;
  grid-template-columns: 160px 1fr;
  row-gap: 10px;
}

.tle-card .label {
  background: #e9e9e9;
  color: #333;
  border-radius: 6px;
  padding: 6px 10px;
}

.tle-card .value {
  font-weight: 800;
  letter-spacing: 1px;
}

.tle-check-result {
  margin-top: 10px;
  text-align: center;
  color: #fff;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px;
}

@media (max-width: 900px) {
  .tle-row.ctl {
    flex-direction: column;
  }

  .tle-history-grid {
    grid-template-columns: 1fr;
  }

  .tle-input input {
    min-width: unset;
    width: 100%;
  }

  .tle-select {
    min-width: unset;
    width: 100%;
  }
}

/* Thai Lotto Elementor — Next.js-inspired UI
   - Clean, modern, accessible
   - Light/Dark via prefers-color-scheme
   - Scoped to .tl-widget soไม่ชนธีมอื่น/Elementor
*/
:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #0a0a0a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ring: #2563eb;
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.05);
  --accent-start: #6366f1;
  /* indigo-500 */
  --accent-end: #22d3ee;
  /* cyan-400  */
  --success-bg: #f0fdf4;
  --success-border: #dcfce7;
  --success-text: #166534;
  --error-bg: #fef2f2;
  --error-border: #fee2e2;
  --error-text: #991b1b;
  --info-bg: #eff6ff;
  --info-border: #dbeafe;
  --info-text: #1e3a8a;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter,
    "Helvetica Neue", Arial, "Noto Sans Thai", "Noto Sans", "SF Pro Text",
    "Apple Color Emoji", "Segoe UI Emoji";
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --card: #0e141b;
    --text: #f5f7fb;
    --muted: #a1a8b3;
    --border: #1f2937;
    --ring: #60a5fa;
    --shadow: 0 8px 18px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
    --success-bg: #0f1f15;
    --success-border: #123522;
    --success-text: #86efac;
    --error-bg: #1a0f11;
    --error-border: #3b0d12;
    --error-text: #fca5a5;
    --info-bg: #0e1726;
    --info-border: #1b2a44;
    --info-text: #93c5fd;
  }
}

/* Base wrapper */
.tl-widget {
  font-family: var(--font);
  color: var(--text);
  margin: 1.25rem 0;
}

/* Layout rows */
.tl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.7rem;
}

.tl-row:has(textarea) {
  grid-template-columns: 1fr;
}

.tl-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Card */
.tl-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

/* Inputs */
.tl-input {
  appearance: none;
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s,
    transform 0.05s ease-in-out;
}

.tl-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
}

@media (prefers-color-scheme: dark) {
  .tl-input {
    background: rgba(255, 255, 255, 0.03);
  }
}

.tl-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring) 18%, transparent);
}

textarea.tl-input {
  min-height: 6.5rem;
  resize: vertical;
}

/* Buttons */
.tl-btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background-image: linear-gradient(
    135deg,
    var(--accent-start),
    var(--accent-end)
  );
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25),
    0 4px 8px rgba(34, 211, 238, 0.15);
  transition: transform 0.05s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.tl-btn:hover {
  filter: brightness(1.05);
}

.tl-btn:active {
  transform: translateY(1px) scale(0.98);
}

/* Status line (loading/error/success) */
.tl-status {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.92rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
}

.tl-status.is-loading {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.tl-status.is-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.tl-status.is-ok {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

/* Draw header */
.thai-lotto-draw {
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.thai-lotto-draw::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(
    60% 60% at 30% 30%,
    var(--accent-end),
    var(--accent-start)
  );
  box-shadow: 0 0 0 3px
    color-mix(in oklab, var(--accent-start) 18%, transparent);
}

.thai-lotto-draw-history {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* Table */
.tl-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}

.tl-table thead th {
  font-size: 0.9rem;
  text-align: left;
  font-weight: 700;
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--border) 45%, transparent),
    transparent
  );
}

.tl-table tbody td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.tl-table tbody tr:last-child td {
  border-bottom: 0;
}

.tl-table tbody tr:hover td {
  background: color-mix(in oklab, var(--border) 14%, transparent);
}

/* Hit row highlight */
.tl-table tr.tl-hit td {
  background: var(--success-bg);
  border-bottom-color: var(--success-border);
  color: var(--success-text);
  box-shadow: inset 0 1px 0 var(--success-border);
}

/* Badges */
.tl-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  margin: 0.12rem 0.25rem 0.12rem 0;
  background: color-mix(in oklab, var(--border) 22%, transparent);
}

.tl-badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.tl-badge--first {
  color: #6d28d9;
  border-color: color-mix(in oklab, #6d28d9 35%, var(--border));
  background: color-mix(in oklab, #6d28d9 10%, transparent);
}

.tl-badge--first-near {
  color: #3730a3;
  border-color: color-mix(in oklab, #3730a3 35%, var(--border));
  background: color-mix(in oklab, #3730a3 10%, transparent);
}

.tl-badge--front3 {
  color: #0e7490;
  border-color: color-mix(in oklab, #0e7490 35%, var(--border));
  background: color-mix(in oklab, #0e7490 10%, transparent);
}

.tl-badge--last3 {
  color: #92400e;
  border-color: color-mix(in oklab, #92400e 35%, var(--border));
  background: color-mix(in oklab, #92400e 10%, transparent);
}

.tl-badge--last2 {
  color: #9f1239;
  border-color: color-mix(in oklab, #9f1239 35%, var(--border));
  background: color-mix(in oklab, #9f1239 10%, transparent);
}

/* Utility */
.tl-muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.tl-space-y > * + * {
  margin-top: 0.65rem;
}

/* Skeleton (optional) */
.tl-skeleton {
  display: block;
  background: linear-gradient(
    90deg,
    color-mix(in oklab, var(--border) 45%, transparent) 25%,
    color-mix(in oklab, var(--border) 25%, transparent) 37%,
    color-mix(in oklab, var(--border) 45%, transparent) 63%
  );
  background-size: 400% 100%;
  animation: tl-shimmer 1.2s infinite linear;
  border-radius: var(--radius-xs);
}

@keyframes tl-shimmer {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: 0 0;
  }
}

/* Elementor-specific scopes */
.elementor-widget-thai_lotto_checker .tl-widget,
.elementor-widget-thai_lotto_by_date .tl-widget,
.elementor-widget-thai_lotto_results_history .tl-widget,
.elementor-widget-thai_lotto_latest .tl-widget {
  margin-top: 1rem;
  margin-bottom: 1.25rem;
}

/* Mobile */
@media (max-width: 640px) {
  .tl-row {
    grid-template-columns: 1fr;
  }

  .tl-actions {
    gap: 0.4rem;
  }

  .tl-btn {
    width: 100%;
  }
}

/* แสดงผลย้อนหลังแบบเต็ม */

.tl-history-card {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.history-card {
  display: flex !important;
  flex-direction: row !important;
  gap: 0.5rem;
}

.tle-by-date {
  border: 1px solid #eee;
  padding: 16px;
  border-radius: 12px;
}

.tle-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tle-select {
  min-width: 260px;
  padding: 6px 10px;
}

.tle-more {
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.tle-result.is-loading {
  opacity: 0.7;
}

.tle-block {
  display: grid;
  gap: 6px;
}

.tle-line {
  padding: 8px 10px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px dashed #eee;
}

.tl-rowline {
  padding: 10px !important;
  display: flex !important;
  flex-direction: column !important;
  border: 1px solid #27cdee7a !important;
  border-radius: 5px !important;
  background-color: #0400314a !important;
}

.tl-prize-met {
  color: #efefef;
  font-weight: 300;
  font-size: 10px;
  margin-left: 8px;
}

.tl-single {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 1140px;
  margin: 0 auto;
}

/* ปุ่มตรวจรางวัล */
.btn-check-lotto-history {
  background: #1bb34d !important;
  color: #fff !important;
  border: 1px solid #14913c !important;
  border-radius: 8px;
  padding: .55rem .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter .2s ease;
}
.btn-check-lotto-history:hover { filter: brightness(1.25) !important; }

/* สถานะตรวจรางวัล */
#tl-check-status[data-state="success"]{
  border:1px solid #1bb34d;
  background:#e8f8ef;
  color:#0e6a33;
  padding:.5rem .75rem;
  border-radius:8px
}
#tl-check-status[data-state="fail"]{
  border:1px solid #e57373;
  background:#fff1f1;
  color:#b71c1c;
  padding:.5rem .75rem;
  border-radius:8px
}

/* กริดรางวัลที่ 2–5: มือถือ 2 คอลัมน์, จอใหญ่ 10 คอลัมน์ */
.tl-grid[data-cols]{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:8px;
}
@media (min-width:768px){
  .tl-grid[data-cols]{ grid-template-columns:repeat(10,1fr); }
}

/* ชิป/หมายเลข ให้ดูเด่นใน 10 คอลัมน์ */
.tl-num, .tl-chip {
  display:inline-block;
  text-align:center;
  padding:.5rem .75rem;
  border:1px solid var(--border, #e5e7eb);
  border-radius:8px;
  font-weight:600;
}
.tl-chip--bold { font-weight:700; }
.tl-chip--muted { opacity:.6; }