/* Reset & Base Styles */
:root {
  --primary-color: #4285f4;
  --danger-color: #d32f2f;
  --warning-color: #fbbc05;
  --success-color: #34a853;
  --dark-bg: #121212;
  --medium-bg: #222;
  --light-bg: #333;
  --text-color: #fff;
  --text-muted: #aaa;
  --border-color: #444;
  --chat-bg: #000;
  --bot-color: #4CA8FF;
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
  background: var(--dark-bg);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-text-size-adjust: none;
  line-height: 1.5;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.2;
}

/* Header & Status */
h1 {
  background: var(--primary-color);
  padding: 0.75rem;
  font-size: clamp(1rem, 3.5vw, 1.3rem);
  text-align: center;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#status {
  padding: 0.2rem 0.5rem;
  background: var(--medium-bg);
  text-align: center;
  font-size: clamp(1rem, 4vw, 1.2rem);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
  align-items: center;
}

.partner-left {
  color: #ff6b6b;
  font-weight: bold;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Video Container */
.video-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background: #000;
}

#videos {
  flex: 1;
  display: flex;
  width: 100%;
  min-height: 0;
  position: relative;
}

video {
  object-fit: cover;
  background: black;
  min-width: 0;
  transition: all 0.3s ease;
}

video[data-disconnected="true"] {
  filter: grayscale(100%) brightness(0.5);
  position: relative;
}

video[data-disconnected="true"]::after {
  content: "Disconnected";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  text-align: center;
  color: white;
  font-size: clamp(1rem, 3vw, 1.2rem);
  transform: translateY(-50%);
}

/* Responsive Video Layout */
@media (orientation: portrait) {
  #videos {
    flex-direction: column;
  }
  video {
    width: 100%;
    height: 50%;
  }
}

@media (orientation: landscape) {
  #videos {
    flex-direction: row;
  }
  video {
    width: 50%;
    height: 100%;
  }
}

/* Control Bar */
.control-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--medium-bg);
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
}

button {
  padding: 0.8rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: clamp(1rem, 4vw, 1.2rem);
  min-width: 120px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  background: var(--light-bg);
  cursor: not-allowed;
  opacity: 0.7;
  transform: none !important;
}

#leaveBtn {
  background: var(--danger-color);
}

/* Chat Area */
.chat-area {
  display: flex;
  flex-direction: column;
  background: var(--dark-bg);
  border-top: 1px solid var(--border-color);
  flex: 0 0 auto;
  max-height: 35vh;
}

#chatLog {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0.75rem;
  font-size: clamp(1rem, 4vw, 1.1rem);
  background: var(--chat-bg);
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) var(--dark-bg);
}

#chatLog::-webkit-scrollbar {
  width: 6px;
}

#chatLog::-webkit-scrollbar-track {
  background: var(--dark-bg);
}

#chatLog::-webkit-scrollbar-thumb {
  background-color: var(--primary-color);
  border-radius: 3px;
}

/* Message Styles */
.message {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  max-width: 80%;
  word-break: break-word;
}

.you {
  background: var(--primary-color);
  color: white;
  margin-left: auto;
  margin-right: 0;
}

.partner {
  background: var(--light-bg);
  margin-right: auto;
  margin-left: 0;
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.8;
  margin-right: 0.5rem;
}

.message-sender {
  font-weight: bold;
  margin-right: 0.3rem;
}

/* Chat Input */
.chat-input {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--medium-bg);
  border-top: 1px solid var(--border-color);
}

#chatInput {
  flex-grow: 1;
  padding: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--light-bg);
  color: var(--text-color);
  font-size: clamp(1rem, 4vw, 1.1rem);
  min-height: 48px;
  transition: all 0.2s ease;
}

#chatInput:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.3);
}

/* Status Indicators */
.status-connected,
.status-waiting {
  display: inline-flex;
  align-items: center;
  color: var(--warning-color);
  font-weight: 500;
  gap: 0.5rem;
  width: 100%;
  justify-content: center;
  text-align: center;
}

