/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基础样式 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #ff6b6b 0%, #ffa07a 100%);
    color: white;
    text-align: center;
    padding: 25px 20px;
}

.header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* 摄像头检测区 */
.camera-section {
    padding: 25px 20px;
    background: linear-gradient(180deg, #e8f5e9 0%, #ffffff 100%);
    border-top: 2px solid #c8e6c9;
}

.camera-section h2 {
    font-size: 1.3rem;
    color: #2e7d32;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 15px;
    overflow: hidden;
    background: #1a1a1a;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.camera-container video,
.camera-container canvas {
    width: 100%;
    height: auto;
    display: block;
}

.camera-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.detection-zone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.zone-label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.zone-box {
    width: 150px;
    height: 180px;
    border: 3px dashed rgba(76, 175, 80, 0.6);
    border-radius: 10px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        border-color: rgba(76, 175, 80, 0.6);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    50% {
        border-color: rgba(76, 175, 80, 1);
        box-shadow: 0 0 20px 5px rgba(76, 175, 80, 0.2);
    }
}

.camera-status {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
}

.status-dot.offline {
    background: #f44336;
}

.status-dot.detecting {
    background: #ff9800;
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.camera-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.camera-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.camera-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.camera-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.camera-btn.stop {
    background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
}

.camera-btn.stop:hover:not(:disabled) {
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.4);
}

.detection-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-label {
    font-size: 0.85rem;
    color: #666;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

/* 检测到人的高亮效果 */
.detection-alert {
    animation: alertFlash 0.5s ease-in-out;
}

@keyframes alertFlash {
    0%, 100% { background: transparent; }
    50% { background: rgba(76, 175, 80, 0.3); }
}

/* 动画展示区 */
.animation-section {
    background: linear-gradient(180deg, #e0f7fa 0%, #ffffff 100%);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: 280px;
}

.cat-container {
    position: relative;
    width: 150px;
    height: 150px;
}

/* 猫咪样式 */
.cat {
    position: absolute;
    width: 100%;
    height: 100%;
    animation: idle 2s ease-in-out infinite;
}

/* 猫咪耳朵 */
.cat-ear {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 40px solid #ff9800;
    top: 0;
}

.cat-ear-left {
    left: 20px;
    transform: rotate(-15deg);
}

.cat-ear-right {
    right: 20px;
    transform: rotate(15deg);
}

.cat-ear::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 25px solid #ffcc80;
    top: 8px;
    left: -12px;
}

/* 猫咪脸部 */
.cat-face {
    position: absolute;
    width: 100px;
    height: 90px;
    background: #ff9800;
    border-radius: 50%;
    top: 25px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.1);
}

/* 猫咪眼睛 */
.cat-eye {
    position: absolute;
    width: 24px;
    height: 28px;
    background: white;
    border-radius: 50%;
    top: 22px;
}

.cat-eye-left {
    left: 15px;
}

.cat-eye-right {
    right: 15px;
}

.cat-pupil {
    position: absolute;
    width: 14px;
    height: 18px;
    background: #333;
    border-radius: 50%;
    top: 5px;
    left: 5px;
    animation: blink 4s ease-in-out infinite;
}

/* 猫咪鼻子 */
.cat-nose {
    position: absolute;
    width: 10px;
    height: 6px;
    background: #ff5722;
    border-radius: 50%;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
}

/* 猫咪嘴巴 */
.cat-mouth {
    position: absolute;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
}

.cat-mouth-left,
.cat-mouth-right {
    position: absolute;
    width: 15px;
    height: 12px;
    border: 3px solid #333;
    border-color: transparent transparent #333 transparent;
    border-radius: 0 0 20px 20px;
    top: 0;
}

.cat-mouth-left {
    left: -12px;
    transform: rotate(-30deg);
}

.cat-mouth-right {
    right: -12px;
    transform: rotate(30deg);
}

/* 猫咪身体 */
.cat-body {
    position: absolute;
    width: 80px;
    height: 60px;
    background: #ff9800;
    border-radius: 40px;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
}

/* 猫咪手臂 */
.cat-arm {
    position: absolute;
    width: 25px;
    height: 35px;
    background: #ff9800;
    border-radius: 15px;
    top: 110px;
}

.cat-arm-left {
    left: 15px;
    transform: rotate(30deg);
    transform-origin: top center;
}

.cat-arm-right {
    right: 15px;
    transform: rotate(-30deg);
    transform-origin: top center;
}

/* 猫咪尾巴 */
.cat-tail {
    position: absolute;
    width: 12px;
    height: 50px;
    background: #ff9800;
    border-radius: 6px;
    top: 130px;
    right: 5px;
    transform: rotate(45deg);
    transform-origin: bottom center;
}

/* 气泡对话框 */
.speech-bubble {
    position: absolute;
    top: 10px;
    right: 20px;
    background: white;
    padding: 12px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    font-size: 1rem;
    color: #333;
    max-width: 200px;
    animation: fadeIn 0.3s ease-out;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
}

/* 动作指示器 */
.action-indicator {
    position: absolute;
    bottom: 20px;
    padding: 10px 20px;
    background: rgba(255, 107, 107, 0.9);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.action-indicator.show {
    opacity: 1;
}

/* 猫咪动画 - 空闲状态 */
@keyframes idle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* 猫咪招手动画 */
@keyframes wave {
    0%, 100% { transform: rotate(30deg); }
    50% { transform: rotate(-20deg); }
}

/* 猫咪跳跃动画 */
@keyframes jump {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-30px); }
}

/* 猫咪尾巴摇摆动画 */
@keyframes tailWag {
    0%, 100% { transform: rotate(45deg); }
    50% { transform: rotate(-30deg); }
}

/* 眨眼动画 */
@keyframes blink {
    0%, 45%, 55%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.1); }
}

