/* --- Base Styles --- */
:root {
    --primary-color: #007bff;
    --primary-hover-color: #0056b3;
    --background-color: #f8f9fa;
    --text-color: #333;
    --light-gray-color: #e9ecef;
    --white-color: #fff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --gallery-gap: 20px;
    --gallery-item-min-width: 280px;
}

@media (max-width: 768px) {
    :root {
        --gallery-gap: 10px;
        --gallery-item-min-width: 150px;
    }
}

@media (max-width: 480px) {
    :root {
        --gallery-gap: 8px;
        --gallery-item-min-width: 120px;
    }
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
}

.btn {
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

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

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

/* --- Header --- */
.main-header {
    background-color: var(--white-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 20px;
    white-space: nowrap;
}

.logo-alt {
    font-weight: 300;
    color: var(--text-color);
}

.main-nav {
    display: flex;
    align-items: center;
    flex-grow: 1;
    justify-content: center;
}

.main-nav .nav-link {
    margin: 0 15px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    position: relative;
    padding-bottom: 5px;
}

.main-nav .nav-link.active,
.main-nav .nav-link:hover {
    color: var(--primary-color);
}

.main-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.main-nav .nav-link.active::after,
.main-nav .nav-link:hover::after {
    width: 100%;
}

.header-actions {
    display: flex;
    align-items: center;
}

@media (max-width: 768px) {
    .main-header .container {
        justify-content: center;
        gap: 10px;
    }
    
    .logo {
        font-size: 1.5rem;
        margin-right: 0;
        text-align: center;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .main-nav {
        order: 2;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 5px;
    }
    
    .main-nav::-webkit-scrollbar {
        height: 3px;
    }
    
    .main-nav::-webkit-scrollbar-thumb {
        background-color: var(--light-gray-color);
    }
    
    .main-nav .nav-link {
        margin: 0 10px;
        white-space: nowrap;
        font-size: 0.9rem;
    }
    
    .header-actions {
        order: 1;
    }
}

@media (max-width: 480px) {
    .main-header {
        padding: 10px 0;
    }
    
    .logo {
        font-size: 1.3rem;
    }
    
    .main-nav .nav-link {
        margin: 0 8px;
        font-size: 0.85rem;
    }
    
    .btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
}

/* --- Toolbar --- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-top: 20px;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 300px;
    padding: 10px 15px 10px 40px;
    border: 1px solid var(--light-gray-color);
    border-radius: 20px;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        gap: 15px;
    }
    
    .search-box input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}

.filter-options select {
    padding: 10px;
    border: 1px solid var(--light-gray-color);
    border-radius: 5px;
    font-size: 1rem;
    margin-left: 10px;
}

/* --- Gallery Grid (Waterfall Layout) --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--gallery-item-min-width), 1fr));
    gap: var(--gallery-gap);
    grid-auto-rows: 10px;
}

.gallery-item {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: auto; /* Fix: Allow height to scale based on aspect ratio */
    display: block;
}

.gallery-item .favorite-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item .delete-icon {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .gallery-item .favorite-icon,
    .gallery-item .delete-icon {
        font-size: 1.2rem;
        opacity: 0.8; /* Always slightly visible on mobile */
    }
}

@media (max-width: 480px) {
    .gallery-item .favorite-icon,
    .gallery-item .delete-icon {
        font-size: 1rem;
    }
}

.gallery-item:hover .favorite-icon,
.gallery-item:hover .delete-icon,
.gallery-item .favorite-icon.collected {
    opacity: 1;
}

.gallery-item .delete-icon:hover {
    color: #ff4757;
}

/* --- Like Button Animation --- */
.like-icon {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 1.5rem;
    color: white;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
    opacity: 0.8;
}

.gallery-item:hover .like-icon {
    opacity: 1;
}

.like-icon.liked {
    color: #ff4757;
    animation: bounce 0.4s ease-in-out;
}

@keyframes bounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* --- Page Title --- */
.page-title {
    text-align: center;
    padding: 40px 0 20px;
}

.page-title h2 {
    font-size: 2.5rem;
    font-weight: 700;
}

/* --- Album Page --- */
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.album-item {
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow-color);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.album-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.album-cover {
    position: relative;
    height: 200px;
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 2rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.album-item:hover .album-overlay {
    opacity: 1;
}

.album-info {
    padding: 15px;
    background-color: var(--white-color);
}

.album-info h3 {
    margin: 0 0 5px;
}

.album-info p {
    margin: 0;
    color: #777;
    font-size: 0.9rem;
}

/* --- Album Detail View --- */
.album-detail-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-color);
    z-index: 1500;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.album-detail-view.visible {
    transform: translateX(0);
}

.album-detail-header {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--light-gray-color);
    background-color: var(--white-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.back-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 20px;
}

#album-detail-title {
    flex-grow: 1;
    margin: 0;
    font-size: 1.5rem;
    cursor: text;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

#album-detail-title:focus {
    background-color: #f0f0f0;
    outline: none;
}

#album-detail-grid {
    padding: 20px;
    flex-grow: 1;
}

