/* ============================================================
   VideoConf - Main Styles
   ============================================================ */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2128;
  --bg-hover: #21262d;
  --bg-input: #0d1117;
  --bg-video: #1c2128;
  --bg-controls: rgba(13, 17, 23, 0.95);

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  --accent-blue: #2f81f7;
  --accent-blue-hover: #388bfd;
  --accent-green: #2da44e;
  --accent-red: #da3633;
  --accent-red-hover: #f85149;
  --accent-amber: #e3b341;

  --border-default: #30363d;
  --border-subtle: #21262d;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 150ms ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

.landing-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 60% 20%, rgba(47, 129, 247, 0.08) 0%, transparent 60%),
              var(--bg-primary);
}

.landing-header {
  display: flex;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.logo svg {
  color: var(--accent-blue);
}

.landing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 40px;
}

.hero {
  text-align: center;
  max-width: 520px;
}

.hero-title {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.landing-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.tab-group {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-panel.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.optional {
  font-weight: 400;
  opacity: 0.7;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.12);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(47, 129, 247, 0.3);
}

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

.btn-full {
  width: 100%;
}

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

.status-msg {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}

.status-msg.error {
  background: rgba(218, 54, 51, 0.12);
  border: 1px solid rgba(218, 54, 51, 0.3);
  color: #f85149;
}

.status-msg.info {
  background: rgba(47, 129, 247, 0.1);
  border: 1px solid rgba(47, 129, 247, 0.3);
  color: var(--accent-blue);
}

.features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px 32px;
  max-width: 520px;
}

.feature {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}

.feature-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--accent-blue);
}

/* ============================================================
   ROOM PAGE
   ============================================================ */

.room-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

.room-loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg-primary);
  z-index: 100;
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.room-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  gap: 16px;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.room-name-display {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.room-id-display {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
}

.room-header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.meeting-timer {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.meeting-timer.recording {
  color: var(--accent-red);
  animation: pulse-timer 1s ease-in-out infinite;
}

@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.room-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.participant-count {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-secondary);
}

.btn-icon-text {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon-text:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-icon-text.copied {
  color: var(--accent-green);
  border-color: var(--accent-green);
}

.room-body-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.video-area {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ============================================================
   VIDEO GRID
   ============================================================ */

.video-grid {
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 12px;
  overflow: hidden;
  align-content: center;
  justify-content: center;
}

.video-grid.count-1 {
  grid-template-columns: 1fr;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.video-grid.count-2 {
  grid-template-columns: repeat(2, 1fr);
}

.video-grid.count-3,
.video-grid.count-4 {
  grid-template-columns: repeat(2, 1fr);
}

.video-grid.count-5,
.video-grid.count-6 {
  grid-template-columns: repeat(3, 1fr);
}

.video-grid.count-7,
.video-grid.count-8,
.video-grid.count-9 {
  grid-template-columns: repeat(3, 1fr);
}

.video-grid.count-10,
.video-grid.count-11,
.video-grid.count-12 {
  grid-template-columns: repeat(4, 1fr);
}

.video-grid.count-13,
.video-grid.count-14,
.video-grid.count-15 {
  grid-template-columns: repeat(5, 1fr);
}

.video-tile {
  position: relative;
  background: var(--bg-video);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16/9;
  border: 2px solid transparent;
  transition: border-color 200ms ease;
}

.video-tile.speaking {
  border-color: var(--accent-green);
}

.video-tile.local-tile {
  border-color: var(--accent-blue);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background-color: #000;
}

.video-tile.video-off video {
  visibility: hidden;
}

.video-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.video-tile.video-off .video-avatar {
  opacity: 1;
}

.avatar-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue) 0%, #1a6bc1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  box-shadow: 0 4px 16px rgba(47, 129, 247, 0.3);
}

.video-tile-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}

.video-tile-name {
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.tile-indicators {
  display: flex;
  gap: 4px;
}

.tile-indicator {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.5);
}

.tile-indicator.muted {
  background: rgba(218, 54, 51, 0.8);
}

.tile-indicator svg {
  color: rgba(255,255,255,0.8);
}

.tile-indicator.muted svg {
  color: #fff;
}

/* ============================================================
   CONTROLS BAR
   ============================================================ */

.quality-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
  margin-right: 12px;
}
.quality-select:hover {
  border-color: var(--accent-blue);
}


.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-controls);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  height: 72px;
  backdrop-filter: blur(12px);
}

