/* ParunaCam — Dark Theme UI */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-glass-hover: rgba(255, 255, 255, 0.1);
  --text-primary: #f0f0f5;
  --text-secondary: #8b8b9e;
  --text-muted: #5a5a6e;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --danger: #ef4444;
  --success: #22c55e;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Screens */
.screen {
  display: none;
  height: 100dvh;
  width: 100%;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* ─── Login Screen ─── */
#login-screen {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at 50% 30%, #1a1035 0%, #0a0a0f 70%);
}

.login-container {
  width: 100%;
  max-width: 340px;
  padding: 24px;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.logo-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 0 40px var(--accent-glow);
  animation: pulse-glow 3s ease-in-out infinite;
}

.logo-icon {
  font-size: 36px;
  filter: grayscale(0);
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-form {
  margin-top: 8px;
}

.input-group {
  display: flex;
  gap: 10px;
}

#password-input {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  backdrop-filter: blur(20px);
}

#password-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

#password-input::placeholder {
  color: var(--text-muted);
}

.btn-login {
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-login:active {
  transform: scale(0.96);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  animation: shake 0.4s ease;
}

/* ─── Camera Screen ─── */
#camera-screen {
  background: var(--bg-primary);
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s ease;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.header-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:active {
  background: var(--bg-glass-hover);
  color: var(--danger);
}

/* Video */
.video-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
  overflow: hidden;
}

.video-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

#video-stream {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2;
  transition: opacity 0.3s ease;
}

.video-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
  color: var(--text-secondary);
}

.overlay-content p {
  margin-top: 12px;
  font-size: 14px;
}

.video-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  z-index: 3;
  animation: pulse-badge 2s ease-in-out infinite;
}

.video-badge.live {
  background: var(--danger);
  color: white;
}

.video-badge.connected {
  background: var(--success);
  color: white;
  animation: none;
}

.video-badge.error {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  animation: none;
}

.btn-reconnect {
  margin-top: 16px;
  padding: 10px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-reconnect:active {
  transform: scale(0.96);
  background: var(--accent-hover);
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

/* Controls */
.controls {
  padding: 12px 16px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.control-group {
  display: flex;
  justify-content: center;
  gap: 24px;
}

.btn-control {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  backdrop-filter: blur(20px);
  min-width: 72px;
}

.btn-control:active {
  background: var(--bg-glass-hover);
  transform: scale(0.96);
}

.btn-control.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-control.muted {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.control-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Connection Info */
.connection-info {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.status-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Animations ─── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(139, 92, 246, 0.15); }
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

/* ─── Landscape ─── */
@media (orientation: landscape) {
  .login-container {
    max-width: 400px;
  }
  
  .controls {
    padding: 8px 16px 12px;
  }
}