/* ============================================================
   Display Board Styles
   ============================================================ */

:root {
  --db-bg:      #0a0a1a;
  --db-accent:  #0d6efd;
  --db-text:    #ffffff;
  --db-muted:   rgba(255,255,255,.6);
  --db-card-bg: rgba(255,255,255,.08);
  --db-border:  rgba(255,255,255,.1);
  --db-font:    'Sarabun', sans-serif;
  --db-slide-duration: 8s;
  --ticker-height: 48px;
  --emergency-height: 0px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.display-body {
  font-family: var(--db-font);
  background: var(--db-bg);
  color: var(--db-text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* ── Themes ── */
body.theme-dark   { --db-bg: #0a0a1a; --db-card-bg: rgba(255,255,255,.08); }
body.theme-light  { --db-bg: #f0f2f5; --db-text: #1a1a2e; --db-card-bg: rgba(0,0,0,.04); --db-muted: rgba(0,0,0,.5); --db-border: rgba(0,0,0,.1); }
body.theme-corporate { --db-bg: #001233; --db-accent: #0094ff; }
body.theme-factory { --db-bg: #0d0d0d; --db-accent: #ff6b00; }

/* ============================================================
   EMERGENCY BANNER
   ============================================================ */
.emergency-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  background: #dc3545;
  color: #fff;
  z-index: 9999;
  padding: 0 1.5rem;
  font-weight: 700;
  overflow: hidden;
}

.blink { animation: blink 1s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

.emergency-ticker {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}
.emergency-item { display: inline-block; padding-right: 4rem; }

/* ============================================================
   SLIDE ENGINE
   ============================================================ */
.slide-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.slide-item {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .8s ease;
  cursor: pointer;
}
.slide-item.active { opacity: 1; z-index: 2; }

.slide-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1);
  transition: transform 10s ease;
}
.slide-item.active .slide-bg { transform: scale(1.04); }

.slide-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.3) 60%, transparent 100%);
}
.slide-overlay-full {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.9) 0%, rgba(0,0,0,.4) 100%);
}
.slide-bg-color {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--db-bg) 0%, rgba(13,110,253,.3) 100%);
}

.slide-content {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 2rem;
  z-index: 3;
}

.slide-title {
  font-size: clamp(1.3rem, 3vw, 2.2rem);
  font-weight: 700;
  line-height: 1.3;
  text-shadow: 0 2px 10px rgba(0,0,0,.5);
  margin-bottom: .5rem;
}

.slide-summary {
  font-size: clamp(.85rem, 1.8vw, 1.1rem);
  color: rgba(255,255,255,.8);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slide-qr {
  width: 72px;
  height: 72px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 8px;
}

/* Progress bar */
.slide-progress {
  position: absolute;
  bottom: var(--ticker-height);
  left: 0; right: 0;
  height: 3px;
  background: rgba(255,255,255,.15);
  z-index: 10;
}
.slide-progress-bar {
  height: 100%;
  background: var(--db-accent);
  width: 0%;
  transition: width linear var(--db-slide-duration);
}

/* Dots */
.slide-dots {
  position: absolute;
  bottom: calc(var(--ticker-height) + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .5rem;
  z-index: 10;
}
.slide-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  cursor: pointer;
  transition: all .2s;
}
.slide-dot.active {
  background: var(--db-accent);
  transform: scale(1.3);
}

/* ============================================================
   TICKER BAR
   ============================================================ */
.ticker-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--ticker-height);
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--db-border);
  display: flex;
  align-items: center;
  z-index: 100;
  overflow: hidden;
}

.ticker-label {
  background: var(--db-accent);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.ticker-content {
  flex: 1;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
}

.ticker-inner {
  display: inline-flex;
  align-items: center;
  animation: ticker-scroll 60s linear infinite;
  white-space: nowrap;
}
@keyframes ticker-scroll {
  0%   { transform: translateX(100vw); }
  100% { transform: translateX(-100%); }
}

.ticker-item {
  padding-right: 3rem;
  font-size: .9rem;
  color: rgba(255,255,255,.85);
}
.ticker-sep { color: var(--db-accent); margin-left: 1rem; }

/* ============================================================
   SPLIT LAYOUT
   ============================================================ */
.display-split {
  display: flex;
  height: calc(100vh - var(--ticker-height));
}

.split-main {
  flex: 7;
  position: relative;
  overflow: hidden;
}

.split-sidebar {
  flex: 3;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--db-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--db-border);
  flex-shrink: 0;
}
.company-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--db-text);
}
.logo-img { max-height: 50px; max-width: 100%; object-fit: contain; }

.sidebar-clock {
  padding: 1rem;
  border-bottom: 1px solid var(--db-border);
  flex-shrink: 0;
  text-align: center;
}
.clock-time {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .05em;
  color: var(--db-accent);
  line-height: 1;
}
.clock-date {
  font-size: .85rem;
  color: var(--db-muted);
  margin-top: .3rem;
}

