/* Basic Body Styling */
body {
    margin: 0;
    /* font-family: 'Arial', sans-serif; */ /* Tailwind handles font */
    background: linear-gradient(135deg, #1e3c72, #2a5298); /* Restore background */
    color: #e0f2fe; /* Restore default text color */
    overflow-x: hidden; /* Prevent horizontal scroll often caused by flex adjustments */
}

/* Controls Panel Styling */
#controls {
    z-index: 10;
    box-sizing: border-box;
    padding: 20px;
    background-color: rgba(17, 34, 64, 0.8);
    border-radius: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

#controls h2 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #233554;
    padding-bottom: 5px;
}

#controls label {
    display: block;
    margin-bottom: 5px;
}

#controls input[type="range"] {
    width: 100%;
    cursor: pointer;
    margin-bottom: 10px;
}

#controls span {
    margin-left: 10px;
}

#controls button {
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px;
    display: block;
    width: 100%;
}

/* Wind Tunnel Container Styling */
#wind-tunnel-container {
    position: relative;
    overflow: hidden;
}

/* Canvas Styling */
#tunnel-canvas,
#drawing-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    aspect-ratio: 2 / 1; /* 固定 2:1 的宽高比 */
}

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    background-color: white;
}

#bd-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* 保持 2:1 宽高比 */
    padding-bottom: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.upper-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/*--------------------------------------*/
/*------- AI Assistant Button ----------*/
/*--------------------------------------*/

.ai-assistant-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s;
    background: none;
    border: none;
    box-shadow: 0 4px 20px rgba(0, 179, 255, 0.3);
    border-radius: 50%;
    overflow: hidden;
    padding: 0;
}

.ai-btn-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.ai-assistant-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 179, 255, 0.4);
}

.ai-assistant-btn:hover .ai-btn-image {
    transform: scale(1.05);
}

.ai-dialog {
    position: absolute;
    bottom: 80px;
    left: 20px;
    right: 20px;
    max-height: 500px;
    background: rgba(10, 25, 47, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 255, 204, 0.1);
}

.ai-dialog.show {
    display: flex;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-dialog-header {
    background: linear-gradient(to right, rgba(0, 255, 204, 0.1), rgba(0, 179, 255, 0.1));
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(136, 146, 176, 0.1);
}

.ai-dialog-title {
    font-weight: bold;
    font-size: 16px;
    color: #00ffcc;
}

.ai-dialog-close {
    background: none;
    border: none;
    color: #8892b0;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.3s;
}

.ai-dialog-close:hover {
    color: #00ffcc;
}

.ai-dialog-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-dialog-body::-webkit-scrollbar {
    width: 6px;
}

.ai-dialog-body::-webkit-scrollbar-track {
    background: rgba(10, 25, 47, 0.5);
}

.ai-dialog-body::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 204, 0.3);
    border-radius: 3px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.5;
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message.user {
    align-self: flex-end;
    background: linear-gradient(to right, #00b3ff, #0062ff);
    color: white;
    border-bottom-right-radius: 5px;
}

.ai-message.bot {
    align-self: flex-start;
    background-color: #112240;
    color: white;
    border-bottom-left-radius: 5px;
    position: relative;
}

.ai-message.bot::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-right: 8px solid #112240;
    border-bottom: 8px solid transparent;
}

.ai-message.user::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-left: 8px solid #00b3ff;
    border-bottom: 8px solid transparent;
}

.ai-dialog-input {
    display: flex;
    flex-wrap: wrap; /* 允许换行 */
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid rgba(136, 146, 176, 0.1);
    background-color: rgba(17, 34, 64, 0.5);
    gap: 8px;
}

.ai-dialog-input input {
    width: 100%; /* 占据整行宽度 */
    margin-bottom: 8px; /* 与下方按钮添加间距 */
    padding: 10px 15px;
    background-color: #112240;
    border: 1px solid rgba(136, 146, 176, 0.3);
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    color: white;
}

.ai-dialog-input input:focus {
    border-color: #00ffcc;
    box-shadow: 0 0 0 2px rgba(0, 255, 204, 0.2);
}

.ai-dialog-input button#aiSendBtn {
    margin-left: 0;
    padding: 10px 18px;
    background: linear-gradient(to right, #00ffcc, #00b3ff);
    color: #0a192f;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.ai-dialog-input button#aiSendBtn:hover {
    opacity: 0.9;
}

.ai-dialog-input button#aiSendBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-dialog-input button#recordBtn {
    padding: 10px; /* 根据需要调整 */
    background-color: transparent; /* 或者其他样式 */
    border: 1px solid rgba(136, 146, 176, 0.3); /* 保持风格统一 */
    border-radius: 50%; /* 圆形按钮 */
    color: white;
    cursor: pointer;
    flex-shrink: 0; /* 防止被压缩 */
    line-height: 1; /* 确保图标垂直居中 */
    font-size: 16px; /* 调整图标大小 */
}

