/* 夜間主題 EPUB 閱讀器首頁樣式 */

/* 全域重置與基礎設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: #e0e0e0;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* 夜空背景動畫 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(2px 2px at 20% 30%, #fff, transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90% 40%, #fff, transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 80% 10%, #fff, transparent);
    background-repeat: repeat;
    background-size: 550px 550px, 350px 350px, 250px 250px, 150px 150px, 400px 400px;
    animation: twinkle 8s ease-in-out infinite alternate;
    z-index: 1;
    pointer-events: none;
}

@keyframes twinkle {
    0% { opacity: 0.3; }
    100% { opacity: 0.8; }
}

/* 浮動元素動畫 */
.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.cloud {
    position: absolute;
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.1);
    animation: float 20s ease-in-out infinite;
}

.cloud::before {
    content: '\f0c2';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.cloud-1 {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.cloud-2 {
    top: 20%;
    right: 20%;
    animation-delay: -5s;
}

.cloud-3 {
    top: 60%;
    left: 5%;
    animation-delay: -10s;
}

.leaf {
    position: absolute;
    font-size: 1.5rem;
    color: rgba(76, 175, 80, 0.3);
    animation: drift 15s ease-in-out infinite;
}

.leaf-1 {
    top: 15%;
    right: 15%;
    animation-delay: 0s;
}

.leaf-2 {
    top: 45%;
    right: 10%;
    animation-delay: -7s;
}

.leaf-3 {
    top: 70%;
    right: 25%;
    animation-delay: -12s;
}

.book-icon {
    position: absolute;
    font-size: 1.8rem;
    color: rgba(255, 193, 7, 0.4);
    animation: pulse 8s ease-in-out infinite;
}

.book-1 {
    top: 25%;
    left: 80%;
    animation-delay: -3s;
}

.book-2 {
    top: 80%;
    left: 15%;
    animation-delay: -6s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) translateX(0px); }
    25% { transform: translateY(-20px) translateX(10px); }
    50% { transform: translateY(-10px) translateX(-10px); }
    75% { transform: translateY(-30px) translateX(5px); }
}