/* Improved Spinner Styles */
.spinner {
  width: 1.2rem;
  height: 1.2rem;
  border: 3px solid;
  border-color: currentColor transparent currentColor transparent;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
}

/* Larger spinner for waiting status */
.status-waiting .spinner {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 3px;
}

/* Spinner animation */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Status message alignment */
.status-connected,
.status-waiting {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Specific spinner colors */
.status-connected .spinner {
  color: var(--primary-color);
}

.status-waiting .spinner {
  color: var(--warning-color);
}

/* Pulse animation for connection status */
.status-pulse {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Modern Button Styles */
.button-modern {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--dark-bg);
  border: 2px solid var(--primary-color);
  color: #b0ceff;
  border-radius: 8px;
  padding: 0.7rem 1.4rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 0 5px rgba(66, 133, 244, 0.5);
  transition: all 0.2s ease;
}

.button-modern:hover {
  background-color: #1c1c1c;
  box-shadow: 0 0 10px var(--primary-color);
}

/* Report Button */
#reportBtn {
  background: var(--dark-bg);
  border: 2px solid var(--danger-color);
  color: #ff6b6b;
  box-shadow: 0 0 5px rgba(211, 47, 47, 0.5);
}

#reportBtn:hover {
  background-color: #1c1c1c;
  box-shadow: 0 0 10px var(--danger-color);
}

/* Mute Button */
#muteBtn.muted {
  background-color: var(--danger-color);
  color: white;
}

/* Welcome Text */
#welcomeText {
  background-color: var(--medium-bg);
  color: var(--text-color);
  padding: 1.5rem;
  border-radius: 12px;
  margin: 1.5rem;
  text-align: center;
  max-width: 800px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
}

#welcomeText h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--primary-color);
  margin-bottom: 1rem;
}

#welcomeText p, #welcomeText li {
  font-size: clamp(1rem, 3vw, 1.1rem);
  margin-bottom: 0.75rem;
}

#welcomeText ul {
  list-style-type: none;
  padding-left: 0;
  margin: 1.5rem 0;
  text-align: left;
}

#welcomeText li {
  padding-left: 1.5rem;
  position: relative;
}

#welcomeText li:before {
  content: "•";
  color: var(--primary-color);
  position: absolute;
  left: 0.5rem;
}

#welcomeText a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

#welcomeText a:hover {
  text-decoration: underline;
}

/* Mobile Optimizations */
@media (max-width: 768px) and (orientation: portrait) {
  .control-bar {
    gap: 0.5rem;
    padding: 0.5rem;
  }
  
  button {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    min-width: 100px;
  }
  
  #chatInput {
    padding: 0.7rem;
    min-height: 42px;
    font-size: 0.9rem;
  }
  
  .chat-area {
    max-height: 30vh;
  }
  
  #chatLog {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
  
  .message {
    padding: 0.4rem 0.6rem;
  }
}

/* Desktop Optimizations */
@media (min-width: 769px) {
  .chat-area {
    max-height: 25vh;
  }
  
  #chatLog {
    padding: 1rem;
    font-size: 1rem;
  }
  
  .control-bar {
    padding: 1rem;
  }
  
  #chatInput {
    font-size: 1rem;
  }
}

/* Rate Limit Warning */
.status-rate-limit {
  background-color: var(--danger-color);
  color: white;
  padding: 8px 15px;
  border-radius: 4px;
  animation: pulseWarning 2s infinite;
}

@keyframes pulseWarning {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Bot Message Styling */
.partner.bot {
  background-color: var(--chat-bg);
  border: 1px solid var(--border-color);
}

.partner.bot .message-sender {
  color: var(--bot-color);
}

/* Camera Toggle Animation */
@keyframes spinCam {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

button#cameraToggleBtn.spin {
  animation: spinCam 1s ease-in-out;
}

/* Floating Report Button */
.report-float {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 1000;
  font-size: 1.6rem;
  background: transparent;
  color: #ff4d4d;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.report-float:hover {
  transform: scale(1.1);
  color: white;
}

/* Landing Page Specific */
body.landing .video-container {
  display: none;
}

body.landing main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

body.landing .control-bar {
  margin-top: 1.5rem;
}