@charset "UTF-8";

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  width: 100%;
  height: 100vh;
  background-color: #0f172a;
  color: #f8fafc;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.webrtc-app {
  width: 100%;
  height: 100%;
  max-width: 1000px;
  background-color: #1e293b;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@media (min-height: 720px) and (min-width: 600px) {
  .webrtc-app {
    height: 94vh;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.view-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==================== 1. 대기실 (Lobby View) 스타일 ==================== */
.lobby-view {
  background: radial-gradient(circle at top right, #1e293b, #0f172a);
}

.app-header {
  padding: 16px 24px;
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand-icon {
  font-size: 22px;
  color: #38bdf8;
}

.header-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 12px;
  border-radius: 20px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.lobby-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .lobby-content {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
}

/* 내 카메라 미리보기 카드 */
.self-preview-card, .users-list-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preview-header, .list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-header h3, .list-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
}

.device-status-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  font-weight: 500;
}

.video-preview-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #090d16;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-preview-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 셀카 반전 */
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #94a3b8;
  font-size: 13px;
  padding: 20px;
  text-align: center;
  z-index: 4;
}

.btn-start-camera {
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.4);
  transition: all 0.2s;
}

.btn-start-camera:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.6);
}

/* 오디오 레벨 미터 */
.audio-meter-container {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 5;
}

.audio-icon {
  font-size: 11px;
  color: #10b981;
}

.audio-bar-track {
  width: 60px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.audio-bar-fill {
  width: 0%;
  height: 100%;
  background: #10b981;
  border-radius: 4px;
  transition: width 0.05s ease-out;
}

/* 장치 선택 셀렉트 박스 */
.device-select-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.select-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.select-item label {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.select-item select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 6px 8px;
  color: #f1f5f9;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.select-item select:focus {
  border-color: #38bdf8;
}

.preview-controls {
  position: absolute;
  bottom: 12px;
  display: flex;
  gap: 10px;
  z-index: 5;
}

.control-btn {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.control-btn.off {
  background: #ef4444;
  border-color: #ef4444;
}

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

.profile-input-group label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 13px;
  outline: none;
}

.input-row input:focus {
  border-color: #38bdf8;
}

.btn-primary {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background: #0369a1;
}

.btn-self-test {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
  transition: all 0.2s;
  margin-top: 4px;
}

.btn-self-test:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.5);
}

/* ==================== 1-1. 대기실 탭 & 방 만들기 스타일 ==================== */
.lobby-tabs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tab-buttons-row {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px;
  border-radius: 12px;
}

.lobby-tab-btn {
  background: none;
  border: none;
  color: #94a3b8;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.lobby-tab-btn:hover {
  color: #f1f5f9;
}

.lobby-tab-btn.active {
  background: #0284c7;
  color: #ffffff;
}

.btn-create-room {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-create-room:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.45);
}

.tab-content-panel {
  flex: 1;
  overflow-y: auto;
  min-height: 240px;
}

/* 방 카드 목록 */
.room-card-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-card-item {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: all 0.15s;
}

.room-card-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(56, 189, 248, 0.3);
}

.room-info-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.room-title {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
}

.room-lock-icon {
  font-size: 11px;
  color: #f59e0b;
}

.room-meta-sub {
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}

