/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 浅色模式（默认） */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
    transition: all 0.3s ease;
}

/* 深色模式 */
body.dark-mode {
    color: #e0e0e0;
    background-color: #1a1a1a;
}

/* 深色模式下的容器和卡片 */
body.dark-mode .prompt-form,
body.dark-mode .prompt-list,
body.dark-mode .admin-content,
body.dark-mode .auth-container {
    background-color: #2d2d2d;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .prompt-card {
    background-color: #3a3a3a;
    border-color: #4a4a4a;
}

body.dark-mode .prompt-card:hover {
    background-color: #404040;
}

/* 深色模式下的表单元素 */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border-color: #4a4a4a;
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
    border-color: #667eea;
    outline: none;
}

/* 深色模式下的表格 */
body.dark-mode th {
    background-color: #3a3a3a;
    color: #e0e0e0;
    border-bottom-color: #4a4a4a;
}

body.dark-mode td {
    border-bottom-color: #4a4a4a;
}

body.dark-mode tr:hover {
    background-color: #3a3a3a;
}

/* 深色模式下的导航菜单 */
body.dark-mode .nav-menu {
    background-color: #2d2d2d;
}

body.dark-mode .nav-menu li a {
    color: #e0e0e0;
}

body.dark-mode .nav-menu li a:hover,
body.dark-mode .nav-menu li a.active {
    background-color: #4a4a4a;
    color: #e0e0e0;
}

/* 深色模式下的消息 */
body.dark-mode .message.success {
    background-color: #1e3a2f;
    color: #a3d9b1;
    border-color: #2d5a44;
}

body.dark-mode .message.error {
    background-color: #3a1e1e;
    color: #d9a3a3;
    border-color: #5a2d2d;
}

/* 深色模式切换按钮 */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-toggle button {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle button:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

body.dark-mode .theme-toggle button {
    background: #4a4a4a;
    color: #e0e0e0;
}

body.dark-mode .theme-toggle button:hover {
    background: #5a5a5a;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.header-content > div:first-child {
    text-align: left;
}

.header-content h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.header-content p {
    font-size: 1.2em;
    opacity: 0.9;
}

.user-auth {
    display: flex;
    align-items: center;
    gap: 10px;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#username-display {
    font-weight: bold;
    font-size: 16px;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }
    
    .header-content > div:first-child {
        text-align: center;
    }
    
    .user-auth {
        justify-content: center;
    }
}

/* 功能导航 */
.function-nav {
    margin-bottom: 30px;
}

.nav-tabs {
    display: flex;
    background: white;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    color: #666;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* 标签页内容 */
.tab-content {
    margin-bottom: 30px;
}

/* 主内容区域 */
main {
    margin-bottom: 30px;
}

/* 模板库样式 */
.templates-section {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 收藏样式 */
.favorites-section {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 历史记录样式 */
.history-section {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header h2 {
    color: #667eea;
    font-size: 1.5em;
    margin: 0;
}

.history-item {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 14px;
}

.history-item .action {
    font-weight: bold;
    color: #333;
}

.history-item .details {
    color: #666;
    margin-top: 4px;
    font-size: 12px;
}

.history-item .timestamp {
    color: #999;
    margin-top: 4px;
    font-size: 11px;
    text-align: right;
}

/* 按钮样式 */
.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* 深色模式下的新样式 */
body.dark-mode .nav-tabs {
    background: #2d2d2d;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .tab-btn {
    color: #aaa;
}

body.dark-mode .tab-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    color: #e0e0e0;
}

body.dark-mode .templates-section,
body.dark-mode .favorites-section,
body.dark-mode .history-section {
    background: #2d2d2d;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .history-item {
    background: #3a3a3a;
    border-color: #4a4a4a;
}

body.dark-mode .history-item .action {
    color: #e0e0e0;
}

body.dark-mode .history-item .details {
    color: #aaa;
}

body.dark-mode .history-item .timestamp {
    color: #888;
}

@media (max-width: 768px) {
    .nav-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        width: 100%;
        text-align: left;
    }
    
    .list-header,
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-box {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
}

.prompt-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.prompt-form h2 {
    margin-bottom: 20px;
    color: #667eea;
    font-size: 1.5em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.form-group textarea {
    resize: vertical;
}

.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn:hover {
    background: #764ba2;
}

.prompt-list {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.list-header h2 {
    color: #667eea;
    font-size: 1.5em;
}

.search-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-box input,
.search-box select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-box input {
    width: 200px;
}

.prompts-grid {
    display: grid;
    gap: 20px;
}

.prompt-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.prompt-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.prompt-card h3 {
    margin-bottom: 10px;
    color: #333;
}

.prompt-card .category {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    margin-bottom: 10px;
}

.prompt-card .content {
    margin-bottom: 15px;
    line-height: 1.5;
    color: #555;
}

.prompt-card .tags {
    margin-bottom: 15px;
}

.tag {
    display: inline-block;
    background: #f0f0f0;
    color: #666;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    margin-right: 5px;
    margin-bottom: 5px;
}

.prompt-card .actions {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-danger:hover {
    background: #c0392b;
}

.message {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.empty-state h3 {
    margin-bottom: 10px;
}

.empty-state p {
    margin-bottom: 20px;
}

/* 自动保存指示器 */
.auto-save-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #4CAF50;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    animation: fadeInOut 2s ease-in-out;
    z-index: 1000;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    20% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* 格式化工具 */
.formatting-tools {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #f9f9f9;
}

body.dark-mode .formatting-tools {
    border-color: #4a4a4a;
    background-color: #3a3a3a;
}

.formatting-tools h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #333;
}

body.dark-mode .formatting-tools h3 {
    color: #e0e0e0;
}

.format-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.format-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.format-btn:hover {
    background-color: #f0f0f0;
}

body.dark-mode .format-btn {
    border-color: #4a4a4a;
    background-color: #3a3a3a;
    color: #e0e0e0;
}

body.dark-mode .format-btn:hover {
    background-color: #4a4a4a;
}

/* 字数统计 */
#word-count {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
    text-align: right;
}

body.dark-mode #word-count {
    color: #aaa;
}

/* 多主题支持 */
.light-theme {
    --bg-color: #ffffff;
    --text-color: #333333;
    --border-color: #dddddd;
    --card-bg: #f9f9f9;
    --btn-bg: #667eea;
    --btn-text: #ffffff;
}

.dark-theme {
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --border-color: #555555;
    --card-bg: #2a2a2a;
    --btn-bg: #667eea;
    --btn-text: #ffffff;
}

/* 主题选择器 */
#theme-selector {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: white;
    cursor: pointer;
}

body.dark-mode #theme-selector {
    border-color: #4a4a4a;
    background-color: #3a3a3a;
    color: #e0e0e0;
}

/* 响应式设计优化 */
@media (max-width: 768px) {
    .format-buttons {
        flex-direction: column;
    }
    
    .format-btn {
        width: 100%;
        text-align: center;
    }
    
    .auto-save-indicator {
        position: static;
        margin-top: 10px;
        text-align: center;
    }
}