/**
 * News 3D Book Styles
 * Hiệu ứng sách 3D lật trang cho trang tin tức
 *
 * @package    ComLink
 * @subpackage Theme/CSS
 * @since      1.0.0
 */

/* ==========================================
   RESET & BASE
   ========================================== */

body.comlink-news-book {
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 50%, #0a0a1a 100%);
    color: white;
    overflow-x: hidden;
    min-height: 100vh;
}

.comlink-news-book * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Hide Flatsome elements */
.comlink-news-book #wrapper,
.comlink-news-book .header-wrapper,
.comlink-news-book .footer-wrapper,
.comlink-news-book #header,
.comlink-news-book #footer {
    display: none !important;
}

/* ==========================================
   HEADER
   ========================================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 15px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: all 0.4s ease;
}

.site-header.scrolled {
    padding: 10px 40px;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes logoBreathing {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 1))
                drop-shadow(0 0 15px rgba(255, 255, 255, 0.9))
                drop-shadow(0 0 35px rgba(255, 255, 255, 0.7));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 1))
                drop-shadow(0 0 20px rgba(255, 255, 255, 1))
                drop-shadow(0 0 45px rgba(255, 255, 255, 0.85));
    }
}

.header-logo img {
    height: 50px;
    width: auto;
    transition: all 0.3s ease;
    animation: logoBreathing 3s ease-in-out infinite;
}

.site-header.scrolled .header-logo img {
    height: 40px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 35px;
}

.header-nav a {
    color: white;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    position: relative;
    padding: 8px 0;
    transition: all 0.3s ease;
}

.header-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #00ff88, #00d4ff);
    transition: width 0.3s ease;
}

.header-nav a:hover,
.header-nav a.active {
    color: #00ff88;
}

.header-nav a:hover::after,
.header-nav a.active::after {
    width: 100%;
}

/* Mobile menu */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 10px;
    background: none;
    border: none;
}

.mobile-menu-btn span {
    width: 25px;
    height: 2px;
    background: white;
    transition: all 0.3s ease;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ==========================================
   MAIN CONTENT & BOOK WRAPPER
   ========================================== */

.book-main {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 100px 20px 60px;
    overflow: hidden;
}

.book-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
    max-width: 1000px;
}

/* ==========================================
   BOOK CONTAINER
   ========================================== */

.news-book {
    position: relative;
    /* StPageFlip will set dimensions */
}

/* Book loaded animation */
.news-book.book-loaded {
    animation: bookAppear 0.6s ease-out;
}

@keyframes bookAppear {
    from {
        opacity: 0;
        transform: scale(0.9) rotateY(-10deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotateY(0);
    }
}

/* ==========================================
   BOOK PAGES
   ========================================== */

.book-page {
    background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
    color: #1a1a2e;
    overflow: hidden;
}

/* Hard cover pages */
.book-page[data-density="hard"] {
    background: linear-gradient(145deg, #1a1a3a 0%, #0d0d20 100%);
    color: white;
}

/* Cover Page */
.book-cover {
    background: linear-gradient(145deg, #0d0d25 0%, #1a1a4a 50%, #0d0d25 100%);
    border: 2px solid rgba(0, 255, 136, 0.3);
}

.cover-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
}

/* Floating Cards Preview (Left Side of Cover) */
.floating-cards-preview {
    position: relative;
    width: 45%;
    height: 100%;
    overflow: visible;
}

.preview-card {
    position: absolute;
    width: 140px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.preview-card-1 {
    top: 8%;
    left: 15%;
    transform: rotate(-8deg);
    animation: floatCard1 4s ease-in-out infinite;
    z-index: 3;
}

.preview-card-2 {
    top: 38%;
    left: 35%;
    transform: rotate(5deg);
    animation: floatCard2 4.5s ease-in-out infinite;
    z-index: 2;
}

.preview-card-3 {
    top: 68%;
    left: 10%;
    transform: rotate(-3deg);
    animation: floatCard3 5s ease-in-out infinite;
    z-index: 1;
}

@keyframes floatCard1 {
    0%, 100% { transform: rotate(-8deg) translateY(0); }
    50% { transform: rotate(-8deg) translateY(-12px); }
}

@keyframes floatCard2 {
    0%, 100% { transform: rotate(5deg) translateY(0); }
    50% { transform: rotate(5deg) translateY(-10px); }
}

@keyframes floatCard3 {
    0%, 100% { transform: rotate(-3deg) translateY(0); }
    50% { transform: rotate(-3deg) translateY(-8px); }
}

.preview-card-img {
    width: 100%;
    height: 70px;
    overflow: hidden;
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
}

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

.preview-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.preview-card-text {
    padding: 8px 10px;
    background: white;
}

.preview-card-date {
    display: block;
    font-size: 9px;
    color: #888;
    margin-bottom: 3px;
}

.preview-card-title {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.3;
}

/* Cover Content (Right Side) */
.cover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 55%;
    height: 100%;
    padding: 20px 25px 20px 10px;
    text-align: center;
}

.cover-badge {
    display: inline-block;
    padding: 6px 16px;
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.4);
    border-radius: 20px;
    font-size: 11px;
    color: #00ff88;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 20px;
}

.cover-content h1 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 12px;
    color: white;
}