#recordBtn {
    background: none;
    border: 1px solid rgba(136, 146, 176, 0.3);
    color: #8892b0;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: all 0.3s;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#recordBtn:hover {
    background-color: #112240;
    color: #00ffcc;
    border-color: #00ffcc;
}

#recordBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#recordingStatus {
    font-size: 12px;
    color: #8892b0;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 60px;
    text-align: left;
}

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

body {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    aspect-ratio: 2 / 1; /* 固定 2:1 的宽高比 */
    overflow: hidden;
}

label {
    margin-left: 20px;
}

button {
    -moz-box-shadow: inset 0px 1px 0px 0px #ffffff;
    -webkit-box-shadow: inset 0px 1px 0px 0px #ffffff;
    box-shadow: inset 0px 1px 0px 0px #ffffff;
    background: -webkit-gradient(
        linear,
        left top,
        left bottom,
        color-stop(0.05, #f9f9f9),
        color-stop(1, #e9e9e9)
    );
    background: -moz-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%);
    background: -webkit-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%);
    background: -o-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%);
    background: -ms-linear-gradient(top, #f9f9f9 5%, #e9e9e9 100%);
    background: linear-gradient(to bottom, #f9f9f9 5%, #e9e9e9 100%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#e9e9e9', GradientType=0);
    background-color: #f9f9f9;
    -moz-border-radius: 6px;
    -webkit-border-radius: 6px;
    border-radius: 6px;
    border: 1px solid #dcdcdc;
    display: inline-block;
    cursor: pointer;
    color: #666666;
    font-size: 15px;
    font-weight: bold;
    padding: 6px 24px;
    text-decoration: none;

    margin-left: 10px;
    margin-top: 5px;
}

button:active {
    position: relative;
    top: 1px;
}

#drawing-mode {
    margin-bottom: 10px;
    vertical-align: top;
}

label {
    display: inline-block;
    width: 130px;
}

.info {
    display: inline-block;
    width: 25px;
}

#bd-wrapper {
    display: none;
}

.typing-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #00ffcc;
    margin-right: 4px;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

.typing-container {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: #112240;
    border-radius: 15px;
    color: #8892b0;
    font-size: 14px;
    max-width: 85%;
    align-self: flex-start;
    position: relative;
}

.typing-container::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-right: 8px solid #112240;
    border-bottom: 8px solid transparent;
}

/* ============ 绘图模式覆盖层（更精确限定）=========== */

#bd-wrapper {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 119px !important; /* 为 docker 留出空间，与父容器的 padding-bottom 一致 */
    z-index: 5;
    display: flex; /* 使用 flex 居中内部容器 */
    align-items: center;
    justify-content: center;
    /* 确保内容保持 2:1 比例 */
    /* 默认透明且不响应事件 */
    background-color: transparent;
    pointer-events: none;
}

/* 仅当 #bd-wrapper 显式可见时，允许交互 */
#bd-wrapper[style*="display: block"] {
    pointer-events: auto;
}

/* 仅当 #bd-wrapper 显式可见时，对其内部容器应用样式 */
#bd-wrapper[style*="display: block"] > .canvas-container {
    position: relative !important; /* 相对定位 */
    width: 100% !important; /* 填充宽度 */
    height: 0 !important;       /* 高度设为0 */
    padding-bottom: 50% !important; /* 高度为宽度的50% (维持2:1) */
    background-color: white; /* 只给它白色背景 */
    max-width: 100%; /* 确保不超出容器 */
}

/* 内部 canvas 元素相对于上述容器定位 */
#bd-wrapper .lower-canvas,
#bd-wrapper .upper-canvas {
    aspect-ratio: 2 / 1 !important; /* 强制 2:1 的宽高比 */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important; /* 填满 300x150 容器 */
    height: 100% !important; /* 填满 300x150 容器 */
}

/* --- 其他元素层级 --- */
.docker {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important; /* 确保宽度始终为100% */
    z-index: 10;
    margin: 0 !important; /* 移除可能的外边距 */
}

/* 为 .docker 的父容器 (长选择器) 添加 padding-bottom */
/* 注意：7rem 是估计值，请根据 .docker 实际高度精确调整 */
.flex-1.flex.flex-col.items-center.justify-center.shadow-md.p-6.bg-secondary\/20.rounded-lg.border.border-accent\/20.relative {
    padding-bottom: 119px !important; /* 根据您提供的 docker 高度 (119.33px) 设置 */
    position: relative !important; /* 确保相对定位 */
    overflow: hidden !important; /* 防止内容溢出 */
}

/* 确保主渲染 Canvas (#tunnel-canvas) 不受影响 */
#tunnel-canvas {
    position: relative;
    z-index: 1; /* 在背景之下 */
}

/* 清理之前的通用 canvas-container 背景设置，确保默认透明 */
.canvas-container {
    background-color: transparent;
}

.sidebar {
    position: relative;
}