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

/* ── Login Overlay ── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 17, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-card {
  background: #161922;
  border: 1px solid #2d3148;
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #e2e8f0;
}

.login-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #e2e8f0;
}

.login-subtitle {
  font-size: 0.85rem;
  color: #9ca3af;
  line-height: 1.4;
}

.login-subtitle strong { color: #e2e8f0; }

.login-input {
  background: #0f1117;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #e2e8f0;
  padding: 10px 12px;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

.login-input:focus { border-color: #16a34a; }

.login-btn {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s, opacity 0.2s;
}

.login-btn:hover { background: #15803d; }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-link-btn {
  background: none;
  border: none;
  color: #60a5fa;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-align: center;
  text-decoration: underline;
}

.login-link-btn:hover { color: #93c5fd; }

.login-error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.4);
  border-radius: 6px;
  color: #fca5a5;
  font-size: 0.82rem;
  padding: 8px 12px;
}

.login-countdown {
  font-size: 0.8rem;
  color: #9ca3af;
  text-align: center;
}

/* ── OTP digit inputs ── */
.otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.otp-digit {
  width: 56px;
  height: 60px;
  background: #0f1117;
  border: 2px solid #374151;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  caret-color: #16a34a;
}

.otp-digit:focus { border-color: #16a34a; }
.otp-digit.filled { border-color: #4ade80; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Left: image viewer ── */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0f1117;
  overflow: hidden;
}

.viewer-header {
  display: none;
}

.viewer-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px;
}

#screenshot-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid #1e2133;
  box-shadow: 0 4px 32px rgba(0,0,0,0.5);
  display: none;
}

.no-image {
  text-align: center;
  color: #374151;
}
.no-image svg { margin-bottom: 12px; opacity: 0.4; }
.no-image p { font-size: 0.85rem; }

/* ── Mode Buttons ── */
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-btn {
  padding: 8px 16px;
  border: 2px solid #374151;
  border-radius: 6px;
  background: #0f1117;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 0.2s, background 0.15s;
  width: 100%;
  text-align: center;
}

.mode-btn:hover {
  background: #1e2133;
}

.mode-btn.active-mode {
  border-color: #16a34a;
  background: #1e2133;
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.3);
}

.mode-btn.go-live {
  border-color: #dc2626;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.3);
}

/* ── Slider Container ── */
.slider-container {
  padding: 0 24px 16px;
  border-top: 1px solid #2d3148;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.slider-container.visible {
  display: flex;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

:root {
  --slider-label-width: 220px;
  --slider-time-width: 80px;
  --slider-wrapper-gap: 12px;
}

.slider-label-group {
  min-width: var(--slider-label-width);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-label {
  font-size: 0.75rem;
  color: #9ca3af;
}

.slider-sub-label {
  font-size: 0.715rem;
  color: #ffffff;
  line-height: 1.2;
  min-height: 0.8rem;
  white-space: pre-line;
}

.slider-track {
  flex: 1;
  height: 20px;
  background: #1e2133;
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 2px;
  overflow: visible;
}

.slider-track .oee-bar {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: auto;
  transform: translateY(-50%);
  display: flex;
  gap: 0;
  padding: 0;
  z-index: 1;
}

.slider-track .oee-block {
  flex: 1;
  border-radius: 1px;
}

.slider-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  background: #16a34a;
  border: 2px solid #000;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 10px rgba(22, 163, 74, 0.5);
  z-index: 20;
}

.slider-thumb:active {
  cursor: grabbing;
}

.slider-time-display {
  font-size: 0.8rem;
  color: #6b7280;
  min-width: var(--slider-time-width);
  text-align: right;
}

.slider-ticks {
  position: relative;
  margin-left: 0;
  margin-right: 0;
  padding: 0;
  font-size: 0.65rem;
  color: #ffffff;
  min-height: 42px;
}

.slider-tick-mark {
  position: absolute;
  top: 0;
  width: 1px;
  background: #4b5563;
  opacity: 0.6;
  transform: translateX(-50%);
}

.slider-tick-mark.minor {
  height: 6px;
}

.slider-tick-mark.major {
  height: 10px;
  opacity: 0.9;
}

.slider-ticks span {
  position: absolute;
  top: 12px;
  display: block;
  transform: translateX(-50%) rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
}

/* ── OEE Graph (embedded in slider) ── */
.oee-bar {
  display: flex;
  height: 100%;
  gap: 0;
  width: 100%;
}

.oee-block {
  flex: 1;
  height: 5px;
  border-radius: 1px;
  transition: background 0.1s;
}

.oee-block.recorded {
  background: #16a34a;
}

.oee-block.empty {
  background: #dc2626;
}

/* ── Right: sidebar ── */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #1a1d27;
  border-left: 1px solid #2d3148;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-section {
  padding: 16px;
}
.sidebar-section + .sidebar-section {
  border-top: 1px solid #2d3148;
}
.sidebar-section h2 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b7280;
  margin-bottom: 12px;
}

