/* style.css - Professional Hair Training Manual (Fully Responsive) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(145deg, #f6efe3 0%, #ede3d4 100%);
    color: #1e2a32;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* ========== HEADER ========== */
.clean-header {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(2px);
    padding: 12px 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 1px solid #e9dfd1;
    position: sticky;
    top: 0;
    z-index: 60;
    width: 100%;
}

.title-section h1 {
    font-size: clamp(1rem, 5vw, 1.4rem);
    font-weight: 700;
    color: #1e3a5f;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.title-section .eng-sub {
    font-size: clamp(0.6rem, 3vw, 0.7rem);
    font-weight: 400;
    color: #7c6e5d;
    margin-top: 4px;
}

.page-indicator-compact {
    background: #f0e7dc;
    padding: 4px 12px;
    border-radius: 60px;
    font-size: clamp(0.75rem, 3.5vw, 0.9rem);
    font-weight: 600;
    color: #1e3a5f;
    white-space: nowrap;
}

.profile-icon {
    background: #1e3a5f;
    color: white;
    width: clamp(32px, 8vw, 35px);
    height: clamp(32px, 8vw, 35px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: clamp(1rem, 4vw, 1.2rem);
    border: 2px solid #e9dfd1;
    flex-shrink: 0;
}

/* ========== BOOK CONTAINER ========== */
.book-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    padding: 10px 12px 70px 12px;
    min-height: 0;
}

#pages-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ========== PAGE STYLES ========== */
.page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.25);
    padding: 16px 18px;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    transition: opacity 0.3s ease;
    scroll-behavior: smooth;
}

.page.active {
    display: flex;
    animation: fadeSlide 0.35s ease-out;
}