.sidebar-news-title {
  padding: .75rem 1rem .5rem;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--db-muted);
  flex-shrink: 0;
}

.sidebar-news-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-news-list::-webkit-scrollbar { display: none; }

.sidebar-news-item {
  display: flex;
  gap: .75rem;
  padding: .7rem 1rem;
  cursor: pointer;
  transition: background .2s;
  border-bottom: 1px solid var(--db-border);
}
.sidebar-news-item:hover,
.sidebar-news-item.active {
  background: rgba(255,255,255,.05);
}
.sidebar-news-item.active {
  border-left: 3px solid var(--db-accent);
}

.sidebar-news-thumb {
  width: 60px;
  height: 45px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
}
.sidebar-news-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-placeholder {
  width: 100%;
  height: 100%;
  background: var(--db-card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--db-muted);
}

.sidebar-news-cat { font-size: .7rem; font-weight: 600; }
.sidebar-news-headline {
  font-size: .82rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sidebar-news-date { font-size: .7rem; color: var(--db-muted); margin-top: 2px; }

/* ============================================================
   FULLSCREEN LAYOUT
   ============================================================ */
.display-fullscreen {
  position: relative;
  height: calc(100vh - var(--ticker-height));
}

.fs-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(1.5rem, 5vw, 4rem);
  z-index: 3;
}

.fs-title {
  font-size: clamp(1.8rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.2;
  text-shadow: 0 4px 20px rgba(0,0,0,.6);
  margin-bottom: 1rem;
}

.fs-summary {
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  color: rgba(255,255,255,.8);
  max-width: 70%;
  line-height: 1.7;
}

.fs-footer { margin-top: 2rem; }

.qr-fs {
  width: 100px;
  height: 100px;
  border: 4px solid rgba(255,255,255,.4);
  border-radius: 10px;
}

.fs-badge-emergency {
  display: inline-block;
  background: #dc3545;
  color: #fff;
  padding: .4rem 1.2rem;
  border-radius: 50rem;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,53,69,.7); }
  50%       { box-shadow: 0 0 0 16px rgba(220,53,69,0); }
}

.fs-clock-overlay {
  position: absolute;
  top: 1.5rem; right: 2rem;
  text-align: right;
  z-index: 10;
}
.fs-clock-time {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
  color: var(--db-accent);
}
.fs-clock-date { font-size: .9rem; color: rgba(255,255,255,.6); }
.fs-dots { bottom: calc(var(--ticker-height) + 20px); }

/* ============================================================
   TV LAYOUT
   ============================================================ */
.display-tv {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--ticker-height));
}

.tv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 2rem;
  background: rgba(0,0,0,.4);
  border-bottom: 1px solid var(--db-border);
  flex-shrink: 0;
}
.tv-company-name { font-size: 1.3rem; font-weight: 700; }
.tv-clock { text-align: right; }
.tv-clock-time { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--db-accent); line-height: 1; }
.tv-clock-date  { font-size: .78rem; color: var(--db-muted); }

.tv-body {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
}

.tv-featured {
  flex: 6.5;
  position: relative;
  overflow: hidden;
}

.tv-slide { cursor: pointer; }

.tv-slide-content {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 2rem 2.5rem;
  z-index: 3;
  background: linear-gradient(to top, rgba(0,0,0,.9) 0%, transparent 100%);
}

.tv-slide-title {
  font-size: clamp(1.5rem, 3.5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: .5rem;
}

.tv-slide-summary {
  font-size: clamp(.85rem, 1.8vw, 1.2rem);
  color: rgba(255,255,255,.8);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tv-qr { width: 80px; height: 80px; border-radius: 8px; border: 2px solid rgba(255,255,255,.3); }

.tv-category-badge {
  display: inline-block;
  padding: .3rem .9rem;
  border-radius: 50rem;
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: .75rem;
}

.tv-badge-emergency {
  display: inline-block;
  background: #dc3545;
  color: #fff;
  padding: .3rem 1rem;
  border-radius: 50rem;
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: .75rem;
}

.tv-grid {
  flex: 3.5;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  background: rgba(0,0,0,.3);
  border-left: 1px solid var(--db-border);
}

.tv-card {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--db-border);
  cursor: pointer;
  transition: background .2s;
  overflow: hidden;
  position: relative;
}
.tv-card:hover { background: rgba(255,255,255,.05); }

.tv-card-img {
  flex-shrink: 0;
  height: 60%;
  background-size: cover;
  background-position: center;
}

.tv-card-body {
  flex: 1;
  padding: .6rem .85rem;
}

.tv-card-cat {
  font-size: .7rem;
  font-weight: 700;
  display: block;
  margin-bottom: .2rem;
}

.tv-card-title {
  font-size: clamp(.8rem, 1.4vw, 1rem);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   KIOSK LAYOUT
   ============================================================ */
.display-kiosk {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--ticker-height));
}

