/* =========================================
   1. Global Reset & Typography
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'ZCOOL KuaiLe', 'YouYuan', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background-color: #fff0f5; /* Changed to LavenderBlush */
    background-image: linear-gradient(to bottom, #fff0f5 0%, #fff5f8 100%);
    color: #4a2c36; /* Deep plum text */
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

button {
    font-family: 'YouYuan', 'Microsoft YaHei', sans-serif;
    outline: none;
    border-radius: 25px; /* Ensure global rounded buttons */
    font-weight: 800; /* Much bolder font */
}

/* =========================================
   2. Page Visibility Logic
   ========================================= */
.page {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding-bottom: 50px;
    animation: fadeIn 0.4s ease-out;
}

.page.active {
    display: block;
}

/* Specific override for Cover Page to use Flexbox */
.page.cover-page.active {
    display: flex;
}

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

/* =========================================
   3. Cover Page (Page 0)
   ========================================= */
.cover-page {
    background: linear-gradient(135deg, #fff0f5 0%, #ffebf0 100%);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.cover-bg-pattern {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: radial-gradient(#ff80ab 1.5px, transparent 1.5px);
    background-size: 30px 30px;
    opacity: 0.15;
    z-index: 0;
}

#trail-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
}

.floating-icons {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
}

.float-icon {
    position: absolute;
    font-size: 24px;
    left: var(--x);
    top: var(--y);
    animation: float 6s ease-in-out infinite;
    opacity: 0.6;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.cover-content {
    position: relative;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px 40px;
    margin-top: clamp(10px, 3vh, 32px);
    border-radius: 30px;
    box-shadow: 0 15px 40px rgba(255, 105, 180, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid #fff0f5;
    max-width: 90%;
}

.cover-avatar {
    font-size: clamp(40px, 8vw, 60px);
    margin-bottom: 25px;
    animation: bounce 2s infinite;
    filter: drop-shadow(0 4px 6px rgba(255, 105, 180, 0.3));
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.cover-title {
    font-size: clamp(2rem, 5vw, 2.8rem);
    color: #ff4081; /* Pink */
    margin-bottom: 20px;
    background: linear-gradient(45deg, #ff80ab, #ff4081); /* Brighter pink gradient */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800; /* Reduced from 900 */
    font-family: 'YouYuan', 'Microsoft YaHei', sans-serif; /* Rounded */
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(255, 105, 180, 0.2);
    /* Removed text-stroke */
}

.cover-subtitle {
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: #ff80ab; /* Softer pink */
    margin-bottom: 35px;
    font-weight: 700; /* Bold */
    font-family: 'YouYuan', 'Microsoft YaHei', sans-serif; /* Rounded */
    letter-spacing: 1px;
    /* Removed text-stroke */
}

.cover-start-btn {
    background: linear-gradient(90deg, #ff80ab, #ff4081);
    color: white;
    border: none;
    padding: 12px 28px;
    font-size: 1rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 64, 129, 0.3);
    transition: transform 0.3s, box-shadow 0.3s;
    font-weight: 800; /* Reduced from 900 */
    letter-spacing: 1px;
    /* Removed text-stroke */
}

.cover-start-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 25px rgba(255, 64, 129, 0.5);
    background: linear-gradient(90deg, #ff4081, #f50057);
}

/* =========================================
   4. Main Page (Page 1) & Header
   ========================================= */
.header {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    margin-bottom: 30px;
    border-radius: 0 0 30px 30px;
    box-shadow: 0 4px 20px rgba(255, 105, 180, 0.15); /* Pink shadow */
    position: relative;
    border-bottom: 3px solid #ffeff5;
}

.header h1 {
    margin-bottom: 5px;
    color: #ff4081; /* Bright pink */
    font-weight: 800; /* Extra bold */
    font-family: 'YouYuan', 'Microsoft YaHei', sans-serif; /* Rounded */
    text-shadow: 2px 2px 4px rgba(255, 182, 193, 0.2);
    letter-spacing: 2px;
    /* Removed text-stroke */
}

.subtitle {
    color: #ff80ab; /* Softer pink */
    margin-bottom: 20px;
    font-weight: 600; /* Bold */
    font-family: 'YouYuan', 'Microsoft YaHei', sans-serif; /* Rounded */
    letter-spacing: 1px;
    /* Removed text-stroke */
}

.intro-btn {
    background: #ff80ab; /* Solid pink */
    border: none;
    color: white;
    padding: 10px 28px;
    border-radius: 25px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    font-weight: 800; /* Much bolder */
    box-shadow: 0 4px 10px rgba(255, 64, 129, 0.3);
    /* Removed text-stroke */
}

.intro-btn:hover {
    background: linear-gradient(135deg, #ff4081, #f50057);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 64, 129, 0.5);
}

/* Back Button Style */
.back-btn {
    background: #ff80ab;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 25px;
    font-weight: 800; /* Much bolder */
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(255, 105, 180, 0.3);
    transition: all 0.3s ease;
    /* Removed text-stroke */
}

.back-btn .back-icon {
    font-weight: 800;
    /* Removed text-stroke */
}

.back-btn:hover {
    background: #ff4081;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 64, 129, 0.4);
}

.back-btn .back-icon {
    font-weight: 900;
}

/* =========================================
   5. Cards Layout (Home Categories)
   ========================================= */
.cards-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.card {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 182, 193, 0.2);
    transition: all 0.3s ease;
    border: 2px solid #fff0f5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    position: relative;
    overflow: hidden;
    /* 3 items per row: (100% - 2 * 30px gap) / 3 */
    width: calc((100% - 60px) / 3);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(255, 105, 180, 0.25);
    border-color: #ff80ab;
}

/* Responsive adjustments */
/* Keep 3 columns on typical laptops/tablets; switch to 2 only below 768px */
@media (max-width: 768px) {
    .cards-container {
        max-width: 700px;
    }
    
    .card {
        /* 2 items per row: (100% - 30px gap) / 2 */
        width: calc((100% - 30px) / 2);
    }
}

@media (max-width: 600px) {
    .card {
        /* 1 item per row */
        width: 100%;
    }
}

.card-icon {
    font-size: clamp(36px, 5vw, 44px);
    margin-bottom: 14px;
    filter: drop-shadow(0 4px 6px rgba(255, 105, 180, 0.2));
    transition: transform 0.3s ease;
}

.card:hover .card-icon {
    transform: scale(1.1);
}

.card-title {
    font-size: 24px;
    font-weight: 800; /* Extra bold */
    color: #ff4081; /* Pink */
    letter-spacing: 1px;
    font-family: 'YouYuan', 'Microsoft YaHei', sans-serif; /* Rounded font */
    text-shadow: 2px 2px 4px rgba(255, 182, 193, 0.2);
    /* Removed text-stroke */
}

/* =========================================
   6. Detail Content & Items
   ========================================= */
.detail-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.ai-card, .video-card {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(255, 182, 193, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    border: 1px solid #fff0f5;
}

.ai-card:hover, .video-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(255, 105, 180, 0.3);
    border-color: #ff80ab;
}

.ai-thumbnail, .video-thumbnail {
    width: 100%;
    min-height: 150px;
    max-height: 400px;
    background: #fff0f5;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-thumbnail img, .video-thumbnail img, .video-thumbnail video {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.ai-card:hover .ai-thumbnail img, 
.video-card:hover .video-thumbnail img,
.video-card:hover .video-thumbnail video {
    transform: scale(1.05);
}

.ai-info, .video-info {
    padding: 15px;
}

.ai-info h3, .video-info h3 {
    font-size: 16px;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #880e4f;
    font-weight: 800; /* Much bolder */
}

.ai-info p, .video-info p {
    font-size: 13px;
    color: #885566; /* Warm grey/pink */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

/* Play icon overlay */
.play-icon {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    background: rgba(0,0,0,0.6);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    pointer-events: none;
}

/* =========================================
   7. Modals (Image & PDF)
   ========================================= */
.image-modal, .pdf-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.image-modal img {
    max-width: 60%;  /* Restricted width as requested */
    max-height: 60vh; /* Restricted height as requested */
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.modal-close-btn {
    position: absolute;
    top: 20px; right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    z-index: 2001;
}

/* =========================================
   8. Admin Panel
   ========================================= */
.admin-panel {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #f8f9fa;
    z-index: 1500;
    overflow-y: auto;
    padding: 20px;
}

.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.admin-tab {
    padding: 8px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    white-space: nowrap;
}

.admin-tab.active {
    background: #ff6b9d;
    color: white;
    border-color: #ff6b9d;
}

.admin-works-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.admin-work-item {
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: relative;
}

.admin-work-thumbnail {
    height: 120px;
    background: #eee;
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
}

.admin-work-thumbnail img, .admin-work-thumbnail video {
    width: 100%; height: 100%; object-fit: cover;
}

/* =========================================
   9. Image Counter & Pagination (From Previous)
   ========================================= */
.image-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 500;
    pointer-events: none;
    z-index: 2002;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: none; /* Initially hidden */
}

.admin-batch-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(255, 107, 157, 0.05);
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
}

/* Pagination / Carousel Layout */
.paginated-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
    padding: 20px 0;
    position: relative;
    min-height: 300px; /* Ensure height stability */
}

.items-wrapper {
    display: flex;
    gap: 20px;
    flex: 1;
    justify-content: center;
    width: 100%;
}

.items-wrapper .card-item {
    flex: 0 0 calc(33.333% - 14px); /* Default 3 per row */
    max-width: calc(33.333% - 14px);
    margin: 0; 
    width: 100%;
}

/* Responsive: Match JS itemsPerPage */
@media (max-width: 768px) {
    .items-wrapper .card-item {
        flex: 0 0 100%; /* 1 per row */
        max-width: 100%;
    }
}

.pagination-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #ff80ab;
    color: #ff80ab;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(255, 107, 157, 0.15);
}

.pagination-btn:hover:not(:disabled) {
    background: #ff80ab;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(255, 107, 157, 0.3);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #ccc;
    color: #ccc;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: none;
}

/* Responsive: 1 item per row on mobile */
@media (max-width: 768px) {
    .items-wrapper .ai-card,
    .items-wrapper .video-card {
        flex: 0 0 100%;
        max-width: 100%;
    }
}
