/* style.css - Premium Responsive Polish */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #FFA500;
  --primary-hover: #ffb733;
  --bg-dark: #0a0a0a;
  --bg-panel: #161616;
  --text: #ffffff;
  --text-muted: #b0b0b0;
  --border: rgba(255, 255, 255, 0.08);
  --glass: rgba(20, 20, 20, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);

  /* Gradients */
  --bg-gradient: radial-gradient(circle at 50% 10%, #1a1a2e 0%, #000000 100%);
  --btn-gradient: linear-gradient(135deg, #FF9966, #FF5E62);
  --msg-me: linear-gradient(135deg, #00C9FF, #92FE9D);
  --msg-them: #262626;

  /* Safe Area Variables */
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
}

/* Base Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  color: var(--text);
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  height: 60px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  padding-top: max(10px, var(--sat));
  flex-shrink: 0;
  z-index: 50;
}

.logo {
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.8px;
  color: white;
}

.logo span {
  background: var(--btn-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.online {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 12px;
  border-radius: 20px;
}

.dot {
  width: 8px;
  height: 8px;
  background: #00fa9a;
  border-radius: 50%;
  box-shadow: 0 0 10px #00fa9a;
}

/* Main Layout */
.app {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  padding-bottom: var(--sab);
}

/* --- Video Section --- */
.video-container {
  flex: 1;
  background: #000;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Contain to ensure full video is seen without cutting */
  background: #000;
}

/* PIP (Local) */
#local-video-container {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 180px;
  aspect-ratio: 16/9;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 10;
  transition: all 0.3s ease;
}

#local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

/* Controls (Overlay) */
.controls {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  z-index: 20;
}

.btn {
  border: none;
  padding: 14px 32px;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn:active {
  transform: scale(0.96);
}

.btn-stop {
  background: rgba(255, 71, 87, 0.9);
  color: white;
  border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn-stop:hover {
  background: #ff5e6c;
}

.btn-next {
  background: rgba(255, 255, 255, 0.95);
  color: black;
}

.btn-next:hover {
  background: #ffffff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.btn-home {
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ccc;
  padding: 14px 20px;
  /* Slightly smaller */
}

.btn-home:hover {
  background: rgba(50, 50, 50, 0.9);
  color: white;
}

/* Status Badge */
#status-overlay {
  top: 30px;
  left: 30px;
  font-weight: 500;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- Chat Section --- */
.chat-container {
  width: 400px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 15;
}

.chat-logs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-logs::-webkit-scrollbar {
  width: 5px;
}

.chat-logs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.msg {
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 15px;
  max-width: 85%;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg.stranger {
  background: var(--msg-them);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  color: #e0e0e0;
}

.msg.me {
  background: var(--msg-me);
  color: #000;
  /* Dark text for contrast on bright gradient */
  font-weight: 500;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  box-shadow: 0 4px 15px rgba(0, 201, 255, 0.15);
}

.msg.sys {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  border: none;
  align-self: center;
  width: auto;
  padding: 6px 16px;
  border-radius: 50px;
  margin: 10px 0;
}

.input-area {
  background: rgba(20, 20, 20, 0.95);
  padding: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: center;
}

.input-field {
  flex: 1;
  background: #252525;
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 14px;
  color: white;
  font-size: 15px;
  transition: all 0.2s;
}

.input-field:focus {
  border-color: var(--primary);
  background: #2a2a2a;
  box-shadow: 0 0 0 2px rgba(255, 165, 0, 0.1);
}

.send-btn {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: var(--primary);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s;
}

.send-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  background: #333;
  opacity: 0.5;
  transform: none;
  cursor: default;
}

/* --- Start Screen --- */
.start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, 0.9);
  backdrop-filter: blur(15px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.start-card {
  background: rgba(30, 30, 30, 0.6);
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8);
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Glow Effect */
.start-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 165, 0, 0.05) 0%, transparent 60%);
  pointer-events: none;
}

.start-card h2 {
  font-size: 28px;
  margin-bottom: 24px;
  background: linear-gradient(to right, #fff, #aaa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: #888;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.3s;
}

.tab.active {
  background: #333;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.start-card .input-field {
  width: 100%;
  margin-bottom: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
}

.start-card .input-field:focus {
  background: rgba(0, 0, 0, 0.5);
  border-color: var(--primary);
}

.lg-btn {
  width: 100%;
  padding: 18px;
  margin-top: 24px;
  background: var(--btn-gradient);
  border: none;
  border-radius: 16px;
  color: white;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(255, 94, 98, 0.25);
  transition: all 0.3s;
}

.lg-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(255, 94, 98, 0.4);
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 850px) {
  .app {
    flex-direction: column;
  }

  .video-container {
    height: 45vh;
    width: 100%;
    flex: none;
  }

  .controls {
    bottom: 12px;
    width: 100%;
    justify-content: center;
    padding: 0 15px;
    gap: 12px;
  }

  .btn {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 10px;
  }

  /* PiP Moves */
  #local-video-container {
    width: 100px;
    /* Smaller */
    aspect-ratio: 3/4;
    top: 15px;
    right: 15px;
    bottom: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  }

  .chat-container {
    width: 100%;
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .input-area {
    padding: 12px;
  }

  .send-btn {
    height: 44px;
    width: 44px;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .app {
    flex-direction: row;
  }

  .video-container {
    height: 100%;
  }

  .chat-container {
    width: 320px;
  }

  #local-video-container {
    bottom: 15px;
    right: 15px;
    top: auto;
    width: 120px;
  }
}