/* 设备AI语音交互Demo - 样式文件 */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

/* 主要内容区域 */
main {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* 设备配置 */
.device-config {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

.device-config .form-group {
    display: flex;
    flex-direction: column;
}

.device-config label {
    margin-bottom: 8px;
    font-weight: bold;
    color: #495057;
}

.device-config input {
    padding: 12px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.device-config input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

/* 状态面板 */
.status-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

.status-item {
    text-align: center;
}

.status-label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #666;
}

.status-connected {
    color: #28a745;
    font-weight: bold;
}

.status-disconnected {
    color: #dc3545;
    font-weight: bold;
}

.status-recording {
    color: #fd7e14;
    font-weight: bold;
    animation: pulse 1s infinite;
}

.status-idle {
    color: #6c757d;
}

.status-playing {
    color: #17a2b8;
    font-weight: bold;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 控制面板 */
.control-panel {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,123,255,0.4);
}

.btn-secondary {
    background: linear-gradient(45deg, #6c757d, #495057);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108,117,125,0.4);
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

/* 录音面板 */
.recording-panel {
    margin-bottom: 30px;
}

.recording-container {
    text-align: center;
}

.record-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.record-button {
    width: 120px;
    height: 120px;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(40,167,69,0.3);
    user-select: none;
}

.record-button.start-record {
    background: linear-gradient(45deg, #28a745, #20c997);
}

.record-button.stop-record {
    background: linear-gradient(45deg, #dc3545, #c82333);
}

.record-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    box-shadow: none;
}

.record-button:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(40,167,69,0.4);
}

.record-button.recording {
    background: linear-gradient(45deg, #dc3545, #c82333);
    animation: recordingPulse 1s infinite;
}

@keyframes recordingPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.record-icon {
    font-size: 2em;
    margin-bottom: 5px;
}

.record-text {
    font-size: 12px;
    font-weight: bold;
}

.recording-hint {
    color: #666;
    font-size: 14px;
}

/* 音频可视化 */
.audio-visualizer {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

#audio-canvas {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #f8f9fa;
}

/* 音频信息 */
.audio-info {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.audio-info p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

/* 文本输入面板 */
.text-panel {
    margin-bottom: 30px;
}

.text-input-container {
    display: flex;
    gap: 10px;
}

#text-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

#text-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

#text-input:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
}

/* 对话面板 */
.chat-panel {
    margin-bottom: 30px;
}

.chat-panel h3 {
    margin-bottom: 15px;
    color: #495057;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.chat-history {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.chat-message.user {
    background: #e3f2fd;
    border-left-color: #2196f3;
}

.chat-message.ai {
    background: #e8f5e8;
    border-left-color: #4caf50;
}

.chat-message.system {
    background: #fff3e0;
    border-left-color: #ff9800;
}

.chat-message.device {
    background: #ffebee;
    border-left-color: #f44336;
}

.message-time {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    font-weight: bold;
}

.message-content {
    display: block;
    line-height: 1.4;
}

/* 配置面板 */
.config-panel {
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}

.config-panel details {
    cursor: pointer;
}

.config-panel summary {
    font-weight: bold;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 15px;
}

.config-form {
    display: grid;
    gap: 15px;
}

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

.form-group label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #495057;
}

.form-group input {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

/* 加载提示 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误提示 */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #dc3545;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(220,53,69,0.3);
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 400px;
}

.error-toast button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    main {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }
    
    /* 设备配置区域 */
    .device-config {
        margin-bottom: 15px;
        padding: 15px;
    }
    
    .device-config .form-group {
        margin-bottom: 10px;
    }
    
    .device-config input {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    /* 状态面板 - 两列布局 */
    .status-panel {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .status-item {
        text-align: center;
        padding: 8px;
    }
    
    .status-label {
        font-size: 12px;
        margin-bottom: 3px;
    }
    
    #connection-status,
    #current-device {
        font-size: 13px;
    }
    
    /* 控制面板 - 按钮一行显示 */
    .control-panel {
        flex-direction: row;
        gap: 10px;
        justify-content: center;
        margin-bottom: 20px;
    }
    
    .control-panel .btn {
        flex: 1;
        max-width: 120px;
        padding: 10px 16px;
        font-size: 14px;
    }
    
    /* 录音按钮 */
    .record-button {
        width: 80px;
        height: 80px;
        font-size: 14px;
    }
    
    /* 文本输入区域 */
    .text-input-container {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .text-input-container input {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    .text-input-container .btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    /* 聊天历史区域 */
    .chat-history {
        max-height: 300px;
        margin-bottom: 15px;
    }
    
    .chat-message {
        margin-bottom: 8px;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .chat-message .timestamp {
        font-size: 11px;
    }
    
    /* 错误提示 */
    .error-toast {
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 14px;
        padding: 10px 15px;
    }
}

/* 滚动条样式 */
.chat-history::-webkit-scrollbar {
    width: 8px;
}

.chat-history::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
