:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
}

.container-fluid {
    height: calc(100vh - 56px);
}

.row.h-100 {
    height: 100%;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.btn {
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

.nav-link {
    font-weight: 500;
}

.history-item {
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    border-left: 3px solid transparent;
}

.history-item:hover {
    background-color: #f8f9fa;
    border-left-color: var(--primary-color);
}

.history-item.active {
    background-color: #e3f2fd;
    border-left-color: var(--primary-color);
}

.history-item .history-date {
    font-size: 0.75rem;
    color: #6c757d;
}

.history-item .history-prompt {
    font-size: 0.875rem;
    color: #495057;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item .history-cost {
    font-size: 0.75rem;
    color: #28a745;
    font-weight: 600;
}

.suggest-prompt-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.suggest-prompt-btn:hover {
    transform: translateY(-1px);
}

.image-result {
    max-width: 100%;
    border-radius: 0.5rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.generation-status {
    padding: 1rem;
    border-radius: 0.5rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.generation-status.generating {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.generation-status.completed {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.generation-status.failed {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.image-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.image-actions .btn {
    flex: 1;
}

.admin-section {
    animation: fadeIn 0.3s ease-in-out;
}

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

.table {
    background-color: #fff;
    border-radius: 0.5rem;
    overflow: hidden;
}

.table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.badge {
    font-size: 0.75rem;
    font-weight: 500;
}

.spinner-border {
    width: 1rem;
    height: 1rem;
}

.modal-content {
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.form-control {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-select {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    min-width: 250px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    color: #fff;
    text-align: center;
}

@media (max-width: 768px) {
    .col-md-4 {
        margin-bottom: 1rem;
    }
    
    .history-item {
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding: 0;
    }
    
    .row.h-100 {
        margin: 0;
    }
    
    .col-lg-3 {
        position: fixed;
        top: 56px;
        left: -100%;
        width: 80%;
        height: calc(100vh - 56px);
        z-index: 1040;
        transition: left 0.3s ease-in-out;
    }
    
    .col-lg-3.show {
        left: 0;
    }
    
    .col-lg-9 {
        width: 100%;
    }
}

.offcanvas-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.image-grid-item {
    background-color: #fff;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: transform 0.15s ease-in-out;
}

.image-grid-item:hover {
    transform: translateY(-2px);
}

.image-grid-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.image-grid-item .card-body {
    padding: 0.75rem;
}

.image-grid-item .card-title {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.image-grid-item .card-text {
    font-size: 0.75rem;
    color: #6c757d;
}

.user-level-normal {
    color: #6c757d;
}

.user-level-bronze {
    color: #cd7f32;
}

.user-level-silver {
    color: #c0c0c0;
}

.user-level-gold {
    color: #ffd700;
}

.points-positive {
    color: #28a745;
}

.points-negative {
    color: #dc3545;
}

.status-pending {
    color: #ffc107;
}

.status-processing {
    color: #17a2b8;
}

.status-completed {
    color: #28a745;
}

.status-failed {
    color: #dc3545;
}

/* 新的样式 - 主布局 */
.main-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2rem;
    min-height: 0;
}

/* 上传区域样式 */
.upload-area {
    position: relative;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: #f8f9ff;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #e3f2fd;
    transform: scale(1.02);
}

.upload-content {
    transition: opacity 0.3s ease;
}

.upload-preview {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.preview-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.preview-remove {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* 表单样式 */
.generation-form .form-control-lg {
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

.suggest-prompts .btn {
    font-size: 0.85rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    margin-bottom: 0.5rem;
}

.generate-btn {
    height: 60px;
    font-size: 1.1rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 123, 255, 0.4);
}

.generation-result {
    min-height: 300px;
    border-radius: 12px;
    background: white;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.operation-area {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* 侧边栏样式 */
.history-sidebar {
    position: fixed;
    top: 0;
    left: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1040;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.history-sidebar.show {
    left: 0;
}

.sidebar-content {
    overflow-y: auto;
    flex: 1;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 历史记录项样式增强 */
.history-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background-color: #f8f9fa;
    transform: translateX(4px);
}

.history-item.active {
    background-color: #e3f2fd;
    border-left: 4px solid var(--primary-color);
}

.history-prompt {
    font-size: 0.85rem;
    color: #495057;
    margin: 0.25rem 0 0.5rem 0;
    line-height: 1.3;
    font-weight: 400;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.history-date {
    font-size: 0.8rem;
    color: #6c757d;
}

.history-cost {
    font-size: 0.8rem;
    color: #28a745;
    font-weight: 600;
    margin-top: 0.25rem;
}

/* 移动端优化 */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    .main-container {
        height: 100vh;
        overflow: hidden;
    }
    
    .main-content {
        padding: 1rem;
        height: calc(100vh - 80px);
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
    }
    
    .history-sidebar {
        width: 100vw;
        left: -100vw;
    }
    
    .generation-result {
        min-height: 250px;
        margin-bottom: 2rem;
    }
    
    .operation-area {
        padding: 1rem;
    }
    
    .upload-area {
        margin-bottom: 1.5rem;
    }
    
    .generate-btn {
        height: 50px;
        font-size: 1rem;
    }
    
    .top-header {
        height: 80px;
    }
    
    .top-header h4 {
        font-size: 1.1rem;
    }
    
    .badge {
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 0.75rem;
        height: calc(100vh - 70px);
    }
    
    .top-header {
        padding: 0.75rem;
        height: 70px;
    }
    
    .generation-result {
        min-height: 180px;
        margin-bottom: 1.5rem;
    }
    
    .operation-area {
        padding: 0.75rem;
        margin-bottom: 2rem;
    }
    
    .upload-content {
        padding: 1.5rem 1rem;
    }
    
    .upload-content h6 {
        font-size: 0.9rem;
    }
    
    .upload-content p {
        font-size: 0.75rem;
    }
    
    .form-control-lg {
        font-size: 1rem;
    }
    
    .form-group.mb-4 {
        margin-bottom: 1.5rem;
    }
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 改善触摸设备体验 */
@media (hover: none) {
    .upload-area:hover {
        transform: none;
        background-color: #f8f9fa;
    }
    
    .generate-btn:hover {
        transform: none;
    }
    
    .history-item:hover {
        transform: none;
    }
}

/* 确保移动端滚动 */
* {
    -webkit-overflow-scrolling: touch;
}

/* iOS 安全区域适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .main-content {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

/* 防止移动端缩放 */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* 改善移动端表单体验 */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px; /* 防止iOS缩放 */
    }
}