* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --dark-900: #121214;
  --dark-800: #1a1b20;
  --dark-700: #27272a;
  --accent: #00d4bd;
  --accent-dim: rgba(0, 212, 189, 0.1);
  --accent-glow: rgba(0, 212, 189, 0.3);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.1);
  --danger-glow: rgba(239, 68, 68, 0.3);
  --padding-screen: 0.75rem;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--dark-900);
  color: white;
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--padding-screen);
  overflow: hidden;
  /* Force landscape layout */
  min-height: 100vh;
}

/* Force landscape layout even in portrait mode */
@media (max-aspect-ratio: 1/1) {
  body {
    transform: rotate(90deg);
    transform-origin: center;
    width: 100vh;
    height: 100vw;
  }
}

.main-container {
  width: 100%;
  height: calc(100vh - (var(--padding-screen) * 2));
  background: var(--dark-800);
  border: 4px solid var(--accent);
  border-radius: 1.5rem;
  display: flex;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s ease-in-out, border-color 0.3s ease-in-out;
}

/* LEFT PANEL */
.left-panel {
  width: 55%;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  border-right: 1px solid #333;
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 1s ease-in-out;
}

.left-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.75) 25%,
    rgba(0, 0, 0, 0.65) 40%,
    rgba(0, 0, 0, 0.5) 55%,
    rgba(0, 0, 0, 0.75) 100%
  );
  pointer-events: none;
  z-index: 1;
}

.left-panel > * {
  position: relative;
  z-index: 2;
}

.clock-display {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.date-display {
  color: #9ca3af;
  font-size: clamp(0.875rem, 1.5vw, 1.125rem);
  font-weight: 500;
  margin-bottom: 2rem;
}

.capacity-info {
  display: flex;
  align-items: center;
  color: #d1d5db;
  margin-bottom: 0.75rem;
  font-size: clamp(0.875rem, 1.2vw, 1rem);
}

.capacity-info i {
  margin-right: 0.75rem;
  font-size: 1rem;
}

.room-name {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 500;
  color: #f3f4f6;
  margin-bottom: 0.5rem;
  line-height: 1.1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: calc(1.1em * 2);
  transition: font-size 0.3s ease;
}

/* Di layar besar, font tetap sama untuk semua panjang teks */
.room-name.medium-text,
.room-name.long-text,
.room-name.very-long-text {
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.room-tags {
  display: none;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.room-tag {
  padding: 0.375rem 0.875rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 0.875rem;
  color: #9ca3af;
}

.status-section {
  margin-top: 2rem;
  margin-bottom: auto;
}

.status-box {
  border: 2px solid var(--accent);
  border-radius: 1.5rem;
  padding: 1.25rem 1.5rem;
  width: 100%;
  background: linear-gradient(135deg, var(--dark-800) 0%, var(--dark-700) 100%);
  position: relative;
  overflow: hidden;
}

.status-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(
    circle at top left,
    var(--accent-dim),
    transparent
  );
  pointer-events: none;
}

.status-box.available {
  box-shadow: 0 0 30px var(--accent-glow);
}

.status-box.occupied {
  border-color: var(--danger);
  box-shadow: 0 0 30px var(--danger-glow);
}

.status-box.occupied::before {
  background: radial-gradient(
    circle at top left,
    var(--danger-dim),
    transparent
  );
}

.status-box.occupied .status-subtitle {
  color: var(--danger);
}

.status-title {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  margin-bottom: 0.25rem;
  position: relative;
}

.status-subtitle {
  color: var(--accent);
  font-size: clamp(0.875rem, 1.5vw, 1.125rem);
  position: relative;
}

.status-box.occupied .status-subtitle {
  color: white;
}

.footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 1.5rem;
}

.qr-button {
  width: clamp(4rem, 8vw, 7rem) !important;
  height: clamp(4rem, 8vw, 7rem) !important;
  border-radius: 0.5rem;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem !important;
  border: 2px solid var(--accent);
  flex-shrink: 0;
  min-width: 4rem;
  min-height: 4rem;
  max-width: 8rem;
  max-height: 8rem;
}

.qr-button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* Connection Indicator */
.connection-indicator {
  width: clamp(0.75rem, 1.5vw, 1rem);
  height: clamp(0.75rem, 1.5vw, 1rem);
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
  transition: all 0.3s ease;
  flex-shrink: 0;
  align-self: flex-end;
}

.connection-indicator.connected {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.connection-indicator.disconnected {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
  animation: pulse-red 2s infinite;
}

.connection-indicator.refreshing {
  background: #fbbf24;
  box-shadow: 0 0 10px #fbbf24;
  animation: pulse-yellow 1s infinite;
}

@keyframes pulse-red {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes pulse-yellow {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

#qrcode {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 0.25rem;
  box-sizing: border-box;
}

#qrcode img {
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: contain;
  margin: 0 auto;
}

/* RIGHT PANEL - TIMELINE */
.right-panel {
  width: 45%;
  background: var(--dark-800);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.timeline-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 1rem 8%;
  position: relative;
}

.timeline-container::-webkit-scrollbar {
  width: 4px;
}

.timeline-container::-webkit-scrollbar-track {
  background: var(--dark-800);
}

.timeline-container::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 2px;
}

.timeline-grid {
  position: relative;
  margin-top: 1rem;
}

.timeline-slot {
  height: 5rem;
  border-bottom: 1px solid #333;
  display: flex;
  position: relative;
}

.time-label {
  width: 4rem;
  text-align: right;
  padding-right: 1rem;
  color: #9ca3af;
  font-weight: 500;
  padding-top: 0.25rem;
  font-size: 0.8rem;
}

.time-line {
  flex: 1;
  border-top: 1px solid #333;
}

/* Event Cards */
.event-card {
  position: absolute;
  left: 4rem;
  right: 0;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  z-index: 5;
  overflow: hidden;
}

.event-card.past {
  background: #9ca3af;
  color: black;
  opacity: 0.85;
  border: 1px solid #6b7280;
}

.event-card.upcoming {
  background: white;
  color: black;
  border: 2px solid var(--accent);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.event-card.ongoing {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
  color: white;
  border: 2px solid #fca5a5;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), 0 0 40px rgba(239, 68, 68, 0.3);
  animation: pulse-ongoing 2s ease-in-out infinite;
}

@keyframes pulse-ongoing {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.6), 0 0 40px rgba(239, 68, 68, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.8), 0 0 60px rgba(239, 68, 68, 0.5);
  }
}