.controls-left {
  flex: 1;
  min-width: 0;
}

.controls-room-id {
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.controls-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 60px;
  height: 52px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  padding: 0;
}

.ctrl-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.ctrl-btn.active {
  background: var(--bg-card);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.ctrl-btn.inactive {
  background: rgba(218, 54, 51, 0.12);
  border-color: rgba(218, 54, 51, 0.3);
  color: var(--accent-red);
}

.ctrl-btn.screen-active {
  background: rgba(47, 129, 247, 0.12);
  border-color: rgba(47, 129, 247, 0.3);
  color: var(--accent-blue);
}

.ctrl-btn.recording-active {
  background: rgba(218, 54, 51, 0.12);
  border-color: rgba(218, 54, 51, 0.3);
  color: var(--accent-red);
  animation: recording-pulse 1.5s ease-in-out infinite;
}

@keyframes recording-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(218, 54, 51, 0); }
  50% { box-shadow: 0 0 0 4px rgba(218, 54, 51, 0.15); }
}

.ctrl-btn.chat-open {
  background: rgba(47, 129, 247, 0.12);
  border-color: rgba(47, 129, 247, 0.3);
  color: var(--accent-blue);
}

.ctrl-btn-danger {
  background: var(--accent-red) !important;
  border-color: var(--accent-red) !important;
  color: #fff !important;
}

.ctrl-btn-danger:hover {
  background: var(--accent-red-hover) !important;
  border-color: var(--accent-red-hover) !important;
}

.ctrl-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl-icon.off {
  display: none;
}

.ctrl-btn.inactive .ctrl-icon.on,
.ctrl-btn.screen-active .ctrl-icon.off,
.ctrl-btn.recording-active .ctrl-icon.off {
  display: none;
}

.ctrl-btn.inactive .ctrl-icon.off {
  display: flex;
}

.ctrl-btn.screen-active .ctrl-icon.on,
.ctrl-btn.recording-active .ctrl-icon.on {
  display: flex;
}

.ctrl-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  opacity: 0.8;
}

.ctrl-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-primary);
}

/* ============================================================
   CHAT PANEL
   ============================================================ */

.chat-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  transition: width 200ms ease;
  overflow: hidden;
}

.chat-panel.hidden {
  width: 0;
  border-left: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 2px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: msg-in 150ms ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.chat-msg-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-blue);
}

.chat-msg-name.self {
  color: var(--accent-green);
}

.chat-msg-time {
  font-size: 10px;
  color: var(--text-muted);
}

.chat-msg-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.system {
  align-items: center;
}

.chat-msg.system .chat-msg-body {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}

.chat-input-area input:focus {
  border-color: var(--accent-blue);
}

.chat-input-area input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-blue);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-send:hover {
  background: var(--accent-blue-hover);
}

/* ============================================================
   NOTIFICATION BAR
   ============================================================ */

.notification-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  animation: notif-in 200ms ease;
  z-index: 10;
  pointer-events: none;
}

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

/* ============================================================
   UTILITIES
   ============================================================ */

.hidden {
  display: none !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .landing-card {
    padding: 20px 16px;
  }

  .features {
    gap: 14px 24px;
  }

  .room-header {
    padding: 0 12px;
  }

  .room-name-display {
    max-width: 100px;
  }

  .btn-icon-text span {
    display: none;
  }

  .controls-bar {
    padding: 10px 12px;
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }
  .controls-left {
    display: none;
  }
  .controls-right {
    flex: none;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
  }
  .quality-select {
    margin-right: 0;
  }

  .ctrl-btn {
    width: 50px;
    height: 46px;
  }

  .ctrl-label {
    display: none;
  }

  .chat-panel {
    position: absolute;
    right: 0;
    top: 52px;
    bottom: 72px;
    z-index: 20;
    width: 280px !important;
    box-shadow: var(--shadow-lg);
  }

  .chat-panel.hidden {
    width: 0 !important;
  }

  .video-grid.count-3,
  .video-grid.count-4,
  .video-grid.count-5,
  .video-grid.count-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  .video-grid.count-7,
  .video-grid.count-8,
  .video-grid.count-9,
  .video-grid.count-10,
  .video-grid.count-11,
  .video-grid.count-12 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .controls-center {
    gap: 5px;
  }

  .ctrl-btn {
    width: 44px;
    height: 42px;
  }
}
