/* --- 基础样式 --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 5vh 20px; /* 增加顶部和左右内边距 */
    box-sizing: border-box;
}

/* --- 密码验证模态框 --- */
.modal {
    display: none; /* 默认隐藏 */
    position: fixed; /* 固定定位，覆盖整个屏幕 */
    z-index: 1000; /* 置于顶层 */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6); /* 半透明黑色背景 */
    justify-content: center;
    align-items: center;
    display: flex; /* 使用 Flexbox 居中 */
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 400px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    margin-top: 0;
}

.modal-content input[type="password"] {
    width: calc(100% - 20px);
    padding: 10px;
    margin: 20px 0;
    border-radius: 5px;
    border: 1px solid #ccc;
}

.modal-content button {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.modal-content button:hover {
    background-color: #0056b3;
}

.modal-content .error-message {
    color: red;
    margin-top: 10px;
    min-height: 20px; /* 避免在没有错误时布局跳动 */
}

/* --- 主容器 --- */
.container {
    background-color: white;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 800px;
    text-align: center;
}

h1 {
    margin-top: 0;
    color: #1a1a1a;
}

p {
    color: #666;
}

/* --- 导航栏 --- */
.nav-tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}

.nav-tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1.1em;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-right: 10px;
}

.nav-tab.active {
    border-bottom-color: #007bff;
    color: #007bff;
}

/* --- 页面切换 --- */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* --- 输入框和按钮 --- */
/* 新增：包裹输入框和清空按钮的容器 */
.prompt-wrapper {
    position: relative;
    display: flex;
    flex-direction: column; /* 垂直排列 */
    flex-grow: 1; /* 让它占据可用空间 */
    max-width: 680px; /* 限制最大宽度 */
}

.input-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center; /* 居中内部元素 */
    align-items: flex-end; /* 与输入框底部对齐 */
}

.prompt-label {
    font-size: 16px; /* 稍大一点的字体 */
    font-weight: 600; /* 加粗 */
    color: #495057; /* 更柔和的黑色 */
    white-space: nowrap;
    text-align: left; /* 左对齐 */
    margin-bottom: 8px; /* 与输入框的间距 */
}

/* --- 按钮组 --- */
.button-group {
    display: flex;
    flex-direction: column; /* 垂直排列 */
    gap: 10px; /* 按钮之间的间距 */
}

/* --- 清空按钮 --- */
.clear-btn {
    padding: 12px 20px;
    background-color: #28a745; /* 绿色 */
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: none; /* 默认隐藏 */
}

.clear-btn:hover {
    background-color: #218838; /* 深一点的绿色 */
}

.clear-btn:disabled {
    background-color: #a0a0a0;
    cursor: not-allowed;
}

.prompt-input {
    width: 100%; /* 占满父容器 .prompt-wrapper */
    box-sizing: border-box; /* 确保 padding 不会影响总宽度 */
    padding: 12px 15px; /* 移除右侧内边距 */
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    resize: vertical; /* 允许用户垂直调整大小 */
    min-height: 80px; /* 设置一个合适的最小高度 */
    line-height: 1.5; /* 改善多行文本的可读性 */
    font-family: inherit; /* 继承父元素的字体 */
}


.prompt-input:focus {
    outline: none;
    border-color: #007bff;
}

.generate-btn {
    padding: 12px 20px; /* 减小按钮的水平padding，使其变窄 */
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.generate-btn:disabled {
    background-color: #a0a0a0;
    cursor: not-allowed;
}

/* --- 内容显示区域 --- */
.image-container, .video-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 30px;
    min-height: 180px;
    background-color: #f7f7f7;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 15px;
    align-content: flex-start;
}

.video-container {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.image-wrapper {
    position: relative;
    background-color: #e9e9e9;
    border-radius: 8px;
    overflow: hidden;
}

.image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-wrapper {
    position: relative;
    background-color: #e9e9e9;
    border-radius: 0;
    overflow: hidden;
}

.video-wrapper video {
    /* position is no longer absolute, to allow natural dimensions */
    width: 100%;
    /* height is set to auto to maintain aspect ratio */
    height: auto;
    display: block; /* to remove bottom space under video */
}


/* --- 加载动画 --- */
.spinner-wrapper {
    grid-column: 1 / -1; /* 让加载动画占据整行 */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: #007bff;
    animation: spin 1s ease infinite;
}

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

/* --- 错误提示 --- */
.error-message {
    color: #d93025;
    margin-top: 15px;
    display: none;
    text-align: left;
    word-break: break-word;
    background-color: #fbeae9;
    border: 1px solid #d93025;
    border-radius: 8px;
    padding: 10px 15px;
}

/* --- 配置区域 --- */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 25px;
    text-align: left;
}

.config-item {
    display: flex;
    flex-direction: column;
}

.config-item label {
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.config-item select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 15px;
    background-color: #fff;
}