:root {
  --bg-dark: #020617;
  --bg-card: rgba(15, 23, 42, 0.8);
  --cyan: #00f2ff;
  --blue: #3b82f6;
  --white: #f8fafc;
  --red: #ef4444;
  --border: rgba(59, 130, 246, 0.3);
  --glow: 0 0 15px rgba(0, 242, 255, 0.5);
}

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

body {
  font-family: 'Rajdhani', sans-serif;
  background-color: var(--bg-dark);
  color: var(--white);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ===== BACKGROUND ===== */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(59, 130, 246, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(59, 130, 246, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: -2;
}

.bg-glow {
  position: fixed;
  top: -10%;
  left: -10%;
  width: 120%;
  height: 120%;
  background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.1), transparent 70%);
  z-index: -1;
  pointer-events: none;
}

/* ===== LOADER ===== */
#loader {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loader-content {
  text-align: center;
  position: relative;
}

.cyber-circle {
  width: 120px;
  height: 120px;
  border: 2px solid transparent;
  border-top: 2px solid var(--cyan);
  border-bottom: 2px solid var(--cyan);
  border-radius: 50%;
  margin: 0 auto 30px;
  animation: spin 2s linear infinite;
  position: relative;
}

.cyber-circle::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 2px solid transparent;
  border-left: 2px solid var(--blue);
  border-right: 2px solid var(--blue);
  border-radius: 50%;
  animation: spin-reverse 1.5s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spin-reverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

.glitch {
  font-family: 'Orbitron', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 5px;
  color: var(--white);
  position: relative;
  margin-bottom: 20px;
}

.loading-bar-container {
  width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 auto 10px;
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  background: var(--cyan);
  box-shadow: var(--glow);
  animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
  0% { width: 0%; left: 0; }
  50% { width: 100%; left: 0; }
  100% { width: 0%; left: 100%; }
}

.loading-status {
  font-size: 0.9rem;
  color: var(--cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ===== APP LAYOUT ===== */
#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.hidden { display: none !important; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 30px;
}

.logo {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.cyan { color: var(--cyan); }
.version { font-size: 0.8rem; color: var(--blue); margin-left: 10px; }

.system-stats {
  display: flex;
  gap: 20px;
}

.stat-item {
  font-size: 0.8rem;
  color: var(--blue);
}

.stat-item .label { color: rgba(255, 255, 255, 0.5); }

/* ===== MAIN CONTENT ===== */
.main-container {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 30px;
}

@media (max-width: 900px) {
  .main-container { grid-template-columns: 1fr; }
}

.video-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.video-wrapper {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--cyan);
  z-index: 10;
}

.tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

video {
  width: 100%;
  display: block;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

.ui-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.rec-indicator {
  position: absolute;
  top: 20px;
  left: 40px;
}

#recStatus {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 1px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 2px;
}

#recStatus.idle { color: var(--cyan); border-left: 3px solid var(--cyan); }
#recStatus.rec { color: var(--red); border-left: 3px solid var(--red); animation: blink 1s infinite; }

@keyframes blink { 50% { opacity: 0.5; } }

.scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--cyan), transparent);
  box-shadow: 0 0 10px var(--cyan);
  animation: scan-move 4s linear infinite;
}

@keyframes scan-move {
  0% { top: 0; }
  100% { top: 100%; }
}

.controls {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.cyber-btn {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.cyber-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--cyan);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.cyber-btn:hover {
  color: var(--bg-dark);
  box-shadow: var(--glow);
}

.cyber-btn:hover::before {
  opacity: 1;
}

.record-btn {
  border-color: var(--red);
  color: var(--red);
}

.record-btn:hover {
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.record-btn:hover::before {
  background: var(--red);
}

/* ===== OUTPUT SECTION ===== */
.output-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.output-card, .history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  position: relative;
}

.card-header {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.output-content {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--cyan);
  text-align: center;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-shadow: var(--glow);
}

.output-content span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 5px;
}

.digit-res {
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 10px;
}

.logs-content {
  height: 200px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
}

.log-entry {
  margin-bottom: 5px;
  padding-left: 10px;
  border-left: 2px solid var(--blue);
}

/* ===== FOOTER ===== */
footer {
  margin-top: 50px;
  text-align: center;
  padding: 20px;
}

.footer-line {
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin-bottom: 20px;
}

footer p {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 2px;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--blue); border-radius: 10px; }
