/* Dream - 智能梦境记录应用 */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --radius: 0.75rem;
    --radius-lg: 1rem;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== 头部 ========== */
.header {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.logo:hover {
    transform: scale(1.02);
}

.logo-icon {
    font-size: 2.5rem;
}

.logo-text h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    gap: 0.25rem;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text);
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-text {
    font-size: 0.875rem;
    font-weight: 500;
}

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu-btn span {
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

/* ========== 主内容区 ========== */
.main {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

/* ========== 记录表单 ========== */
.record-container {
    max-width: 800px;
    margin: 0 auto;
}

.dream-form {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group.full-width {
    margin-bottom: 2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
}

.label-text {
    display: block;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.label-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
    font-family: inherit;
}

.char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.range-input {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--bg);
    appearance: none;
    cursor: pointer;
}

.range-input::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    cursor: pointer;
    box-shadow: var(--shadow);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.emoji-rating {
    display: flex;
    gap: 0.5rem;
}

.emoji-rating span {
    font-size: 1.75rem;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.2s;
}

.emoji-rating span:hover,
.emoji-rating span.active {
    opacity: 1;
    transform: scale(1.2);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.checkbox-label:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary);
}

.checkbox-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-icon {
    font-size: 1.25rem;
}

.form-actions {
    margin-top: 2rem;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.125rem;
}

.btn-icon {
    font-size: 1.25rem;
}

/* ========== 梦境列表 ========== */
.dream-list {
    display: grid;
    gap: 1rem;
}

.dream-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.dream-card:hover {
    border-color: var(--primary);
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.dream-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.dream-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.dream-date {
    color: var(--text-muted);
    font-size: 0.875rem;
    white-space: nowrap;
}

.dream-preview {
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dream-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    padding: 0.375rem 0.875rem;
    background: var(--bg);
    border-radius: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.tag.mood {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text);
    border: none;
}

.tag.lucid {
    background: rgba(236, 72, 153, 0.2);
    color: var(--accent);
    border-color: var(--accent);
}

/* ========== 筛选栏 ========== */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
}

.filter-select {
    padding: 0.875rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
}

/* ========== 分析结果 ========== */
.dream-selector {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.dream-selector select {
    flex: 1;
    min-width: 200px;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}

.analysis-result {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.analysis-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.analysis-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.analysis-section h3 {
    color: var(--primary-light);
    margin-bottom: 1rem;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analysis-text {
    color: var(--text);
    line-height: 1.8;
}

.theme-list,
.symbol-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.theme-item,
.symbol-item {
    padding: 0.5rem 1rem;
    background: var(--bg);
    border-radius: 1.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
}

.suggestion-list {
    list-style: none;
}

.suggestion-list li {
    padding: 0.75rem 0;
    padding-left: 2rem;
    position: relative;
}

.suggestion-list li:before {
    content: "💡";
    position: absolute;
    left: 0;
}

/* ========== 画廊 ========== */
.gallery-controls {
    margin-bottom: 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.gallery-item {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: all 0.3s;
    position: relative;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.gallery-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.2s;
    display: block;
}

.gallery-image:hover {
    opacity: 0.8;
}

.gallery-delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--danger);
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: var(--shadow);
}

.gallery-delete-btn:hover {
    background: white;
    transform: scale(1.1);
}

.gallery-item:hover .gallery-delete-btn {
    opacity: 1;
}

.gallery-delete-btn::after {
    content: '×';
    font-weight: bold;
}

.gallery-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    background: rgba(15, 23, 42, 0.8);
}

.gallery-item.selected .gallery-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.gallery-item.selected .gallery-checkbox::after {
    content: '✓';
    color: white;
    font-size: 0.875rem;
    font-weight: bold;
}

.gallery-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.gallery-controls {
    margin-bottom: 1rem;
}

.gallery-info {
    padding: 1rem;
}

.gallery-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.gallery-date {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ========== 统计 ========== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.stats-charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.chart-card h3 {
    margin-bottom: 1rem;
    color: var(--text);
}

.chart {
    min-height: 200px;
}

.stats-actions {
    display: flex;
    gap: 1rem;
}

/* ========== 模态框 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    animation: modalSlide 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--text-muted);
    background: none;
    border: none;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* ========== 空状态和加载 ========== */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.loading-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ========== Toast 通知 ========== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastSlide 0.3s ease;
    min-width: 300px;
}

@keyframes toastSlide {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--danger);
}

.toast-icon {
    font-size: 1.25rem;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover,
.pagination button.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-card);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }
    
    .nav.active {
        display: flex;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .main {
        padding: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .dream-card-header {
        flex-direction: column;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-charts-container {
        grid-template-columns: 1fr;
    }
}
