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

body {
  background: #1a1a2e;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== HEADER ==================== */

header {
  background: #16213e;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0f3460;
}

body.login-mode header {
  display: none;
}

h1 {
  font-size: 1.5rem;
  color: #e94560;
}

.status {
  display: flex;
  gap: 20px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #555;
}

.status-dot.connected {
  background: #4ade80;
  box-shadow: 0 0 10px #4ade80;
}

.status-dot.connecting {
  background: #fbbf24;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==================== MAIN ==================== */

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ==================== SCREENS ==================== */

.screen {
  display: none;
  width: 100%;
  max-width: 900px;
}

.screen.active {
  display: block;
}

.screen-title {
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: #888;
}

.screen-title span {
  color: #e94560;
}

/* ==================== CARDS ==================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.card:hover {
  border-color: #e94560;
  transform: translateY(-2px);
}

.card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card.disabled:hover {
  border-color: #0f3460;
  transform: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-online {
  background: #065f46;
  color: #4ade80;
}

.badge-offline {
  background: #7f1d1d;
  color: #f87171;
}

.badge-ready {
  background: #065f46;
  color: #4ade80;
}

.badge-busy {
  background: #78350f;
  color: #fbbf24;
}

.badge-empty {
  background: #374151;
  color: #9ca3af;
}

.card-info {
  font-size: 0.85rem;
  color: #888;
}

.card-info div {
  margin: 4px 0;
}

.card-info strong {
  color: #aaa;
}

/* ==================== BUTTONS ==================== */

.back-btn {
  background: transparent;
  border: 1px solid #0f3460;
  color: #888;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.back-btn:hover {
  border-color: #e94560;
  color: #eee;
}

.end-session-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: #dc2626;
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.end-session-btn:hover {
  background: #b91c1c;
}

.fullscreen-btn {
  position: absolute;
  bottom: 10px;
  right: 130px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #444;
  color: white;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-btn svg {
  width: 20px;
  height: 20px;
}

.fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: #e94560;
}

/* Fullscreen mode */
.video-container:fullscreen,
.video-container:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container:fullscreen video,
.video-container:-webkit-full-screen video {
  /* Upscale to fill screen while maintaining aspect ratio */
  width: 100%;
  height: 100%;
  object-fit: contain;  /* contain = keep aspect ratio, cover = fill & crop */
  /* Smooth upscaling (reduces pixelation on large screens) */
  image-rendering: auto;  /* auto = smooth, pixelated = sharp pixels */
}

.video-container:fullscreen .no-video,
.video-container:-webkit-full-screen .no-video {
  width: 100%;
  height: 100%;
}

/* ==================== EMPTY STATE ==================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* ==================== VIDEO ==================== */

.video-container {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(233, 69, 96, 0.3);
}

video {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 200px);
}

.video-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: monospace;
}

.drone-info-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.drone-info-overlay .drone-name {
  color: #e94560;
  font-weight: 600;
}

.no-video {
  width: 640px;
  height: 480px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #0a0a15;
  color: #666;
}

.no-video svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.5;
}

/* ==================== FOOTER ==================== */

footer {
  background: #16213e;
  padding: 10px 20px;
  text-align: center;
  font-size: 0.8rem;
  color: #666;
  border-top: 1px solid #0f3460;
}

footer.hidden {
  display: none;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.stat {
  font-family: monospace;
}

.stat-label {
  color: #888;
}

.telemetry-row {
  border-top: 1px solid #333;
  padding-top: 5px;
  gap: 20px;
}

.telemetry-row .stat-label {
  color: #e94560;
}

.stat-value {
  color: #4ade80;
}

/* ==================== GAMEPAD PANEL ==================== */

.gamepad-panel {
  margin-top: 30px;
  padding: 20px;
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 8px;
}

/* Not connected state */
.gamepad-not-connected {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px;
}

.gamepad-icon {
  color: #666;
  margin-bottom: 12px;
}

.gamepad-message {
  font-size: 1rem;
  color: #888;
  margin-bottom: 16px;
}

.gamepad-activate-btn {
  background: #e94560;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.gamepad-activate-btn:hover {
  background: #d63a54;
}

.gamepad-activate-btn:active {
  transform: scale(0.98);
}

.gamepad-hint {
  font-size: 0.8rem;
  color: #555;
  margin-top: 12px;
}

/* Connected state */
.gamepad-connected {
  padding: 5px;
}

.gamepad-connected-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #0f3460;
}

.gamepad-connected-icon {
  width: 36px;
  height: 36px;
  background: #065f46;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4ade80;
}