.cover-content h1 span {
    background: linear-gradient(135deg, #00ff88, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cover-subtitle {
    font-size: 13px;
    line-height: 1.5;
    opacity: 0.7;
    margin-bottom: 25px;
    max-width: 280px;
}

.cover-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
}

.cover-stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #00ff88;
}

.stat-label {
    font-size: 11px;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cover-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    opacity: 0.5;
    animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

.cover-hint svg {
    animation: arrowBounce 1s ease-in-out infinite;
}

@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

/* ==========================================
   CONTENT PAGES
   ========================================== */

.page-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

.page-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow: hidden;
}

/* Book Card */
.book-card {
    display: flex;
    gap: 12px;
    padding: 10px;
    background: white;
    border-radius: 10px;
    text-decoration: none;
    color: #1a1a2e;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    color: #1a1a2e;
}

.book-card-image {
    position: relative;
    width: 100px;
    min-width: 100px;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

.book-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
    font-size: 28px;
    opacity: 0.5;
}

.book-card-category {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 8px;
    background: #00ff88;
    border-radius: 4px;
    font-size: 9px;
    color: white;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

.book-card-content time {
    font-size: 10px;
    color: #888;
    margin-bottom: 4px;
}

.book-card-content h3 {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    color: #1a1a2e;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

/* Page Footer */
.page-footer {
    display: flex;
    justify-content: center;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: auto;
}

.page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #00ff88, #00d4ff);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

/* ==========================================
   BACK COVER
   ========================================== */

.book-back {
    background: linear-gradient(145deg, #0d0d25 0%, #1a1a4a 50%, #0d0d25 100%);
    border: 2px solid rgba(0, 255, 136, 0.3);
}

.back-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 30px;
    text-align: center;
}

.load-more-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 40px;
}

.load-more-section p {
    font-size: 14px;
    opacity: 0.7;
}

.load-more-section strong {
    color: #00ff88;
}

.load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.2), rgba(0, 212, 255, 0.2));
    border: 1px solid rgba(0, 255, 136, 0.4);
    border-radius: 30px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.4), rgba(0, 212, 255, 0.4));
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 255, 136, 0.2);
}

.load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.loading-spinner span {
    font-size: 12px;
    opacity: 0.7;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 255, 136, 0.2);
    border-top-color: #00ff88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.all-loaded {
    font-size: 14px;
    opacity: 0.6;
    padding: 20px;
}

.back-footer {
    margin-top: auto;
}

.back-logo img {
    height: 40px;
    width: auto;
    opacity: 0.8;
    margin-bottom: 15px;
}

.back-footer p {
    font-size: 12px;
    opacity: 0.5;
    margin-bottom: 10px;
}

.back-links {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.back-links a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 12px;
    transition: color 0.3s ease;
}

.back-links a:hover {
    color: #00ff88;
}

/* ==========================================
   BOOK NAVIGATION
   ========================================== */

.book-nav {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.btn-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-nav:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.2);
    border-color: rgba(0, 255, 136, 0.4);
    transform: scale(1.1);
}

.btn-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-nav svg {
    width: 18px;
    height: 18px;
}

.page-indicator {
    font-size: 14px;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
}

.page-indicator #current-page {
    color: #00ff88;
    font-weight: 700;
}

/* Keyboard hint */
.keyboard-hint {
    font-size: 12px;
    opacity: 0.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyboard-hint span {
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-family: monospace;
}

/* ==========================================
   FOOTER
   ========================================== */

.book-footer {
    position: relative;
    padding: 60px 20px 30px;
    background: linear-gradient(to bottom, rgba(10, 10, 26, 0.95), rgba(5, 5, 15, 1));
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 40px;
}

/* Office Cards Grid */
.footer-offices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto 40px;
    padding: 0 20px;
}

.office-card {
    text-align: center;
    padding: 25px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.office-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 255, 136, 0.2);
    transform: translateY(-5px);
}

.office-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(139, 92, 246, 0.15));
    border-radius: 12px;
}

.office-icon svg {
    width: 26px;
    height: 26px;
    stroke: #a855f7;
}

