/* Preview CSS - Vertical TV Display */

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --white: #ffffff;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-500: #64748b;
  --gray-700: #334155;
  --danger: #ef4444;
  --transition: 1000ms;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--gray-100);
  display: flex;
  flex-direction: column;
}

/* Rotation modes */
body.rotation-0 {
  transform-origin: top left;
  width: 100vw;
  height: 100vh;
}

body.rotation-90 {
  transform-origin: top left;
  transform: rotate(90deg) translateY(-100%);
  width: 100vh;
  height: 100vw;
}

/* Connection status indicator (bottom right, smaller) */
.connection-status {
  position: fixed;
  bottom: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all 0.3s ease;
}

.connection-status svg {
  width: 12px;
  height: 12px;
}

.connection-status.connected {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  opacity: 0; /* Hidden when connected */
}

.connection-status.disconnected {
  background: rgba(239, 68, 68, 0.9);
  color: white;
  opacity: 1; /* Visible when disconnected */
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Header with date (left), logo (center), time (right) */
.board-header {
  background: var(--white);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.header-date {
  flex: 1;
  color: #000;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
}

.logo-container {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  margin: 0 -2px 0 0;
}

.school-logo {
  height: 40px;
  width: auto;
}

.header-time {
  flex: 1;
  color: #000;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* When no posters AND no events - special styling */
body.no-content {
  background: var(--white);
}

/* No poster label in header */
.no-poster-label {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-left: 0.5rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* No-content container (no posters, no events) */
.no-content-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 3rem;
}

.no-content-logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.no-content-logo {
  height: 100px;
  width: auto;
  opacity: 0.9;
}

.quote-container {
  max-width: 600px;
  text-align: center;
  padding: 0 2rem;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quote-text {
  font-size: 1.4rem;
  font-weight: 600;
  color: #93c5fd; /* Lighter blue color */
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

/* No posters placeholder */
.no-posters-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--gray-500);
}

.placeholder-content svg {
  opacity: 0.3;
}

.placeholder-content p {
  font-size: 1.1rem;
  font-weight: 500;
}

/* Main content */
.board-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* No posters state */
.no-posters {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  gap: 1rem;
}

.no-posters svg {
  opacity: 0.5;
}

.no-posters p {
  font-size: 1.2rem;
}

/* Poster container */
.poster-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--gray-100);
  min-height: 0;
}

/* Horizontal mode - posters take more space */
body.rotation-0 .poster-container {
  flex: 3;
  max-height: 75%;
}

.poster-container.single {
  padding: 1rem;
}

/* Horizontal single poster - center with proper sizing */
.poster-container.single.horizontal-single {
  padding: 1rem 2rem;
}

.poster-container.single .poster-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* In horizontal single mode, constrain width for better appearance */
.poster-container.single.horizontal-single .poster-image {
  max-width: 80%;
}

/* Slideshow */
.poster-container.slideshow {
  position: relative;
}

.poster-container.slideshow.horizontal-carousel {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.posters-track {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
  width: 100%;
  gap: 0.5rem;
}

.poster-slide {
  position: absolute;
  width: calc(100% / 3);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  will-change: transform, opacity;
  transition: transform 0.6s ease, opacity 0.6s ease;
  box-sizing: border-box;
  padding: 0 0.25rem;
}

.poster-slide.visible {
  opacity: 1;
}

.poster-slide .poster-image {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
}

/* Horizontal mode - make poster images slightly larger */
body.rotation-0 .poster-slide .poster-image {
  max-width: 98%;
  max-height: 98%;
}

body.rotation-0 .poster-container.single .poster-image {
  max-width: 85%;
  max-height: 90%;
}

/* Original vertical slideshow styles */
.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition) ease-in-out;
  pointer-events: none;
}

.slide.active {
  opacity: 1;
  pointer-events: auto;
}

.slide .poster-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Progress dots */
.progress-dots {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  border: 2px solid var(--primary);
  transition: all 0.3s ease;
}

.dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

