/* ===== 千问APP视频通话风格 - 流式车辆定损 ===== */

/* ===== CSS Variables ===== */
:root {
  --bg-deep: #0b0f15;
  --bg-dark: #141a23;
  --bg-glass: rgba(15, 20, 28, 0.78);
  --bg-glass-light: rgba(255, 255, 255, 0.06);
  --bg-bubble-ai: rgba(20, 28, 38, 0.88);
  --bg-bubble-user: rgba(74, 144, 226, 0.22);
  --accent: #4a90e2;
  --accent-soft: rgba(74, 144, 226, 0.2);
  --accent-glow: rgba(74, 144, 226, 0.35);
  --text-primary: #f0f3f7;
  --text-secondary: #a0aec0;
  --text-muted: #5a6a7e;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  --warning: #f59e0b;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.4);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --radius-full: 9999px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-display: 'Outfit', -apple-system, 'PingFang SC', 'Noto Sans SC', sans-serif;
  --font-body: -apple-system, 'PingFang SC', 'Noto Sans SC', 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --ctrl-btn-size: 60px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

/* ===== App Shell ===== */
.app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ===== Top Status Bar ===== */
.status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 20px 12px;
  background: linear-gradient(180deg, rgba(11, 15, 21, 0.92) 0%, rgba(11, 15, 21, 0.6) 70%, transparent 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

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

.status-bar__indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}

.status-bar__indicator--idle {
  background: var(--text-muted);
}

.status-bar__indicator--connecting {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning), 0 0 12px rgba(245, 158, 11, 0.3);
  animation: pulse-glow 1.4s ease-in-out infinite;
}

.status-bar__indicator--active {
  background: var(--success);
  box-shadow: 0 0 6px var(--success), 0 0 12px var(--success-glow);
  animation: pulse-glow 2s ease-in-out infinite;
}

.status-bar__indicator--completed {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.status-bar__indicator--error {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.status-bar__text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.status-bar__timer {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 1.2px;
  background: var(--bg-glass-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* ===== Video Container ===== */
.video-container {
  position: absolute;
  inset: 0;
  background: var(--bg-deep);
  overflow: hidden;
}

.video-container__preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-container__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(11, 15, 21, 0.6) 0%, transparent 18%),
    linear-gradient(0deg, rgba(11, 15, 21, 0.7) 0%, transparent 25%);
}

.video-container__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 3;
  background: linear-gradient(160deg, #0d1117 0%, #151d28 40%, #0f1923 100%);
}

.video-container__placeholder-icon {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.12), rgba(74, 144, 226, 0.04));
  border: 1.5px solid rgba(74, 144, 226, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  animation: breathe 3s ease-in-out infinite;
}

.video-container__placeholder-text {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  max-width: 260px;
  line-height: 1.7;
  letter-spacing: 0.3px;
}

/* ===== Chat Panel (Floating Subtitle) ===== */
.chat-panel {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 12px;
  right: 12px;
  z-index: 50;
  max-height: 35vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  overflow: hidden;
}

.chat-panel--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chat-panel__handle {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  margin: 10px auto 4px;
  flex-shrink: 0;
}

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 6px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chat-panel__messages::-webkit-scrollbar {
  width: 2px;
}

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

.chat-panel__messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* ===== Messages ===== */
.message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
  animation: msg-fade-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  word-break: break-word;
}

.message--ai {
  align-self: flex-start;
  background: var(--bg-bubble-ai);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.message--user {
  align-self: flex-end;
  background: var(--bg-bubble-user);
  color: #e0edff;
  border-bottom-right-radius: 6px;
  border: 1px solid rgba(74, 144, 226, 0.15);
}

.message--system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 14px;
  border: none;
  opacity: 0.8;
}

.message__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
  opacity: 0.65;
}

.message--ai .message__label {
  color: var(--accent);
}

.message--user .message__label {
  color: rgba(200, 220, 255, 0.7);
}

/* ===== Action Area (Bottom Control Bar) ===== */
.action-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  background: linear-gradient(0deg, rgba(11, 15, 21, 0.88) 0%, rgba(11, 15, 21, 0.4) 80%, transparent 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ===== Buttons ===== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  outline: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.92);
}

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

/* Start button - large pill shape on idle */
.btn--primary {
  padding: 18px 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent) 0%, #3b7dd8 50%, #2563eb 100%);
  color: #fff;
  font-size: 16px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px var(--accent-glow), 0 0 40px rgba(74, 144, 226, 0.15);
  animation: btn-breathe 2.5s ease-in-out infinite;
}

.btn--primary:active {
  transform: scale(0.94);
  box-shadow: 0 2px 10px var(--accent-glow);
  animation: none;
}

/* Stop button - circular red */
.btn--danger {
  width: var(--ctrl-btn-size);
  height: var(--ctrl-btn-size);
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0;
  box-shadow: 0 4px 16px var(--danger-glow);
  padding: 0;
}

.btn--danger span {
  font-size: 22px;
  line-height: 1;
}

.btn--danger:active {
  transform: scale(0.9);
  box-shadow: 0 2px 8px var(--danger-glow);
}

/* ===== Spinner ===== */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===== Error Banner ===== */
.error-banner {
  position: fixed;
  top: calc(70px + var(--safe-top));
  left: 16px;
  right: 16px;
  z-index: 200;
  padding: 14px 40px 14px 16px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  color: #fca5a5;
  font-size: 13px;
  line-height: 1.5;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  animation: slide-down 0.3s ease;
}

.error-banner--visible {
  display: block;
}

.error-banner__close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fca5a5;
  font-size: 20px;
  cursor: pointer;
  opacity: 0.7;
  padding: 4px;
  line-height: 1;
}

/* ===== Conclusion Panel ===== */
.conclusion-panel {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  flex-direction: column;
  background: rgba(11, 15, 21, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.conclusion-panel--visible {
  display: flex;
  animation: panel-slide-up 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.conclusion-panel__header {
  text-align: center;
  margin-bottom: 24px;
  padding-top: 12px;
}

.conclusion-panel__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.conclusion-panel__subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.conclusion-panel__content {
  flex: 1;
  background: var(--bg-glass-light);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.conclusion-panel__actions {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.conclusion-panel__actions .btn--primary {
  animation: none;
  padding: 16px 40px;
}

/* ===== Animations ===== */
@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.15);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 20px 4px rgba(74, 144, 226, 0.1);
  }
}

@keyframes btn-breathe {
  0%, 100% {
    box-shadow: 0 4px 20px var(--accent-glow), 0 0 40px rgba(74, 144, 226, 0.12);
  }
  50% {
    box-shadow: 0 4px 30px var(--accent-glow), 0 0 60px rgba(74, 144, 226, 0.2);
  }
}

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

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

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-slide-up {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive: Desktop ===== */
@media (min-width: 768px) {
  .app {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.5);
  }

  .status-bar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }

  .action-area {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }

  .chat-panel {
    max-width: 456px;
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    width: calc(100% - 24px);
  }

  .chat-panel--visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }

  .error-banner {
    max-width: 448px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100% - 32px);
  }

  .conclusion-panel {
    max-width: 480px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
  }
}

/* ===== Landscape ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .chat-panel {
    max-height: 40vh;
    bottom: calc(80px + var(--safe-bottom));
  }

  .action-area {
    padding: 12px 20px calc(12px + var(--safe-bottom));
  }

  .status-bar {
    padding: calc(6px + var(--safe-top)) 16px 6px;
  }

  :root {
    --ctrl-btn-size: 48px;
  }
}
