/**
 * My Virtual Boss - Real Estate AI Training
 * Mobile-First Responsive Design
 */

/* =============================================================================
   CSS Variables & Theme
   ============================================================================= */

:root {
  /* Primary colors - professional, trustworthy */
  --color-primary: #1e3a5f;
  --color-primary-light: #2d5a8c;
  --color-primary-dark: #0f2847;
  
  /* Accent - warm gold */
  --color-accent: #d4a574;
  --color-accent-light: #e8c9a8;
  
  /* Neutrals */
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #2c3e50;
  --color-text-light: #6b7c93;
  --color-text-muted: #9ca3af;
  --color-border: #e8e4df;
  
  /* Semantic */
  --color-success: #27ae60;
  
  /* Typography */
  --font-primary: 'Crimson Pro', Georgia, serif;
  --font-secondary: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;600;700&display=swap');

/* =============================================================================
   Base Styles
   ============================================================================= */

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

html {
  font-size: 16px; /* Prevents iOS auto-zoom on inputs */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-secondary);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* =============================================================================
   Screens
   ============================================================================= */

.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* =============================================================================
   Pre-Session Screen
   ============================================================================= */

#pre-session {
  padding: var(--spacing-lg) var(--spacing-md);
  max-width: 100%;
  overflow-y: auto;
}

.container {
  max-width: 640px;
  margin: 0 auto;
}

/* Header / Branding */
.header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.logo {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--spacing-md);
  color: white;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-shadow: var(--shadow-md);
}

.logo svg {
  width: 100%;
  height: 100%;
}

h1 {
  font-family: var(--font-primary);
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.subtitle {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--spacing-xs);
}

.description {
  font-size: 0.95rem;
  color: var(--color-text-light);
  line-height: 1.5;
}

/* How It Works */
.how-it-works {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.how-it-works h2 {
  font-family: var(--font-primary);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--spacing-md);
}

.how-it-works ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.how-it-works li {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
}

.how-it-works strong {
  color: var(--color-primary);
  font-weight: 600;
}

/* Scenario Selector */
.scenario-selector {
  margin-bottom: var(--spacing-xl);
}

.scenario-selector h2 {
  font-family: var(--font-primary);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--spacing-lg);
  text-align: center;
}

/* Role Toggles */
.role-toggles {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.role-toggle {
  width: 100%;
  min-height: 56px;
  padding: var(--spacing-md);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-secondary);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.role-toggle:active {
  transform: scale(0.98);
}

.role-toggle.selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.role-toggle:not(.selected) {
  opacity: 0.7;
}

/* Scenario Cards Container */
.scenario-cards-container {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
}

.scenario-cards-container:not(.hidden) {
  max-height: 2000px;
  opacity: 1;
}

.scenario-cards {
  display: none;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.scenario-cards.active {
  display: flex;
}

/* Scenario Card */
.scenario-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  min-height: 72px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
}

.scenario-card:active {
  transform: scale(0.98);
}

.scenario-card.selected {
  background: linear-gradient(135deg, var(--color-accent-light), var(--color-accent));
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

.scenario-card.selected .card-title {
  color: var(--color-primary-dark);
}

.card-description {
  font-size: 0.9rem;
  color: var(--color-text-light);
  line-height: 1.4;
}

.scenario-card.selected .card-description {
  color: var(--color-primary);
}

/* Start Section */
.start-section {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.primary-btn {
  width: 100%;
  min-height: 56px;
  padding: var(--spacing-md) var(--spacing-lg);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-secondary);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-md);
}

.primary-btn:not(:disabled):hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

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

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-text-light);
}

.mic-notice {
  margin-top: var(--spacing-sm);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* =============================================================================
   Session Screen
   ============================================================================= */

#session {
  flex-direction: column;
  background: #0a0a0a;
  height: 100vh;
  overflow: hidden;
}

#session.active {
  display: flex;
}

#video-container {
  flex: 1;
  min-height: 0;        /* Allow flex item to shrink below video's intrinsic height (Chrome fix) */
  overflow: hidden;      /* Clip video to allocated flex space */
  position: relative;
  width: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#connection-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  color: white;
}

#video-container.connected #connection-status {
  display: none;
}

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

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

.session-controls {
  padding: var(--spacing-md);
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
}

.secondary-btn {
  min-height: 48px;
  padding: var(--spacing-sm) var(--spacing-lg);
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-secondary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:active {
  transform: scale(0.95);
}

/* =============================================================================
   Post-Session Screen
   ============================================================================= */

#post-session {
  display: flex;
  padding: var(--spacing-xl) var(--spacing-md);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 100vh;
  text-align: center;
}

#post-session.active {
  display: flex !important;  /* Override .screen.active { display: block } */
}

#post-session .card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl) var(--spacing-lg);
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--color-success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto var(--spacing-lg);
  box-shadow: 0 4px 16px rgba(39, 174, 96, 0.3);
}

#post-session h1 {
  font-family: var(--font-primary);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

#post-session .subtitle {
  font-size: 1rem;
  color: var(--color-text-light);
  margin-bottom: var(--spacing-lg);
}

#session-summary {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-lg);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

#session-summary h2 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-md);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-family: var(--font-primary);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-actions {
  margin-top: var(--spacing-lg);
}

.post-actions .primary-btn {
  width: 100%;
}

/* =============================================================================
   Responsive Design - Desktop
   ============================================================================= */

@media (min-width: 480px) {
  .role-toggles {
    flex-direction: row;
  }
  
  .role-toggle {
    flex: 1;
  }
}

@media (min-width: 640px) {
  #pre-session {
    padding: var(--spacing-xl);
  }
  
  h1 {
    font-size: 2.5rem;
  }
  
  .how-it-works {
    padding: var(--spacing-xl);
  }
  
  .start-section .primary-btn {
    width: auto;
    min-width: 280px;
  }
}

@media (max-width: 375px) {
  h1 {
    font-size: 1.75rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  .summary-stats {
    grid-template-columns: 1fr;
  }
}

/* =============================================================================
   Utility Classes
   ============================================================================= */

.hidden {
  display: none !important;
}

/* =============================================================================
   Animations
   ============================================================================= */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen.active {
  animation: fadeIn 0.3s ease-out;
}

/* =============================================================================
   Time Warning Banner
   ============================================================================= */

#time-warning {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #f59e0b;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}