/* Events section */
.events-section {
  background: var(--white);
  padding: 1.5rem;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
  max-height: 40%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Events section when no posters - taller to show more events */
.events-section.events-large {
  max-height: 70%;
}

/* Horizontal mode (rotation 0) - smaller events section, 4 events visible (2x2 grid) */
body.rotation-0 .events-section {
  flex: 1;
  max-height: 28%;
  padding: 1rem 1.5rem;
}

body.rotation-0 .events-title {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.events-title {
  font-size: 1.1rem;
  color: var(--primary);
  margin-bottom: 1rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* Events list - FIXED HEIGHT to contain animation */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden; /* Critical - contains all animation */
  flex: 1;
  position: relative;
  /* Calculate height for exactly 4 items (item ~55px + 12px gap = ~67px each) */
  min-height: 270px; /* 4 items * ~67px */
  max-height: 270px;
}

/* Horizontal mode - 4 events visible (2 rows x 2 columns), with vertical sliding */
body.rotation-0 .events-list {
  min-height: 155px; /* 2 rows * 75px + 5px gap */
  max-height: 155px;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

/* When no posters (events-large class), show up to 10 events */
.events-section.events-large .events-list {
  min-height: 670px; /* 10 items * ~67px */
  max-height: 670px;
}

/* Horizontal mode with no posters - 2x2 grid (4 events) */
body.rotation-0 .events-section.events-large .events-list {
  min-height: 155px;
  max-height: 155px;
}

/* Horizontal mode - event items take 50% width (2 per row) */
body.rotation-0 .events-list .event-item {
  position: absolute;
  width: 50%; /* Full 50% width */
  height: 75px; /* Fixed height for consistent animation */
  min-height: 75px;
  max-height: 75px;
  flex: 0 0 auto;
  opacity: 0;
  will-change: transform, opacity;
  /* Only animate Y position, not X */
  transition: transform 0.6s ease-in-out, opacity 0.3s ease-in-out, left 0s;
  top: 0;
  left: 0;
  padding: 0 0.25rem;
  box-sizing: border-box;
}

/* Horizontal mode - visible events positioned in 2x2 grid */
body.rotation-0 .events-list .event-item.visible {
  opacity: 1;
}

.events-carousel {
  position: relative;
  overflow: hidden; /* Contains sliding elements */
  height: 100%;
}

/* For carousel, items are absolutely positioned by JS */
.events-list .event-item {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  opacity: 0;
  will-change: transform, opacity;
}

.events-list .event-item.visible {
  opacity: 1;
}

.event-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.5rem;
  border-radius: 8px;
  background: var(--gray-100);
  transition: background 0.2s ease;
  /* Isolate transforms */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Horizontal mode - slightly smaller event items */
body.rotation-0 .event-item {
  padding: 0.4rem 0.5rem;
  gap: 0.75rem;
}

body.rotation-0 .event-date {
  padding: 0.3rem 0.5rem;
  min-width: 60px;
}

body.rotation-0 .event-day {
  font-size: 0.7rem;
}

body.rotation-0 .event-time {
  font-size: 0.85rem;
}

body.rotation-0 .event-text {
  font-size: 0.9rem;
}

.event-item:hover {
  background: var(--gray-200);
}

.event-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--primary);
  color: white;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  min-width: 70px;
}

.event-day {
  font-size: 0.75rem;
  font-weight: 500;
}

.event-time {
  font-size: 0.9rem;
  font-weight: 600;
}

.event-text {
  flex: 1;
  color: var(--gray-700);
  font-size: 0.95rem;
}

.no-events {
  text-align: center;
  color: var(--gray-500);
  padding: 1rem;
}

/* Scrollbar styling */
.events-section::-webkit-scrollbar {
  width: 6px;
}

.events-section::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 3px;
}

.events-section::-webkit-scrollbar-thumb {
  background: var(--gray-500);
  border-radius: 3px;
}

.events-section::-webkit-scrollbar-thumb:hover {
  background: var(--gray-700);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .board-header {
    padding: 0.75rem;
  }

  .school-logo {
    height: 32px;
  }

  .events-section {
    padding: 1rem;
    max-height: 35%;
  }

  .events-title {
    font-size: 1rem;
  }

  .event-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .event-date {
    flex-direction: row;
    gap: 0.5rem;
    min-width: auto;
  }
}