/* 淡入动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 猫咪招手状态 */
.cat.waving .cat-arm-right {
    animation: wave 0.5s ease-in-out infinite;
}

.cat.waving .cat-tail {
    animation: tailWag 0.5s ease-in-out infinite;
}

/* 猫咪跳跃状态 */
.cat.jumping {
    animation: jump 0.6s ease-out;
}

/* 功能控制区 */
.control-section {
    padding: 25px 20px;
    background: #fff8e1;
    border-top: 2px solid #ffecb3;
}

.control-section h2 {
    font-size: 1.3rem;
    color: #ff8f00;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.control-item:last-child {
    margin-bottom: 0;
}

.control-item span {
    font-size: 1rem;
    color: #555;
    font-weight: 500;
}

/* AI模式按钮 */
.mode-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #9c27b0 0%, #e91e63 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.4);
}

.mode-btn.active {
    background: linear-gradient(135deg, #4caf50 0%, #8bc34a 100%);
}

/* 开关切换 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #ff6b6b;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* 音量控制 */
.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-btn {
    width: 35px;
    height: 35px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.volume-btn:hover {
    background: #ffecb3;
    transform: scale(1.1);
}

#volumeSlider {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #ff6b6b;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

#volumeSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#volumeValue {
    min-width: 45px;
    text-align: right;
}

/* 话术按钮 */
.speech-buttons {
    display: flex;
    gap: 10px;
}

.speech-btn {
    padding: 8px 16px;
    border: 2px solid #ffcc80;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.speech-btn:hover {
    background: #fff8e1;
}

.speech-btn.active {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

/* 话术设置区 */
.settings-section {
    padding: 25px 20px;
    background: #e3f2fd;
    border-top: 2px solid #bbdefb;
}

.settings-section h2 {
    font-size: 1.3rem;
    color: #1976d2;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.setting-item label {
    font-size: 0.9rem;
    color: #555;
    font-weight: 500;
}

.setting-item input {
    padding: 12px 15px;
    border: 2px solid #bbdefb;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.setting-item input:focus {
    border-color: #1976d2;
}

.save-btn {
    align-self: flex-start;
    padding: 8px 20px;
    background: linear-gradient(135deg, #1976d2 0%, #42a5f5 100%);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(25, 118, 210, 0.3);
}

/* 模拟触发区 */
.trigger-section {
    padding: 25px 20px;
    background: #f3e5f5;
    border-top: 2px solid #e1bee7;
}

.trigger-section h2 {
    font-size: 1.3rem;
    color: #7b1fa2;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trigger-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.trigger-btn {
    padding: 18px 25px;
    border: none;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.trigger-shout {
    background: linear-gradient(135deg, #ff6b6b 0%, #ffa07a 100%);
    color: white;
}

.trigger-interact {
    background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
    color: white;
}

.trigger-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.trigger-btn:active {
    transform: translateY(-1px);
}

/* 状态提示区 */
.status-section {
    padding: 25px 20px;
    background: white;
    border-top: 2px solid #eee;
}

.status-section h2 {
    font-size: 1.3rem;
    color: #37474f;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.status-item {
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: #fafafa;
    border-radius: 12px;
}

.status-label {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 5px;
}

.status-value {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

/* 底部 */
.footer {
    padding: 20px;
    background: #546e7a;
    color: white;
    text-align: center;
}

.footer p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 响应式设计 */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .cat-container {
        width: 120px;
        height: 120px;
    }

    .speech-bubble {
        right: 10px;
        max-width: 150px;
        font-size: 0.9rem;
    }

    .control-item {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .volume-control {
        justify-content: center;
    }

    #volumeSlider {
        width: 100px;
    }

    .speech-buttons {
        justify-content: center;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .trigger-btn {
        padding: 15px 20px;
        font-size: 1rem;
    }
}

/* 动画类 */
.animate-bounce {
    animation: bounce 0.5s ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* 消息提示 */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
}
