/* ============================================================
   安全聊天系统 - 样式
   移动端优先，暗色主题
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f1e;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

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

/* ============ 登录页 ============ */
.login-view {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.app-title {
  text-align: center;
  font-size: 28px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  text-align: center;
  color: #888;
  font-size: 14px;
  margin-bottom: 32px;
}

.role-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.role-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid #333;
  background: transparent;
  color: #888;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.role-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: transparent;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: #1e1e35;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  outline: none;
}

.form-group input:focus {
  border-color: #667eea;
}

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

.captcha-question {
  background: #2a2a4a;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: bold;
  color: #667eea;
  white-space: nowrap;
}

.captcha-row input {
  flex: 1;
}

#captcha-refresh {
  background: #2a2a4a;
  border: none;
  color: #667eea;
  width: 40px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
}

.error-message {
  color: #ff6b6b;
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:active {
  opacity: 0.8;
}

.login-hint {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: #666;
  line-height: 1.8;
}

/* ============ 聊天页 ============ */
.chat-view {
  background: #0f0f1e;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a4a;
}

.role-badge {
  padding: 6px 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 20px;
  font-size: 13px;
  color: white;
}

.header-right {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 20px;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:active {
  background: #2a2a4a;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 75%;
  display: flex;
  flex-direction: column;
}

.message.own {
  align-self: flex-end;
  align-items: flex-end;
}

.message.other {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-content {
  padding: 10px 14px;
  border-radius: 16px;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.4;
}

.message.own .msg-content {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.other .msg-content {
  background: #2a2a4a;
  color: #e0e0e0;
  border-bottom-left-radius: 4px;
}

.msg-content.emoji {
  font-size: 48px;
  background: transparent;
  padding: 4px;
}

.msg-content.image {
  background: #2a2a4a;
  padding: 12px;
}

.msg-content.error {
  background: #3a1a1a;
  color: #ff9999;
  font-style: italic;
}

.msg-time {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
}

/* ============ 输入区 ============ */
.input-area {
  background: #1a1a2e;
  border-top: 1px solid #2a2a4a;
  padding: 8px;
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: #1e1e35;
  border-radius: 12px;
  margin-bottom: 8px;
}

.emoji-picker span {
  font-size: 28px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
}

.emoji-picker span:active {
  background: #2a2a4a;
}

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

.input-row textarea {
  flex: 1;
  padding: 10px 14px;
  background: #1e1e35;
  border: 1px solid #333;
  border-radius: 20px;
  color: #fff;
  font-size: 15px;
  resize: none;
  outline: none;
  max-height: 100px;
  font-family: inherit;
}

.input-row textarea:focus {
  border-color: #667eea;
}

.send-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 20px;
  color: white;
  font-size: 15px;
  cursor: pointer;
}

.send-btn:active {
  opacity: 0.8;
}

/* ============ 通话页 ============ */
.call-view {
  background: #000;
}

.call-header {
  padding: 16px;
  text-align: center;
  background: #1a1a2e;
  color: white;
  font-size: 18px;
}

.video-container {
  flex: 1;
  position: relative;
  background: #000;
}

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

.local-video {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 120px;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid #667eea;
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: #1a1a2e;
}

.call-btn {
  padding: 16px 20px;
  background: #2a2a4a;
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 14px;
  cursor: pointer;
  min-width: 80px;
  height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.call-btn.hangup {
  background: #e74c3c;
}

.call-btn:active {
  opacity: 0.8;
}

/* ============ 滚动条 ============ */
.messages::-webkit-scrollbar {
  width: 4px;
}

.messages::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

/* ============ 响应式 ============ */
@media (min-width: 768px) {
  .login-container {
    max-width: 450px;
  }
  
  .message {
    max-width: 60%;
  }
}
