/* ============================================================
   TIZEN DIGITAL SIGNAGE — STYLE
   Optimized for Samsung Smart TV (Tizen WebKit)
   - GPU-only animations (transform, opacity)
   - System fonts (no external font loading)
   - No CSS Grid (use flexbox for Tizen compat)
   - contain: strict on static elements
   ============================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: 'Samsung Sans', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  /* Cursor: visible by default, hidden after idle */
  cursor: default;
}

/* Cursor auto-hide after 3s idle */
body.cursor-hide {
  cursor: none;
}

body.cursor-hide #fullscreen-btn {
  opacity: 0;
  pointer-events: none;
}

/* === FULLSCREEN BUTTON === */
#fullscreen-btn {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: 80px;
  height: 80px;
  background: rgba(0,0,0,0.6);
  border: 3px solid rgba(255,255,255,0.5);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.3s ease, background 0.3s ease;
  pointer-events: auto;
}

#fullscreen-btn:hover {
  opacity: 1;
  background: rgba(0,0,0,0.85);
  border-color: #fff;
}

#fullscreen-btn svg {
  width: 40px;
  height: 40px;
}

/* Hide button when already in fullscreen */
body.is-fullscreen #fullscreen-btn {
  display: none;
}

/* In fullscreen: cursor hidden, show on mouse move */
body.is-fullscreen {
  cursor: none;
}

body.is-fullscreen.cursor-visible {
  cursor: default;
}

/* === SLIDESHOW (full-screen background) === */
#slideshow {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
}

.slide {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0;
  transition: opacity 1s ease;
  will-change: opacity;
  contain: strict;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #111;
}

.slide.active {
  opacity: 1;
  z-index: 1;
}

/* Dark overlay for readability */
#slideshow::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(0,0,0,0.45) 0%,
    rgba(0,0,0,0.15) 40%,
    rgba(0,0,0,0.15) 60%,
    rgba(0,0,0,0.45) 100%
  );
  z-index: 2;
  pointer-events: none;
  contain: strict;
}

/* === LEFT COLUMN: jadwal + sholat (tidak pernah tumpang tindih) === */
#left-column {
  position: fixed;
  top: 30px;
  left: 40px;
  bottom: 80px;          /* tepat di atas ticker bar */
  z-index: 10;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
  gap: 16px;
  pointer-events: none;
  min-width: 320px;
  max-width: 480px;
}

/* === ROOM SCHEDULE OVERLAY (top-left) === */
#schedule-overlay {
  /* posisi diatur oleh #left-column flex */
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-height: 0;          /* penting: agar flex bisa crop konten */
  z-index: 10;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 20px 28px;
  overflow-y: auto;
  pointer-events: none;
  contain: layout style;
}

/* Custom scrollbar for schedule */
#schedule-overlay::-webkit-scrollbar {
  width: 3px;
}
#schedule-overlay::-webkit-scrollbar-track {
  background: transparent;
}
#schedule-overlay::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}

.schedule-title {
  font-size: 20px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#schedule-date {
  font-size: 15px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 12px;
  letter-spacing: 1px;
}

#schedule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border-left: 3px solid rgba(100,181,246,0.6);
}

.schedule-item.active-now {
  border-left-color: #66bb6a;
  background: rgba(102,187,106,0.12);
}

.schedule-sesi {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,203,68,0.85);
  letter-spacing: 1px;
}

.schedule-kegiatan {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin-top: 2px;
}

.schedule-meta {
  font-size: 14px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}

.schedule-now-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #1b5e20;
  background: #66bb6a;
  padding: 1px 8px;
  border-radius: 3px;
  margin-left: 8px;
  text-transform: uppercase;
  vertical-align: middle;
}

.schedule-empty {
  font-size: 16px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 12px 0;
}

.schedule-loading {
  font-size: 16px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 12px 0;
}

.schedule-error {
  font-size: 14px;
  color: rgba(239,83,80,0.7);
  text-align: center;
  padding: 8px 0;
}

/* === CLOCK OVERLAY (top-right) === */
#clock-overlay {
  position: fixed;
  top: 30px;
  right: 40px;
  z-index: 10;
  text-align: right;
  pointer-events: none;
}

#clock-time {
  font-size: 96px;
  font-weight: 700;
  letter-spacing: 4px;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 30px rgba(0,0,0,0.8),
    0 2px 8px rgba(0,0,0,0.6);
}

#cs {
  font-size: 48px;
  vertical-align: super;
  opacity: 0.7;
  margin-left: 4px;
}

.colon {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.2; }
}

#clock-date {
  font-size: 28px;
  font-weight: 400;
  color: rgba(255,255,255,0.75);
  margin-top: 8px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  letter-spacing: 2px;
}

/* === PRAYER OVERLAY (bottom-left) === */
#prayer-overlay {
  /* posisi diatur oleh #left-column flex — selalu di bawah jadwal */
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  z-index: 10;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 24px 32px;
  pointer-events: none;
  contain: layout style;
}

.prayer-title {
  font-size: 22px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#prayer-location {
  font-size: 16px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

#prayer-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prayer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  transition: background-color 0.3s ease;
}

.prayer-row.active {
  background: rgba(76,175,80,0.25);
}

.prayer-name {
  font-size: 20px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: 1px;
}

.prayer-row.active .prayer-name {
  color: #81c784;
}

.prayer-time {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.prayer-row.active .prayer-time {
  color: #a5d6a7;
}

/* Next prayer countdown */
#next-prayer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

#next-label {
  font-size: 14px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 2px;
}

#next-name {
  font-size: 20px;
  font-weight: 700;
  color: #64b5f6;
}

#next-countdown {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 15px rgba(100,181,246,0.4);
}

/* === TICKER BAR (bottom) === */
#ticker-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  overflow: hidden;
  z-index: 10;
  contain: layout style paint;
}

#ticker-text {
  white-space: nowrap;
  font-size: 22px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 1px;
  animation: scroll-left 30s linear infinite;
  will-change: transform;
  padding-left: 100%;
}

@keyframes scroll-left {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* === ERROR OVERLAY === */
#error-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#error-overlay.hidden {
  display: none;
}

#error-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #e53935;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 20px;
}

#error-msg {
  font-size: 24px;
  color: rgba(255,255,255,0.7);
  text-align: center;
  max-width: 600px;
}

/* === RESPONSIVE (4K support) === */
@media (min-width: 2560px) {
  #clock-time { font-size: 128px; }
  #cs { font-size: 64px; }
  #clock-date { font-size: 36px; }
  #left-column { bottom: 96px; min-width: 420px; max-width: 600px; }
  #prayer-overlay { padding: 32px 40px; }
  .prayer-title { font-size: 28px; }
  .prayer-name { font-size: 26px; }
  .prayer-time { font-size: 32px; }
  #next-countdown { font-size: 36px; }
  #ticker-bar { height: 72px; }
  #ticker-text { font-size: 28px; }
  #schedule-overlay { padding: 28px 36px; }
  .schedule-title { font-size: 26px; }
  .schedule-kegiatan { font-size: 24px; }
  .schedule-sesi { font-size: 18px; }
  .schedule-meta { font-size: 18px; }
}
