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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f0f;
  color: #fff;
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Create/Waiting Screens */
.create-container,
.waiting-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.back-link {
  position: absolute;
  top: 2rem;
  left: 2rem;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  color: #fff;
}

.logo {
  font-size: 4rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: #94a3b8;
  margin-bottom: 2rem;
}

/* Video URL Inputs */
.video-inputs {
  width: 100%;
  max-width: 500px;
  margin-bottom: 1rem;
}

.video-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.video-number {
  width: 28px;
  height: 28px;
  background: #e94560;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.video-url-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 10px;
  color: #fff;
  outline: none;
  transition: border-color 0.3s;
}

.video-url-input:focus {
  border-color: #e94560;
}

.video-url-input::placeholder {
  color: #64748b;
}

.video-hint {
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn.large {
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
  border-radius: 12px;
}

.btn.small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn.primary {
  background: #e94560;
  color: #fff;
}

.btn.primary:hover {
  background: #d63850;
  transform: translateY(-2px);
}

.btn.secondary {
  background: #334155;
  color: #fff;
}

.btn.secondary:hover {
  background: #475569;
}

.btn.danger {
  background: #dc2626;
  color: #fff;
}

.btn.danger:hover {
  background: #b91c1c;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Session Code Display */
.session-code-display {
  background: #1a1a2e;
  border: 2px solid #e94560;
  border-radius: 16px;
  padding: 2rem 3rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

#session-code {
  font-size: 2.5rem;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: #e94560;
}

.share-link {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  width: 100%;
  max-width: 500px;
}

.share-link input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #94a3b8;
}

/* Waiting Indicator */
.waiting-indicator {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #94a3b8;
  margin-bottom: 2rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #333;
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Dashboard Layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: 100vh;
}

/* Video Panel */
.video-panel {
  background: #111;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.connection-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
}

.badge-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
}

.connection-badge.disconnected {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.connection-badge.disconnected .badge-dot {
  background: #ef4444;
}

.video-feed {
  flex: 1;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-feed video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.placeholder {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.placeholder span {
  font-size: 4rem;
  margin-bottom: 1rem;
}

/* Recording Indicator */
.recording-indicator {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.rec-dot {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: rec-pulse 1s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Recording Controls */
.recording-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #333;
}

.record-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #333;
  color: #fff;
  border: 2px solid #444;
}

.record-btn:hover:not(:disabled) {
  background: #444;
  border-color: #555;
}

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

.record-btn.recording {
  background: #dc2626;
  border-color: #ef4444;
  animation: recording-pulse 2s ease-in-out infinite;
}

@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.download-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #22c55e;
  color: #fff;
  border: none;
}

.download-btn:hover {
  background: #16a34a;
}

.recording-time {
  font-family: monospace;
  font-size: 1rem;
  color: #ef4444;
  font-weight: 600;
  margin-left: auto;
}

/* Control Panel */
.control-panel {
  background: #1a1a1a;
  border-left: 1px solid #333;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-section {
  background: #222;
  border-radius: 12px;
  padding: 1.25rem;
}

.panel-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Info Rows */
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #333;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .label {
  color: #64748b;
}

.info-row .value {
  font-weight: 500;
}

.info-row .link {
  color: #3b82f6;
  text-decoration: none;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-row .link:hover {
  text-decoration: underline;
}

/* Intervention Buttons */
.intervention-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.intervention-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #1a1a1a;
  cursor: pointer;
  transition: all 0.2s;
}

.intervention-btn:hover {
  transform: translateY(-2px);
}

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

.intervention-btn .btn-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.intervention-btn .btn-label {
  font-size: 0.8rem;
  color: #94a3b8;
}

.intervention-btn.nudge {
  border-color: #3b82f6;
}

.intervention-btn.nudge:hover {
  background: rgba(59, 130, 246, 0.1);
}

.intervention-btn.quiz {
  border-color: #f97316;
}

.intervention-btn.quiz:hover {
  background: rgba(249, 115, 22, 0.1);
}

.intervention-btn.break {
  border-color: #22c55e;
}

.intervention-btn.break:hover {
  background: rgba(34, 197, 94, 0.1);
}

.intervention-btn.custom {
  border-color: #6b7280;
}

.intervention-btn.custom:hover {
  background: rgba(107, 114, 128, 0.1);
}

/* Custom Message Input */
.custom-input-group {
  display: flex;
  gap: 0.5rem;
}

.custom-input-group input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
}

.custom-input-group input:focus {
  outline: none;
  border-color: #6b7280;
}

/* Session Log */
.log-section {
  flex: 1;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.log-container {
  flex: 1;
  overflow-y: auto;
  max-height: 200px;
}

.log-empty {
  color: #64748b;
  text-align: center;
  padding: 2rem;
  font-size: 0.9rem;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #1a1a1a;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.log-icon {
  font-size: 1.2rem;
}

.log-content {
  flex: 1;
}

.log-type {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.log-message {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.log-time {
  font-size: 0.7rem;
  color: #64748b;
}

.log-status {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
}

.log-status.acknowledged {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

/* Session Control Buttons */
.panel-section:last-child {
  display: flex;
  gap: 0.75rem;
}

.panel-section:last-child .btn {
  flex: 1;
}

/* ====================================
   QUESTIONS SECTION
   ==================================== */
.form-section {
  width: 100%;
  max-width: 500px;
  margin-bottom: 1.5rem;
  text-align: left;
}

.form-label {
  display: block;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.5rem;
}

.form-hint {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 1rem;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #333;
  border-radius: 26px;
  transition: 0.3s;
}

.toggle-slider::before {
  position: absolute;
  content: '';
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #e94560;
}

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

/* Questions Section */
.questions-section {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(233, 69, 96, 0.05);
  border: 1px solid rgba(233, 69, 96, 0.2);
  border-radius: 12px;
}

.question-card {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.question-number {
  font-weight: 600;
  color: #e94560;
  font-size: 0.9rem;
}

.remove-question-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.remove-question-btn:hover {
  color: #ef4444;
}

.question-text-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  margin-bottom: 0.75rem;
  outline: none;
}

.question-text-input:focus {
  border-color: #e94560;
}

.options-label {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.correct-radio {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #e94560;
}

.option-input {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.9rem;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  color: #fff;
  outline: none;
}

.option-input:focus {
  border-color: #e94560;
}

.correct-hint {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.75rem;
  font-style: italic;
}

/* ====================================
   TEMPLATE ACTIONS
   ==================================== */
.template-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.template-name {
  color: #22c55e;
  font-size: 0.9rem;
}

.create-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

/* ====================================
   MODALS
   ==================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
}

.modal-small {
  max-width: 350px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
}

.modal-header h2 {
  font-size: 1.1rem;
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 60vh;
}

.modal-body .form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  margin-bottom: 1rem;
  outline: none;
}

.modal-body .form-input:focus {
  border-color: #e94560;
}

/* Templates List */
.templates-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.templates-empty {
  text-align: center;
  color: #64748b;
  padding: 2rem;
}

.template-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #222;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.template-item:hover {
  border-color: #e94560;
  background: #2a2a2a;
}

.template-info h4 {
  color: #fff;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.template-meta {
  font-size: 0.8rem;
  color: #64748b;
}

.template-delete {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem;
}

.template-delete:hover {
  color: #ef4444;
}

/* Responsive */
@media (max-width: 900px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh auto;
  }

  .control-panel {
    border-left: none;
    border-top: 1px solid #333;
  }
}