.room-badge.waiting {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.room-badge.in_call {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.btn-join-room {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-join-room:hover {
  background: #0369a1;
  transform: scale(1.03);
}

.btn-join-room:disabled {
  background: #475569;
  cursor: not-allowed;
  transform: none;
}

/* 방 만들기 모달 폼 */
.modal-card.form-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}

.modal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-row h3 {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

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

.form-group label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  color: #ffffff;
  font-size: 13px;
  outline: none;
}

.form-group input:focus {
  border-color: #38bdf8;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 12px;
}

.share-link-box {
  display: flex;
  gap: 6px;
  width: 100%;
}

.share-link-box input {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 6px 10px;
  color: #38bdf8;
  font-size: 11px;
  outline: none;
}

.btn-copy {
  background: #0284c7;
  border: none;
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-cancel {
  background: rgba(255,255,255,0.1);
  color: #cbd5e1;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* 대기자 목록 */
.user-list-wrapper {
  flex: 1;
  overflow-y: auto;
  min-height: 220px;
}

.lobby-user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  transition: background-color 0.15s;
}

.lobby-user-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-text-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-nick-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-nickname {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
}

.badge-me {
  font-size: 10px;
  background: #eab308;
  color: #422006;
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 700;
}

.user-state {
  font-size: 11px;
  color: #10b981;
}

.user-state.busy {
  color: #f59e0b;
}

/* 통화 요청 버튼 */
.btn-call-action {
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-call-action:hover {
  background: #059669;
  transform: scale(1.02);
}

.btn-call-action:disabled {
  background: #475569;
  cursor: not-allowed;
  transform: none;
}

.empty-lobby-message {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  text-align: center;
  gap: 10px;
  font-size: 13px;
  padding: 30px 0;
}

.empty-lobby-message i {
  font-size: 36px;
}

/* ==================== 2. 화상 통화 뷰 (Video Call View) ==================== */
.call-view {
  background: #020617;
  position: relative;
}

.call-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.caller-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #38bdf8;
  color: #ffffff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.caller-details h2 {
  font-size: 16px;
  font-weight: 700;
}

.call-duration {
  font-size: 12px;
  color: #94a3b8;
}

.connection-quality {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.5);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
}

.quality-dot.green {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 6px #10b981;
}

/* 비디오 그리드 */
.video-grid {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  background: #000000;
  overflow: hidden;
}

.remote-video-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remote-video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remote-placeholder {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #94a3b8;
}

.remote-placeholder i {
  font-size: 56px;
}

/* PIP 내 비디오 */
.local-video-container {
  position: absolute;
  bottom: 90px;
  right: 20px;
  width: 180px;
  aspect-ratio: 4 / 3;
  background: #1e293b;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.2);
  z-index: 30;
  cursor: grab;
}

@media (max-width: 600px) {
  .local-video-container {
    width: 120px;
    bottom: 85px;
    right: 14px;
  }
}

.local-video-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.pip-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 10px;
  background: rgba(0,0,0,0.6);
  padding: 2px 6px;
  border-radius: 4px;
}

/* 통화 컨트롤 바 */
.call-controls-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 18px;
  border-radius: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 40;
  box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.call-ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.call-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.06);
}

.call-ctrl-btn.off {
  background: #ef4444;
}

.call-ctrl-btn.hangup-btn {
  background: #dc2626;
  color: #ffffff;
}

.call-ctrl-btn.hangup-btn:hover {
  background: #b91c1c;
}

/* 통화 중 채팅창 */
.in-call-chat-panel {
  position: absolute;
  top: 70px;
  right: 20px;
  width: 280px;
  height: 380px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  z-index: 50;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5);
}

.chat-panel-header {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-panel-header h4 {
  font-size: 14px;
}

.icon-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
}

.chat-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.in-call-msg {
  padding: 6px 10px;
  border-radius: 8px;
  max-width: 85%;
  word-break: break-word;
}

.in-call-msg.mine {
  align-self: flex-end;
  background: #0284c7;
  color: #ffffff;
}

.in-call-msg.other {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.chat-panel-input {
  display: flex;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  gap: 6px;
}

.chat-panel-input input {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 6px 10px;
  color: #ffffff;
  font-size: 12px;
  outline: none;
}

.chat-panel-input button {
  background: #0284c7;
  border: none;
  color: #ffffff;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

/* ==================== 3. 모달 및 팝업 스타일 ==================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card.call-alert-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 30px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.pulse-ring {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ringPulse 1.4s infinite;
}

.pulse-ring.green {
  background: #10b981;
}

@keyframes ringPulse {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 18px rgba(2, 132, 199, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); }
}

.modal-sub {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.4;
}

.modal-actions-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.btn-success {
  flex: 1;
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-danger {
  flex: 1;
  background: #ef4444;
  color: #ffffff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
