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

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131a26;
  --bg-card: rgba(22, 30, 49, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --accent-color: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.35);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --font-family: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
  --sidebar-width: 380px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: radial-gradient(circle at 50% 50%, #1e293b 0%, var(--bg-primary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

/* App Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #a5f3fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.control-groups {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Scrollbar Style */
.control-groups::-webkit-scrollbar {
  width: 6px;
}
.control-groups::-webkit-scrollbar-track {
  background: transparent;
}
.control-groups::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.control-groups::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: var(--transition-smooth);
}

.control-card:hover {
  border-color: rgba(56, 189, 248, 0.2);
}

.card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Control Elements */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.input-value {
  font-size: 0.8rem;
  font-family: monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-color);
}

/* Styled Range Input */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  transition: background 0.3s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
  transition: transform 0.1s, background-color 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #7dd3fc;
}

/* Option Buttons / Toggle */
.option-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.btn-option {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: center;
}

.btn-option:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-option.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(56, 189, 248, 0.05) 100%);
  border-color: var(--accent-color);
  color: var(--accent-color);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

/* Switch Styles */
.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-switch {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 34px;
}

.slider-switch:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider-switch {
  background-color: var(--accent-color);
}

input:checked + .slider-switch:before {
  transform: translateX(22px);
}

/* Sidebar Footer & Recording UI */
.sidebar-footer {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: none;
  border-radius: 12px;
  color: white;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45);
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.recording {
  background: linear-gradient(135deg, var(--danger-color) 0%, #b91c1c 100%);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.btn-secondary {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-secondary);
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  justify-content: center;
  margin-top: 4px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-dot.active {
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
  animation: blink 1.5s ease-in-out infinite;
}

.status-dot.recording {
  background-color: var(--danger-color);
  box-shadow: 0 0 8px var(--danger-color);
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Preview Area */
.preview-container {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  background-color: #0d121f;
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(29, 78, 216, 0.05) 0px, transparent 50%);
}

.canvas-frame {
  position: relative;
  background: #111625;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
  max-height: calc(100% - 60px);
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  width: fit-content;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 5;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(56, 189, 248, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s linear infinite;
}

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

.loading-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* Poster wrapper */
.poster-wrapper {
  position: relative;
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Canvas and SVG element style */
.poster-wrapper canvas, .poster-wrapper svg {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  border-radius: 12px;
}

/* Video Specs Label */
.resolution-tag {
  position: absolute;
  bottom: -45px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-family: monospace;
}

/* Hidden canvas for video recording */
#hidden-recording-canvas {
  display: none;
}