/* ── Logout section — space always reserved at top of sidebar ── */
.sidebar-logout {
  border-bottom: 1px solid #2d3148;
  visibility: hidden; /* space reserved; button hidden until login is enabled */
}
.sidebar-logout.visible {
  visibility: visible;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid #374151;
  border-radius: 6px;
  color: #9ca3af;
  font-size: 0.82rem;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.logout-btn:hover {
  background: #1f2937;
  color: #e2e8f0;
  border-color: #4b5563;
}
.logout-btn svg {
  flex-shrink: 0;
}

/* ── Service buttons ── */
.service-btn {
  width: 100%;
  background: #0f1117;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  border: 2px solid #374151;
  transition: border-color 0.2s, background 0.15s;
  position: relative;
}
.service-btn:last-child { margin-bottom: 0; }

.service-btn.selected {
  background: #1e2133;
  outline: none;
}
.service-btn.selected.online  { border-color: #16a34a; }
.service-btn.selected.offline { border-color: #dc2626; }
.service-btn:hover { background: #1e2133; }

.service-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #c9d1e0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.online  .status-dot { background: #16a34a; box-shadow: 0 0 6px #16a34a; }
.offline .status-dot { background: #dc2626; box-shadow: 0 0 6px #dc2626; }
.unknown .status-dot { background: #4b5563; }

.service-meta {
  font-size: 0.7rem;
  color: #6b7280;
  margin-top: 4px;
  padding-left: 16px;
}

/* ── Device status ── */
.device-card {
  background: #0f1117;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid #2d3148;
}
.device-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}
.device-status-row .status-dot { width: 9px; height: 9px; }
.device-time {
  font-size: 0.7rem;
  color: #6b7280;
  margin-top: 6px;
}
.device-name {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 2px;
}

/* ── Media Transport Controls ── */
.media-controls {
  display: none; /* hidden in live mode */
  position: fixed;
  bottom: 0;
  right: 0;
  width: 260px;
  background: #1a1d27;
  border-top: 1px solid #2d3148;
  border-left: 1px solid #2d3148;
  padding: 12px 16px;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  z-index: 50;
}

.media-controls.visible {
  display: flex;
}

.media-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1117;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: 8px 0;
  cursor: pointer;
  color: #9ca3af;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.media-btn svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.media-btn:hover {
  background: #1e2133;
  color: #e2e8f0;
  border-color: #6b7280;
}

.media-btn:active {
  background: #16a34a22;
  border-color: #16a34a;
  color: #16a34a;
}

/* ── Archive Modal/Popup ── */
.archive-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.archive-modal.visible {
  display: flex;
}

.archive-modal-content {
  background: #1a1d27;
  border: 1px solid #2d3148;
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
}

.archive-modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #e2e8f0;
}

.archive-calendar-section,
.archive-shifts-section {
  margin-bottom: 20px;
}

.archive-calendar-label,
.archive-shifts-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 8px;
  display: block;
}

.archive-calendar-inputs {
  display: block;
  margin-bottom: 12px;
}

.archive-calendar-inputs input {
  width: 100%;
  background: #0f1117;
  border: 1px solid #2d3148;
  border-radius: 4px;
  padding: 8px;
  color: #e2e8f0;
  font-size: 0.85rem;
}

.archive-shifts-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archive-shift-btn {
  background: #0f1117;
  border: 2px solid #374151;
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.15s;
  text-align: left;
}

.archive-shift-btn:hover {
  background: #1e2133;
}

.archive-shift-btn.selected {
  border-color: #16a34a;
  background: #1e2133;
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.3);
}

.archive-shift-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #c9d1e0;
}

.archive-shift-time {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 2px;
}

.archive-modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.archive-modal-btn {
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}

.archive-modal-btn.cancel {
  background: #374151;
  color: #e2e8f0;
}

.archive-modal-btn.cancel:hover {
  background: #4b5563;
}

.archive-modal-btn.confirm {
  background: #16a34a;
  color: #fff;
}

.archive-modal-btn.confirm:hover {
  background: #15803d;
}

.archive-modal-btn.confirm:disabled {
  background: #6b7280;
  cursor: not-allowed;
}

/* ── Inactivity Auto-Live Modal ── */
.inactivity-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 120;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.inactivity-modal.visible {
  display: flex;
}

.inactivity-modal-content {
  width: 100%;
  max-width: 460px;
  background: #1a1d27;
  border: 1px solid #2d3148;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.inactivity-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 8px;
}

.inactivity-modal-message {
  font-size: 0.88rem;
  line-height: 1.45;
  color: #9ca3af;
}

.inactivity-modal-message span {
  color: #fca5a5;
  font-weight: 700;
}

.inactivity-modal-buttons {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.inactivity-btn {
  border: none;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.inactivity-btn.stay {
  background: #374151;
  color: #e2e8f0;
}

.inactivity-btn.stay:hover {
  background: #4b5563;
}

.inactivity-btn.live {
  background: #dc2626;
  color: #ffffff;
}

.inactivity-btn.live:hover {
  background: #b91c1c;
}
