@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #0f0a1a;
  --bg2: #1a0f2e;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-hover: rgba(255, 255, 255, 0.1);
  --primary: #a855f7;
  --primary-glow: rgba(168, 85, 247, 0.4);
  --secondary: #06b6d4;
  --secondary-glow: rgba(6, 182, 212, 0.35);
  --accent: #ec4899;
  --accent-glow: rgba(236, 72, 153, 0.35);
  --success: #10b981;
  --danger: #f43f5e;
  --warning: #fbbf24;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --radius: 16px;
  --blur: blur(20px);
}

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

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(168, 85, 247, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(6, 182, 212, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  z-index: -1;
}

.hidden { display: none !important; }

.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Auth */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  border-radius: 24px;
  padding: 44px 36px;
}

.logo { text-align: center; margin-bottom: 36px; }

.logo h1 {
  font-size: 2.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.logo p { color: var(--text-muted); font-size: 0.92rem; margin-top: 8px; }

.tabs {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 28px;
  border: 1px solid var(--glass-border);
}

.tab {
  flex: 1;
  padding: 11px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.25s;
}

.tab.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 7px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 13px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: all 0.25s;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  width: 100%;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px var(--primary-glow); }

.btn-secondary {
  background: var(--glass);
  backdrop-filter: var(--blur);
  color: var(--text);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover { background: var(--glass-hover); border-color: var(--primary); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #e11d48);
  color: white;
}

.btn-accent {
  background: linear-gradient(135deg, var(--secondary), #0891b2);
  color: white;
}

.btn-record {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 0.8rem;
  padding: 8px 12px;
}

.btn-record.off {
  background: rgba(244, 63, 94, 0.12);
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.35);
}

.btn-record .rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: recPulse 1.2s infinite;
}

.btn-record.off .rec-dot {
  background: var(--text-muted);
  animation: none;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 1.1rem;
}

.btn-icon:hover { background: var(--glass-hover); border-color: var(--secondary); }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 14px; text-align: center; }

/* Dashboard */
.dashboard { min-height: 100vh; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--glass-border);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right { display: flex; align-items: center; gap: 14px; }
.user-badge { color: var(--text-muted); font-size: 0.9rem; }

.main-content { max-width: 1140px; margin: 0 auto; padding: 28px; padding-bottom: 90px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

@media (max-width: 768px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  border-radius: 20px;
  padding: 28px;
}

.card h2 { font-size: 1.15rem; margin-bottom: 8px; font-weight: 600; }
.card p.desc { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 22px; }

.code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 24px 0;
}

.code-digit {
  width: 60px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168, 85, 247, 0.1);
  border: 2px solid rgba(168, 85, 247, 0.4);
  border-radius: 14px;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  box-shadow: 0 0 24px var(--primary-glow);
}

.code-input-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 24px 0;
}

.code-input-group input {
  width: 60px;
  height: 68px;
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.code-input-group input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 20px var(--secondary-glow);
}

.session-list { list-style: none; }

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.25s;
}

.session-item:hover {
  border-color: var(--primary);
  background: rgba(168, 85, 247, 0.08);
  transform: translateX(4px);
}

.role-badge {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(168, 85, 247, 0.2);
  color: var(--primary);
  margin-left: 8px;
}

.role-badge.tracker {
  background: rgba(6, 182, 212, 0.2);
  color: var(--secondary);
}

/* Session */
.session-view {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  height: calc(100vh - 73px);
  padding: 18px;
}

@media (max-width: 900px) {
  .session-view { grid-template-columns: 1fr; height: auto; }
}

.map-container {
  border-radius: 20px;
  overflow: hidden;
  min-height: 420px;
  position: relative;
}

#map { width: 100%; height: 100%; min-height: 420px; }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.panel-card {
  border-radius: 18px;
  padding: 18px;
}

.panel-card.flex-grow {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.status-bar { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.action-buttons .btn { flex: 1; min-width: 72px; }

.record-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-controls h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.record-row { display: flex; gap: 8px; flex-wrap: wrap; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 180px;
  max-height: 280px;
}

.chat-msg {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 14px;
  max-width: 88%;
  font-size: 0.9rem;
}

.chat-msg.mine {
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.25);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-msg.theirs {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
}

.chat-msg .sender { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 3px; }

.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }

.chat-input-row input {
  flex: 1;
  padding: 11px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.permission-toggles { display: flex; flex-direction: column; gap: 14px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.9rem; }

.toggle { position: relative; width: 50px; height: 28px; cursor: pointer; }
.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 28px;
  border: 1px solid var(--glass-border);
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: rgba(168, 85, 247, 0.35);
  border-color: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: var(--primary);
}

.call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 26, 0.92);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.call-videos {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  position: relative;
}

.video-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.call-videos video {
  width: 320px;
  max-width: 90vw;
  display: block;
  background: rgba(0, 0, 0, 0.5);
}

.video-wrap .flip-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
}

.call-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.remote-streams {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.stream-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.remote-streams video {
  width: 100%;
  display: block;
  background: rgba(0, 0, 0, 0.4);
  min-height: 140px;
}

.stream-wrap .flip-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
}

.location-info {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.85rem;
  z-index: 500;
}

.location-info span { color: var(--secondary); font-weight: 500; }

.back-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  transition: all 0.2s;
}

.back-btn:hover { color: var(--primary); border-color: var(--primary); }

.empty-state { text-align: center; color: var(--text-muted); padding: 36px; font-size: 0.9rem; }

.tracking-active {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--success);
}

.pulse {
  width: 10px;
  height: 10px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

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

.toast {
  position: fixed;
  top: 80px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 14px;
  z-index: 2000;
  font-size: 0.9rem;
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.recordings-list {
  list-style: none;
  max-height: 160px;
  overflow-y: auto;
}

.recordings-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 0.82rem;
}

.recordings-list a {
  color: var(--secondary);
  text-decoration: none;
}

.recordings-list a:hover { text-decoration: underline; }

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px 14px;
  z-index: 200;
  border-top: 1px solid var(--glass-border);
}

.nav-item {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 14px;
  transition: all 0.25s;
}

.nav-item .nav-icon { font-size: 1.3rem; }

.nav-item.active {
  background: rgba(168, 85, 247, 0.2);
  color: var(--primary);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.nav-item:hover:not(.active) {
  background: var(--glass-hover);
  color: var(--text);
}

/* Files page */
.files-content { max-width: 720px; }

.files-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.crumb {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s;
}

.crumb.active { color: var(--primary); font-weight: 600; }
.crumb:hover { background: var(--glass-hover); color: var(--text); }

.retention-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding: 10px 14px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 12px;
}

.folder-list { list-style: none; }

.folder-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--glass);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.25s;
}

.folder-item:hover {
  border-color: var(--primary);
  transform: translateX(6px);
  box-shadow: 0 4px 24px var(--primary-glow);
}

.folder-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168, 85, 247, 0.12);
  border-radius: 14px;
}

.folder-item.video-folder .folder-icon {
  background: rgba(6, 182, 212, 0.12);
}

.folder-info { flex: 1; }
.folder-info h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 2px; }
.folder-info p { font-size: 0.82rem; color: var(--text-muted); }

.folder-arrow { color: var(--text-muted); font-size: 1.2rem; }

.file-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.file-list-header h2 { font-size: 1.1rem; }

.file-items { list-style: none; }

.file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  margin-bottom: 10px;
}

.file-item-icon { font-size: 1.5rem; }

.file-item-info { flex: 1; min-width: 0; }
.file-item-info .name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-item-info .meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.file-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.file-item-actions .btn { padding: 6px 10px; font-size: 0.78rem; }