@keyframes fadeSlide {
    from { opacity: 0; transform: translateX(6px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border-bottom: 2px solid #f0e2d0;
    padding-bottom: 10px;
    flex-shrink: 0;
}

.page-number {
    background: #1e3a5f;
    color: white;
    width: clamp(32px, 8vw, 36px);
    height: clamp(32px, 8vw, 36px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: clamp(0.9rem, 4vw, 1.1rem);
    flex-shrink: 0;
}

.page h2 {
    font-size: clamp(0.95rem, 4.5vw, 1.3rem);
    font-weight: 700;
    color: #1e3a5f;
    line-height: 1.25;
    flex: 1;
}

/* Page Image */
.page-image {
    width: 100%;
    border-radius: 16px;
    margin: 8px 0 14px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    object-fit: cover;
    background: #f9f3ea;
    max-height: 250px;
    flex-shrink: 0;
}

/* Page Content */
.page-content {
    flex: 1;
    line-height: 1.6;
    font-size: clamp(0.85rem, 4vw, 1rem);
    color: #2c3e2f;
    overflow-y: auto;
}

.page-content p {
    margin-bottom: 10px;
}

.page-content ul, .page-content ol {
    padding-left: 20px;
    margin: 10px 0;
}

.page-content li {
    margin-bottom: 6px;
}

.page-content table {
    width: 100%;
    font-size: clamp(0.7rem, 3.5vw, 0.85rem);
}

/* Page Footer Logo */
.page::after {
    content: "";
    display: block;
    width: 100%;
    height: 40px;
    background-image: url('img/logo.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    opacity: 0.4;
    margin-top: 16px;
    flex-shrink: 0;
}

/* ========== NAVIGATION ========== */
.nav-simple {
    position: fixed;
    bottom: 12px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 8px 16px;
    z-index: 100;
    background: transparent;
}

.arrow-btn {
    background: rgba(30, 58, 95, 0.85);
    backdrop-filter: blur(8px);
    border: none;
    width: clamp(44px, 12vw, 48px);
    height: clamp(44px, 12vw, 48px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    font-size: clamp(1.5rem, 6vw, 2rem);
    font-weight: 300;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.arrow-btn:active {
    transform: scale(0.94);
    background: rgba(30, 58, 95, 1);
}

.counter-simple {
    font-size: clamp(0.8rem, 4vw, 1rem);
    font-weight: 600;
    color: #1e3a5f;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 40px;
    text-align: center;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    min-width: 65px;
}

/* ========== FAB BUTTON ========== */
.fab {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: clamp(48px, 12vw, 54px);
    height: clamp(48px, 12vw, 54px);
    background: #1e3a5f;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
    z-index: 200;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.fab:active {
    transform: scale(0.94);
}

/* ========== FAB MENU ========== */
.fab-menu {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: min(280px, 85vw);
    background: #fffef7;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: none;
    z-index: 300;
    max-height: 60vh;
    overflow-y: auto;
}

.fab-menu.active {
    display: block;
    animation: menuPop 0.2s ease;
}

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

.menu-header {
    background: #1e3a5f;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

#close-menu {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
}

#toc-list {
    list-style: none;
}

#toc-list li {
    padding: 12px 16px;
    border-bottom: 1px solid #f0e2d4;
    font-size: clamp(0.8rem, 3.5vw, 0.9rem);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

#toc-list li:hover {
    background: #f9efe5;
}

/* ========== PROFILE OVERLAY ========== */
#profile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 20000;
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

#profile-overlay[style*="display: block"] {
    display: flex !important;
}

.profile-modal {
    background: white;
    width: min(320px, 85%);
    max-height: 80vh;
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow-y: auto;
}

.close-profile-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #eee;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
}

.profile-avatar {
    font-size: clamp(40px, 12vw, 50px);
    margin: 10px 0;
}

.profile-name {
    margin: 5px 0;
    color: #1e3a5f;
    font-size: clamp(1.1rem, 5vw, 1.3rem);
}

.profile-username {
    margin: 0;
    color: #666;
    font-size: clamp(0.8rem, 3.5vw, 0.85rem);
}

.profile-divider {
    margin: 15px 0;
    border: 0;
    border-top: 1px solid #eee;
}

.profile-info {
    text-align: left;
    margin-bottom: 20px;
    font-size: clamp(0.85rem, 4vw, 0.9rem);
    padding: 0 5px;
}

.logout-btn {
    background: #d9534f;
    color: white;
    border: none;
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    font-size: clamp(0.9rem, 4vw, 1rem);
}

/* ========== SCROLLBAR ========== */
.page::-webkit-scrollbar {
    width: 3px;
}

.page::-webkit-scrollbar-track {
    background: #f0e2d4;
    border-radius: 10px;
}

.page::-webkit-scrollbar-thumb {
    background: #c0aa8a;
    border-radius: 10px;
}

/* ========== VERY SMALL DEVICES (<= 380px) ========== */
@media (max-width: 380px) {
    .clean-header {
        padding: 8px 12px;
    }
    
    .page {
        padding: 12px 14px;
        border-radius: 20px;
    }
    
    .page-header {
        gap: 8px;
        margin-bottom: 12px;
    }
    
    .page-image {
        max-height: 180px;
        margin: 6px 0 10px 0;
    }
    
    .nav-simple {
        bottom: 8px;
        gap: 12px;
    }
    
    .arrow-btn {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }
    
    .fab {
        width: 44px;
        height: 44px;
        bottom: 12px;
        right: 12px;
        font-size: 1.4rem;
    }
    
    .fab-menu {
        bottom: 70px;
        right: 12px;
        width: min(260px, 90vw);
    }
    
    .profile-modal {
        padding: 20px;
    }
}

/* ========== LANDSCAPE MODE ========== */
@media (orientation: landscape) and (max-height: 500px) {
    .clean-header {
        padding: 6px 12px;
    }
    
    .title-section h1 {
        font-size: 0.9rem;
    }
    
    .title-section .eng-sub {
        font-size: 0.55rem;
    }
    
    .page-image {
        max-height: 100px;
    }
    
    .book-container {
        padding-bottom: 55px;
    }
    
    .nav-simple {
        bottom: 4px;
        gap: 15px;
    }
    
    .arrow-btn {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
    
    .fab {
        width: 40px;
        height: 40px;
        bottom: 8px;
        right: 8px;
        font-size: 1.2rem;
    }
    
    .fab-menu {
        bottom: 60px;
        right: 8px;
        max-height: 70vh;
    }
    
    .page {
        padding: 10px 14px;
    }
    
    .page-content {
        font-size: 0.8rem;
    }
}

/* ========== TABLET & LARGER ========== */
@media (min-width: 768px) {
    .book-container {
        padding: 15px 20px 80px 20px;
    }
    
    .page {
        padding: 24px 30px;
        border-radius: 32px;
    }
    
    .page-image {
        max-height: 320px;
    }
    
    .nav-simple {
        gap: 30px;
    }
    
    .arrow-btn {
        width: 55px;
        height: 55px;
        font-size: 2rem;
    }
    
    .fab {
        width: 60px;
        height: 60px;
        bottom: 24px;
        right: 24px;
        font-size: 2rem;
    }
    
    .fab-menu {
        bottom: 100px;
        right: 24px;
        width: 320px;
    }
}

/* ========== AUTH MODAL (Login/Register) ========== */
#auth-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1e3a5f;
    z-index: 30000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#auth-modal-overlay > div {
    background: white;
    padding: clamp(20px, 6vw, 30px);
    border-radius: 20px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
}