@keyframes drift {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(5deg); }
    50% { transform: translateY(-25px) rotate(-3deg); }
    75% { transform: translateY(-10px) rotate(8deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

/* 主要內容區域 */
.main-wrapper {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 3rem;
}

/* 標題區域 */
.hero-section {
    text-align: center;
    margin-bottom: 2rem;
}

.hero-content {
    max-width: 800px;
}

.main-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 20px rgba(138, 43, 226, 0.5);
}

.title-line {
    display: block;
    line-height: 0.9;
}

.title-line.highlight {
    background: linear-gradient(135deg, #8a2be2, #da70d6, #9370db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.title-line.highlight::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #8a2be2, transparent);
    border-radius: 2px;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: #b0b0b0;
    font-weight: 300;
    margin-top: 1rem;
}

/* 上傳區域 */
.upload-section {
    width: 100%;
    max-width: 900px;
}

.upload-container {
    background: rgba(26, 26, 46, 0.8);
    border: 2px dashed rgba(138, 43, 226, 0.3);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.upload-container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #8a2be2, #da70d6, #9370db, #8a2be2);
    border-radius: 20px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.upload-container:hover::before {
    opacity: 0.7;
}

.upload-container:hover {
    border-color: rgba(138, 43, 226, 0.6);
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(138, 43, 226, 0.2);
}

.upload-visual {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.book-stack {
    display: flex;
    gap: 8px;
    transform: perspective(100px) rotateY(-15deg);
}

.book {
    width: 40px;
    height: 60px;
    border-radius: 4px;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.book-red { background: linear-gradient(135deg, #e53e3e, #c53030); }
.book-blue { background: linear-gradient(135deg, #3182ce, #2c5282); }
.book-green { background: linear-gradient(135deg, #38a169, #2f855a); }

.book::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255,255,255,0.3);
    border-radius: 1px;
}

.magic-sparkles {
    display: flex;
    gap: 1rem;
}

.sparkle {
    font-size: 1.5rem;
    animation: sparkle 2s ease-in-out infinite;
}

.sparkle:nth-child(2) { animation-delay: 0.6s; }
.sparkle:nth-child(3) { animation-delay: 1.2s; }

@keyframes sparkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2) rotate(180deg); }
}

.upload-content h2 {
    font-size: 2rem;
    color: #ffffff;
    margin-bottom: 1rem;
    font-weight: 600;
}

.upload-description {
    color: #b0b0b0;
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* 按鈕樣式 */
.primary-button, .secondary-button {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    position: relative;
    overflow: hidden;
}

.primary-button {
    background: linear-gradient(135deg, #8a2be2, #9370db);
    color: white;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.4);
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(138, 43, 226, 0.6);
}

.secondary-button {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.button-icon {
    font-size: 1.2rem;
}

/* 分隔線 */
.divider {
    margin: 2rem 0;
    position: relative;
    text-align: center;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
}

.divider-text {
    background: rgba(26, 26, 46, 0.8);
    padding: 0 1.5rem;
    color: #9a9a9a;
    font-size: 0.9rem;
}

/* URL 輸入區域 */
.url-section {
    margin-top: 2rem;
}

.url-title {
    font-size: 1.3rem;
    color: #ffffff;
    margin-bottom: 1rem;
    font-weight: 500;
}

.url-input-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.url-input {
    flex: 1;
    min-width: 300px;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-size: 1rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.url-input:focus {
    outline: none;
    border-color: rgba(138, 43, 226, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.url-input::placeholder {
    color: #888;
}

/* 最近閱讀區域 */
.recent-section {
    width: 100%;
    max-width: 1200px;
    margin-top: 3rem;
}

.recent-container {
    background: rgba(26, 26, 46, 0.6);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(15px);
}

.recent-title {
    font-size: 1.8rem;
    color: #ffffff;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 600;
}

.title-icon {
    font-size: 2rem;
}

.recent-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.recent-book-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.recent-book-item:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 30px rgba(138, 43, 226, 0.3);
}

.book-cover {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.3), rgba(147, 112, 219, 0.3));
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.4), rgba(147, 112, 219, 0.4));
    color: rgba(255, 255, 255, 0.6);
    font-size: 3rem;
}

.cover-placeholder.loading {
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.4), rgba(126, 87, 194, 0.4));
    animation: pulse 1.5s ease-in-out infinite;
}

.cover-placeholder.loading i {
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.9; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cover-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 2rem 1rem 1rem;
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.book-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-info .book-title {
    color: #ffffff;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.3;
}

.book-info .book-author {
    color: #b0b0b0;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.book-progress {
    margin-bottom: 1rem;
}

.progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #8a2be2, #9370db);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8rem;
    color: #9370db;
    font-weight: 500;
}

.book-date {
    color: #888;
    font-size: 0.8rem;
    margin-top: auto;
    margin-bottom: 0.5rem;
}

.book-actions {
    margin-top: 0.5rem;
}

.reselect-file-btn {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.8), rgba(147, 112, 219, 0.8));
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
    justify-content: center;
}

.reselect-file-btn:hover {
    background: linear-gradient(135deg, rgba(138, 43, 226, 1), rgba(147, 112, 219, 1));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(138, 43, 226, 0.3);
}

.reselect-file-btn i {
    font-size: 0.8rem;
}

/* 載入動畫 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(10px);
}

.loading-content {
    text-align: center;
    color: #e0e0e0;
}

.loading-animation {
    margin-bottom: 2rem;
}

.book-loading {
    display: inline-flex;
    gap: 5px;
}

.book-page {
    width: 8px;
    height: 40px;
    background: linear-gradient(135deg, #8a2be2, #9370db);
    border-radius: 2px;
    animation: bookFlip 1.5s ease-in-out infinite;
}

.book-page:nth-child(2) { animation-delay: 0.2s; }
.book-page:nth-child(3) { animation-delay: 0.4s; }

@keyframes bookFlip {
    0%, 100% { transform: scaleY(1); opacity: 1; }
    50% { transform: scaleY(0.5); opacity: 0.7; }
}

.loading-text {
    font-size: 1.2rem;
    color: #b0b0b0;
}

/* 拖拽樣式 */
.upload-container.drag-over {
    border-color: rgba(138, 43, 226, 0.8);
    background: rgba(138, 43, 226, 0.1);
    transform: scale(1.02);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .main-wrapper {
        padding: 1rem;
        gap: 2rem;
    }
    
    .upload-container {
        padding: 2rem 1.5rem;
    }
    
    .url-input-group {
        flex-direction: column;
    }
    
    .url-input {
        min-width: 100%;
    }
    
    .upload-visual {
        flex-direction: column;
        gap: 1rem;
    }
    
    .recent-books-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }
    
    .book-cover {
        height: 180px;
    }
    
    .cover-title {
        font-size: 0.9rem;
        padding: 1.5rem 0.8rem 0.8rem;
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .upload-container {
        padding: 1.5rem 1rem;
    }
    
    .recent-books-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .book-cover {
        height: 160px;
    }
    
    .cover-title {
        font-size: 0.85rem;
        padding: 1.2rem 0.6rem 0.6rem;
    }
    
    .book-info {
        padding: 1rem;
    }
}