.gamepad-connected-label {
  font-size: 0.8rem;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gamepad-connected-name {
  font-size: 0.95rem;
  color: #ccc;
  margin-top: 2px;
}

.gamepad-values {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .gamepad-values {
    grid-template-columns: repeat(3, 1fr);
  }
}

.gamepad-value-group {
  background: #0f3460;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}

.gamepad-value-label {
  font-size: 0.7rem;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.gamepad-value {
  font-family: monospace;
  font-size: 1.1rem;
  color: #4ade80;
  font-weight: 600;
}

/* ==================== LOGIN ==================== */

.login-container {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  margin: 0 auto;
}

.login-logo {
  font-size: 2.5rem;
  font-weight: 700;
  color: #e94560;
  margin-bottom: 8px;
}

.login-subtitle {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: #0f3460;
  border: 2px solid #1a4980;
  border-radius: 6px;
  color: #eee;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #e94560;
}

.form-group input::placeholder {
  color: #555;
}

.login-error {
  color: #f87171;
  font-size: 0.85rem;
  min-height: 20px;
}

.login-btn {
  background: #e94560;
  border: none;
  padding: 14px 24px;
  border-radius: 6px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.login-btn:hover {
  background: #d63a54;
}

.login-btn:active {
  transform: scale(0.98);
}

.login-btn:disabled {
  background: #555;
  cursor: not-allowed;
}

/* ==================== ADMIN PANEL ==================== */

.admin-header, .stations-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.admin-btn {
  background: #0f3460;
  border: 1px solid #1a4980;
  color: #e94560;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.admin-btn:hover {
  background: #1a4980;
  border-color: #e94560;
}

.admin-section {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.section-header {
  margin-bottom: 16px;
}

.section-header h3 {
  color: #e94560;
  font-size: 1.1rem;
}

.create-token-form .form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.create-token-form .form-group {
  flex: 1;
  min-width: 180px;
}

.create-token-form .form-group label {
  display: block;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 6px;
}

.create-token-form .form-group input {
  width: 100%;
  padding: 10px 14px;
  background: #0f3460;
  border: 2px solid #1a4980;
  border-radius: 6px;
  color: #eee;
  font-size: 0.95rem;
}

.create-token-form .form-group input:focus {
  outline: none;
  border-color: #e94560;
}

.btn-primary {
  background: #e94560;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:hover {
  background: #d63a54;
}

.new-token-display {
  margin-top: 16px;
  padding: 16px;
  background: #0f3460;
  border-radius: 6px;
  border: 2px solid #4ade80;
}

.token-warning {
  color: #fbbf24;
  font-size: 0.85rem;
  margin-bottom: 10px;
  font-weight: 600;
}

.token-value {
  font-family: monospace;
  font-size: 0.9rem;
  color: #4ade80;
  background: #1a1a2e;
  padding: 12px;
  border-radius: 4px;
  word-break: break-all;
  margin-bottom: 10px;
}

.btn-copy {
  background: #065f46;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  color: #4ade80;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-copy:hover {
  background: #047857;
}

.tokens-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.token-card {
  background: #0f3460;
  border-radius: 6px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.token-card.revoked {
  opacity: 0.5;
  border: 1px solid #7f1d1d;
}

.token-info {
  flex: 1;
  min-width: 200px;
}

.token-station-name {
  font-weight: 600;
  font-size: 1rem;
  color: #eee;
  margin-bottom: 4px;
}

.token-station-id {
  font-size: 0.85rem;
  color: #888;
  font-family: monospace;
}

.token-meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 6px;
}

.token-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.online {
  background: #065f46;
  color: #4ade80;
}

.status-badge.offline {
  background: #374151;
  color: #9ca3af;
}

.status-badge.revoked {
  background: #7f1d1d;
  color: #f87171;
}

.token-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  background: #1a4980;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  color: #eee;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-action:hover {
  background: #2563eb;
}

.btn-action.danger {
  background: #7f1d1d;
  color: #f87171;
}

.btn-action.danger:hover {
  background: #991b1b;
}

.btn-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== RECORDING ==================== */

.rec-btn {
  position: absolute;
  bottom: 10px;
  right: 200px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #444;
  color: #ccc;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.rec-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: #e94560;
}

.rec-btn.rec-active {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  animation: pulse 1s infinite;
}

.recording-indicator {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  z-index: 10;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  animation: pulse 1s infinite;
}

.rec-label {
  color: #dc2626;
  font-weight: 600;
}

.rec-timer {
  color: #eee;
  font-family: monospace;
}

.rec-mic {
  background: #065f46;
  color: #4ade80;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* ==================== UPLOAD OVERLAY ==================== */

.upload-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  border-top: 2px solid #e94560;
}

.upload-progress-bar {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  background: #e94560;
  border-radius: 3px;
  transition: width 0.3s;
}

.upload-text {
  color: #eee;
  font-size: 0.9rem;
}

.upload-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.upload-overlay.upload-complete {
  border-top-color: #4ade80;
}

.upload-overlay.upload-complete .upload-progress-fill {
  background: #4ade80;
}

.upload-overlay.upload-complete .upload-text {
  color: #4ade80;
}

.upload-overlay.upload-error {
  border-top-color: #f87171;
}

.upload-overlay.upload-error .upload-progress-fill {
  background: #f87171;
}

.upload-overlay.upload-error .upload-text {
  color: #f87171;
}

.upload-link-btn {
  background: #065f46;
  color: #4ade80;
  padding: 6px 14px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.upload-link-btn:hover {
  background: #047857;
}

.upload-dismiss-btn {
  background: #374151;
  border: none;
  color: #eee;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.upload-dismiss-btn:hover {
  background: #4b5563;
}

.upload-retry-btn {
  background: #7f1d1d;
  border: none;
  color: #f87171;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.upload-retry-btn:hover {
  background: #991b1b;
}