.office-card h4 {
    color: #00ff88;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 10px;
}

.office-card p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

/* Footer Bottom */
.footer-bottom {
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-bottom p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
    margin: 15px 0 0;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.footer-social a {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    transition: all 0.3s ease;
}

.footer-social a:hover {
    background: rgba(0, 255, 136, 0.2);
    border-color: rgba(0, 255, 136, 0.4);
    transform: translateY(-2px);
}

.footer-social svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ==========================================
   RESPONSIVE - TABLET
   ========================================== */

@media (max-width: 900px) {
    .header-nav {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: rgba(10, 10, 26, 0.98);
        flex-direction: column;
        padding: 30px;
        gap: 20px;
        transform: translateY(-150%);
        opacity: 0;
        transition: all 0.3s ease;
    }

    .header-nav.active {
        transform: translateY(0);
        opacity: 1;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .site-header {
        padding: 15px 20px;
    }

    .book-main {
        padding: 90px 15px 80px;
    }

    .floating-cards-preview {
        display: none;
    }

    .cover-wrapper {
        flex-direction: column;
    }

    .cover-content {
        width: 100%;
        padding: 30px;
    }

    .keyboard-hint {
        display: none;
    }
}

/* ==========================================
   RESPONSIVE - MOBILE
   ========================================== */

@media (max-width: 768px) {
    .book-main {
        padding: 80px 10px 90px;
    }

    .book-wrapper {
        gap: 20px;
    }

    /* Smaller cards on mobile */
    .book-card {
        gap: 10px;
        padding: 8px;
    }

    .book-card-image {
        width: 80px;
        min-width: 80px;
    }

    .book-card-content h3 {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }

    .book-card-content time {
        font-size: 9px;
    }

    .book-card-category {
        font-size: 8px;
        padding: 2px 6px;
    }

    /* Cover adjustments */
    .cover-content h1 {
        font-size: 22px;
    }

    .cover-subtitle {
        font-size: 12px;
    }

    .stat-number {
        font-size: 22px;
    }

    .cover-stats {
        gap: 20px;
    }

    /* Navigation */
    .book-nav {
        padding: 10px 15px;
        gap: 10px;
    }

    .btn-nav {
        width: 36px;
        height: 36px;
    }

    .btn-first,
    .btn-last {
        display: none;
    }

    .page-indicator {
        font-size: 13px;
    }

    /* Footer */
    .book-footer {
        padding: 40px 15px 25px;
    }

    .footer-offices {
        grid-template-columns: 1fr;
        gap: 20px;
        margin-bottom: 30px;
    }

    .office-card {
        padding: 20px 15px;
    }

    .office-icon {
        width: 45px;
        height: 45px;
    }

    .office-icon svg {
        width: 22px;
        height: 22px;
    }

    .office-card h4 {
        font-size: 0.95rem;
    }

    .office-card p {
        font-size: 0.8rem;
    }

    .footer-social a {
        width: 36px;
        height: 36px;
    }

    .footer-social svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 15px;
    }

    .page-cards {
        gap: 8px;
    }

    .book-card {
        gap: 8px;
        padding: 6px;
    }

    .book-card-image {
        width: 70px;
        min-width: 70px;
    }

    .book-card-content h3 {
        font-size: 11px;
    }

    .cover-content {
        padding: 20px;
    }

    .cover-content h1 {
        font-size: 20px;
    }

    .cover-badge {
        font-size: 10px;
        padding: 4px 12px;
    }
}

/* ==========================================
   ACCESSIBILITY
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    .news-book.book-loaded {
        animation: none;
    }
}

/* Focus styles */
.btn-nav:focus,
.load-more-btn:focus,
.book-card:focus {
    outline: 2px solid #00ff88;
    outline-offset: 2px;
}

/* ==========================================
   STPAGEFLIP OVERRIDES
   ========================================== */

/* Canvas styling */
.stf__parent {
    margin: 0 auto;
    display: block !important;
}

/* Page shadows */
.stf__block {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* Soft page curl effect */
.stf__item {
    background-color: transparent !important;
}

/* Book container */
#news-book {
    display: block;
    margin: 0 auto;
    min-height: 500px;
}

/* Hide pages initially - StPageFlip will show them */
#news-book > .book-page {
    position: absolute;
    left: -9999px;
}

/* When StPageFlip is active, it creates .stf__parent wrapper */
.stf__parent .book-page,
#news-book.book-loaded .book-page {
    position: relative;
    left: auto;
}

/* Fallback: Show pages if StPageFlip fails to initialize */
#news-book.fallback-mode > .book-page {
    position: relative;
    left: auto;
    display: block;
    max-width: 450px;
    margin: 20px auto;
    min-height: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