/* --- About Page --- */
.about-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    line-height: 1.8;
}

.about-content h3 {
    margin-top: 30px;
}

.features-list ul {
    list-style: none;
    padding: 0;
}

.features-list li {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.features-list i {
    color: var(--primary-color);
    margin-right: 15px;
    width: 25px;
    text-align: center;
}

/* --- Add Album Modal --- */
.form-group {
    margin: 20px 0;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--light-gray-color);
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
}

/* --- No Results Message --- */
.no-results {
    grid-column: 1 / -1;
    padding: 50px 0;
    text-align: center;
    font-size: 1.2rem;
    color: #777;
}

/* --- Floating Action Button --- */
.floating-action-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    z-index: 100;
}

@media (max-width: 768px) {
    .floating-action-button {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
        font-size: 1.2rem;
    }
}

.floating-action-button:hover {
    background-color: var(--primary-hover-color);
    transform: scale(1.1);
}

.floating-action-button.active {
    background-color: #28a745; /* Green for user mode */
}

/* --- Mode Menu --- */
.mode-menu {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    overflow: hidden;
    z-index: 99;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease-out;
}

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

.mode-menu a {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.mode-menu a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.mode-menu a:hover {
    background-color: #f5f5f5;
}

.mode-menu a.active {
    background-color: var(--primary-color);
    color: white;
}

@media (max-width: 768px) {
    .mode-menu {
        bottom: 80px;
        right: 20px;
    }
    
    .mode-menu a {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* --- Loader --- */
.loader {
    border: 5px solid var(--light-gray-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none; /* Hidden by default */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Upload Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}

.modal-content {
    background-color: var(--white-color);
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

@media (max-width: 480px) {
    .modal-content {
        padding: 20px 15px;
        width: 95%;
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.upload-area {
    border: 2px dashed var(--light-gray-color);
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    margin: 20px 0;
}

.upload-area i {
    font-size: 3rem;
    color: var(--primary-color);
}

.upload-area p {
    margin: 10px 0 0;
}

.upload-area span {
    color: var(--primary-color);
    font-weight: 500;
}

.upload-form input,
.upload-form textarea,
.upload-form select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--light-gray-color);
    border-radius: 5px;
    box-sizing: border-box;
}

.upload-form textarea {
    min-height: 80px;
    resize: vertical;
}

.upload-preview {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 10px; /* Add padding to prevent scrollbar from cutting off content */
}

.preview-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 5px;
    object-fit: cover;
}

/* --- Image Detail Modal --- */
#image-detail-modal .image-detail-content {
    background: transparent;
    padding: 0;
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#image-detail-modal .image-title {
    color: var(--white-color);
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 10px;
}

#image-detail-modal img {
    max-height: calc(85vh - 120px); /* Adjust space for metadata, title, and button */
    max-width: 90vw;
    border-radius: 10px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    #image-detail-modal img {
        max-height: calc(70vh - 100px);
    }
    
    #image-detail-modal .image-title {
        font-size: 1rem;
    }
}

.image-metadata {
    display: flex;
    gap: 20px;
    color: var(--white-color);
    margin-bottom: 15px;
    font-size: 0.9rem;
}

#image-detail-modal .download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.date-header {
    grid-column: 1 / -1; /* Span across all columns */
    padding: 20px 0 10px;
    font-size: 1.2rem;
    font-weight: 500;
    border-bottom: 1px solid var(--light-gray-color);
    margin-bottom: 10px;
}

/* --- 背景模糊效果 --- */
.blurred > :not(#image-detail-modal):not(#album-image-detail-modal) {
    filter: blur(8px) !important;
    transition: filter 0.3s;
    pointer-events: none;
    user-select: none;
}

.blurred #image-detail-modal,
.blurred #album-image-detail-modal {
    filter: none !important;
    pointer-events: auto;
    user-select: auto;
}