.event-card.ongoing .event-name,
.event-card.ongoing .event-time,
.event-card.ongoing .event-purpose {
  color: white;
  opacity: 1;
}

.event-card.past .event-name,
.event-card.upcoming .event-name {
  font-size: 1rem;
  font-weight: 800;
}

.event-card.ongoing .event-name {
  font-size: 1rem;
  font-weight: 800;
  color: white;
}

.event-card.past .event-time,
.event-card.upcoming .event-time {
  font-size: 0.85rem;
  font-weight: 800;
}

.event-card.ongoing .event-time {
  font-size: 0.85rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
}

.event-card.past .event-purpose,
.event-card.upcoming .event-purpose {
  font-size: 0.8rem;
  font-weight: 800;
}

.event-card.ongoing .event-purpose {
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.85);
}

.event-name {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-time {
  font-size: 0.7rem;
  opacity: 0.7;
}

.event-card.past .event-name {
  color: #1f2937;
}

.event-card.past .event-time {
  color: #374151;
}

.event-purpose {
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-card.past .event-purpose {
  color: #374151;
}

/* Current Time Indicator */
.current-time-indicator {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  z-index: 1;
  pointer-events: none;
}

.current-time-label {
  position: absolute;
  top: 50%;
  right: calc(100% + 0.5rem);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.75rem;
  background: transparent;
  padding: 0;
  z-index: 30;
  transform: translateY(-50%);
  white-space: nowrap;
}

.current-time-dot {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.current-time-line {
  width: 100%;
  height: 2px;
  background: transparent;
  border-top: 2px dashed var(--accent);
  opacity: 1;
  margin-left: 0.25rem;
}

/* RESPONSIVE - Tablet & Mobile Portrait */
@media (max-width: 1024px) {
  :root {
    --padding-screen: 0.5rem;
  }

  /* Keep landscape layout */
  .main-container {
    flex-direction: row;
    border-radius: 1rem;
  }

  .left-panel {
    width: 40%;
    padding: 1rem;
  }

  .right-panel {
    width: 60%;
  }

  .timeline-container {
    padding: 0.75rem 0.75rem 0.75rem 5%;
  }

  .time-label {
    width: 3.5rem;
    font-size: 0.75rem;
  }

  .event-card {
    left: 3.5rem;
    right: 0;
  }

  .current-time-label {
    font-size: 0.625rem;
    right: calc(100% + 0.25rem);
  }
}

  .qr-button {Tablet Medium */
@media (max-width: 768px) {
  .left-panel {
    width: 38%;
    padding: 0.875rem;
  }

  .right-panel {
    width: 62%;
  }

  .qr-button {
    width: 4.5rem !important;
    height: 4.5rem !important;
    min-width: 3rem;
    min-height: 3rem;
  }

  .clock-display {
    font-size: 2.25rem;
  }

  .room-name {
    font-size: 1.75rem;
  }

  /* Mulai auto-resize di tablet */
  .room-name.medium-text {
    font-size: 1.625rem;
  }

  .room-name.long-text {
    font-size: 1.5rem;
  }

  .room-name.very-long-text {
    font-size: 1.375rem;
  }

  .status-box {
    padding: 0.875rem 1rem;
  }
}

/* RESPONSIVE - Mobile Small */
@media (max-width: 480px) {
  .clock-display {
    font-size: 2rem;
  }

  .room-name {
    font-size: 1.5rem;
  }

  /* Auto-resize lebih agresif di mobile */
  .room-name.medium-text {
    font-size: 1.35rem;
  }

  .room-name.long-text {
    font-size: 1.2rem;
  }

  .room-name.very-long-text {
    font-size: 1.05rem;
  }

  .status-box {
    padding: 1rem;
    border-radius: 1rem;
  }

  .qr-button {
    width: 3.5rem !important;
    height: 3.5rem !important;
    min-width: 2.5rem !important;
    min-height: 2.5rem !important;
    padding: 0.15rem !important;
  }

  .timeline-slot {
    height: 4rem;
  }

  .current-time-label {
    font-size: 0.5rem;
    padding: 0.125rem 0.25rem;
    right: calc(100% + 0.15rem);
    max-width: 2.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .left-panel {
    width: 35%;
    padding: 0.75rem;
  }

  .right-panel {
    width: 65%;
  }

  .clock-display {
    font-size: 1.75rem;
  }

  .room-name {
    font-size: 1.25rem;
  }

  /* Auto-resize maksimal di mobile kecil */
  .room-name.medium-text {
    font-size: 1.15rem;
  }

  .room-name.long-text {
    font-size: 1.05rem;
  }

  .room-name.very-long-text {
    font-size: 0.95rem;
  }

  .status-box {
    padding: 0.75rem;
    border-radius: 1rem;
  }

  .qr-button {
    width: 4.5rem !important;
    height: 4.5rem !important;
  }
}

/* Large Desktop Screens */
@media (min-width: 1920px) {
  .qr-button {
    width: 8rem !important;
    height: 8rem !important;
    max-width: 10rem;
    max-height: 10rem;
  }

  .left-panel {
    padding: 2.5rem;
  }

  .timeline-container {
    padding: 1.5rem 1.5rem 1.5rem 10%;
  }
}

/* Small Height Devices */
@media (max-height: 600px) {
  .left-panel {
    padding: 0.75rem;
  }

  .status-section {
    margin-top: 1rem;
  }

  .footer-actions {
    padding-top: 0.75rem;
  }

  .qr-button {
    width: 4rem !important;
    height: 4rem !important;
  }

  .clock-display {
    margin-bottom: 0.25rem;
  }

  .date-display {
    margin-bottom: 1rem;
  }
  .status-box {
    padding: 0.75rem;
    border-radius: 1rem;
  }

  .capacity-info {
    font-size: 0.75rem;
  }

  .capacity-info i {
    font-size: 0.75rem;
  }
}

/* RESPONSIVE - Very Small Mobile */
@media (max-width: 360px) {
  .qr-button {
    width: 3rem !important;
    height: 3rem !important;
    min-width: 2.25rem !important;
    min-height: 2.25rem !important;
    padding: 0.125rem !important;
  }

  #qrcode {
    padding: 0.15rem;
  }

  .clock-display {
    font-size: 1.5rem;
  }

  .room-name {
    font-size: 1.125rem;
  }

  /* Auto-resize sangat agresif di mobile sangat kecil */
  .room-name.medium-text {
    font-size: 1rem;
  }

  .room-name.long-text {
    font-size: 0.9rem;
  }

  .room-name.very-long-text {
    font-size: 0.8rem;
  }

  .status-box {
    padding: 0.625rem;
  }

  .footer-actions {
    padding-top: 0.75rem;
  }
}

/* Landscape Mode - Optimize for all screens */
@media (max-height: 500px) and (orientation: landscape) {
  .main-container {
    flex-direction: row;
  }

  .left-panel {
    width: 50%;
    border-right: 1px solid #333;
    border-bottom: none;
    padding: 1rem;
  }

  .right-panel {
    width: 50%;
  }

  .date-display {
    margin-bottom: 0.5rem;
  }

  .status-section {
    margin-top: 0.5rem;
  }

  .footer-actions {
    padding-top: 0.5rem;
  }
}