.kiosk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(0,0,0,.4);
  border-bottom: 1px solid var(--db-border);
  flex-shrink: 0;
}
.kiosk-brand { font-size: 1.2rem; font-weight: 700; }
.kiosk-clock { text-align: right; }
.kiosk-clock-time { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--db-accent); line-height: 1; }
.kiosk-clock-date  { font-size: .78rem; color: var(--db-muted); }

.kiosk-cats {
  display: flex;
  gap: .6rem;
  padding: .75rem 1.2rem;
  overflow-x: auto;
  flex-shrink: 0;
  background: rgba(0,0,0,.2);
  scrollbar-width: none;
}
.kiosk-cats::-webkit-scrollbar { display: none; }

.kiosk-cat-btn {
  padding: .5rem 1.2rem;
  border-radius: 50rem;
  border: 1px solid var(--db-border);
  background: transparent;
  color: var(--db-muted);
  font-family: var(--db-font);
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.kiosk-cat-btn:hover,
.kiosk-cat-btn.active {
  background: var(--cat-color, var(--db-accent));
  border-color: var(--cat-color, var(--db-accent));
  color: #fff;
}

.kiosk-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1rem 1.2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.kiosk-card {
  background: var(--db-card-bg);
  border: 1px solid var(--db-border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all .25s;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(5px);
}
.kiosk-card:hover {
  transform: translateY(-4px);
  border-color: var(--db-accent);
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}

.kiosk-card-img {
  height: 160px;
  position: relative;
  overflow: hidden;
}
.kiosk-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.kiosk-card:hover .kiosk-card-img img { transform: scale(1.05); }
.kiosk-card-placeholder {
  width: 100%;
  height: 100%;
  background: var(--db-card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--db-muted);
}

.kiosk-emergency-badge {
  position: absolute;
  top: .5rem; right: .5rem;
  background: #dc3545;
  color: #fff;
  padding: .2rem .6rem;
  border-radius: 50rem;
  font-size: .75rem;
  font-weight: 700;
}
.kiosk-pin-badge {
  position: absolute;
  top: .5rem; left: .5rem;
  background: rgba(255, 193, 7, .9);
  color: #000;
  padding: .2rem .5rem;
  border-radius: 50rem;
  font-size: .75rem;
}

.kiosk-card-body {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.kiosk-card-cat {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 50rem;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  align-self: flex-start;
}

.kiosk-card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}

.kiosk-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}
.kiosk-card-date { font-size: .75rem; color: var(--db-muted); }
.kiosk-read-more { font-size: .8rem; color: var(--db-accent); font-weight: 600; }

.kiosk-hint {
  padding: .5rem 1.2rem;
  text-align: center;
  font-size: .8rem;
  color: var(--db-muted);
  flex-shrink: 0;
  border-top: 1px solid var(--db-border);
}

/* ============================================================
   NEWS DETAIL OVERLAY
   ============================================================ */
.news-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  backdrop-filter: blur(20px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: overlayIn .3s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.news-detail-inner {
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--db-border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.news-detail-header {
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--db-border);
}
.news-detail-header h2 { font-size: clamp(1.2rem, 3vw, 2rem); font-weight: 700; }

.news-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.news-content { font-size: 1rem; line-height: 1.8; }
.news-content img { max-width: 100%; border-radius: 8px; }

.news-detail-footer {
  padding: 1rem 2rem;
  border-top: 1px solid var(--db-border);
}

/* ============================================================
   NEWS DETAIL PAGE (QR landing)
   ============================================================ */
body.news-detail-page {
  font-family: 'Sarabun', sans-serif;
  background: #f0f2f5;
  overflow: auto;
}

.news-article { padding-bottom: 3rem; }
.news-title { font-size: clamp(1.4rem, 4vw, 2.5rem); font-weight: 800; margin-bottom: 1rem; line-height: 1.3; }
.news-meta { color: #6c757d; font-size: .9rem; }
.news-cover img { width: 100%; max-height: 500px; object-fit: cover; }
.news-content { font-size: 1.05rem; line-height: 1.9; }
.news-content img { max-width: 100%; border-radius: 8px; margin: 1rem 0; }
.news-qr { background: #fff; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .display-split { flex-direction: column; }
  .split-main   { flex: 1 1 65%; }
  .split-sidebar { flex: 1 1 35%; border-left: none; border-top: 1px solid var(--db-border); }

  .tv-grid { display: none; }
  .tv-featured { flex: 1; }

  .kiosk-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (max-width: 480px) {
  .kiosk-grid { grid-template-columns: 1fr; }
  .slide-title  { font-size: 1.2rem; }
  .fs-title     { font-size: 1.5rem; }
}
