/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap');

/* Simple Image Viewer CSS with Blue Theme */
html, body {
    margin: 0;
    padding: 0;
    background: #306e8d;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    user-select: none;
}

/* Header Section */
.header {
    background: #306e8d;
    color: white;
    text-align: center;
    padding: 15px 20px;
    border-bottom: 2px solid #6688C3;
}

.header h1 {
    margin: 0 0 8px 0;
    font-size: 26px;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.5px;
    color: white;
}

.header h2 {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.3px;
    color: white;
}

.header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.2px;
    color: white;
}

/* Control bar */
.control-bar {
    background: #264574;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 100;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
}

.button-row {
    display: contents;
}

/* Table of Contents Button */
.toc-button {
    background: #a2abbb;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Poppins', 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 150px;
    justify-content: center;
}

.toc-button:hover {
    background: #5577B2;
}

/* TOC Modal Styles */
.toc-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.toc-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toc-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

.toc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #B8D4E3;
    background: #E9F4F8;
    border-radius: 12px 12px 0 0;
}

.toc-modal-header h3 {
    margin: 0;
    color: #0F3A4D;
    font-family: 'Poppins', sans-serif;
    font-size: 20px;
    font-weight: 600;
}

.toc-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #0F3A4D;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.toc-close:hover {
    background: rgba(15,58,77,0.1);
}

.toc-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* TOC Items in Modal */
.toc-item {
    padding: 16px 25px;
    cursor: pointer;
    border-bottom: 1px solid #E9F4F8;
    color: #333;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.1px;
    transition: all 0.2s ease;
    display: block;
}

.toc-item:hover {
    background: #B8D4E3;
    color: #0F3A4D;
}

.toc-item:last-child {
    border-bottom: none;
}

.toc-item.current {
    background: #81B4C6;
    color: #0F3A4D;
    font-weight: 600;
    border-left: 4px solid #6688C3;
}

.toc-item.major-section {
    font-weight: 600;
    font-size: 16px;
    color: #0F3A4D;
    background-color: #F3F8FB;
    letter-spacing: 0.2px;
    padding: 18px 25px;
}

.toc-item.major-section:hover {
    background-color: #E9F4F8;
}

.toc-item.major-section.current {
    background: #6688C3;
    color: white;
    font-weight: 700;
}

/* Animation keyframes */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.control-bar button {
    background: #1d2e4b;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Poppins', 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
}

.control-bar button:hover {
    background: #5577B2;
}

.control-bar button:disabled {
    background: #1d2e4b;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Viewer container */
#viewer-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #1B5471;
    display: flex;
    justify-content: center;
    align-items: center;
}

#image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 100%;
    min-height: 100%;
    transition: transform 0.3s ease;
    transform-origin: center center;
    overflow: hidden;
}

.handbook-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 70%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    background: white;
    cursor: grab;
    transition: transform 0.35s cubic-bezier(0.4, 0.0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
}

.handbook-image.active {
    opacity: 1;
}

.handbook-image.loading {
    opacity: 0.5;
}

.handbook-image:active {
    cursor: grabbing;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 18px;
    background: rgba(15, 58, 77, 0.9);
    padding: 20px;
    border-radius: 8px;
    display: none;
    z-index: 10;
}

.loading.show {
    display: block;
    animation: pulse 1.5s infinite;
}

.error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-align: center;
    background: rgba(198, 40, 40, 0.9);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 10;
}

.error h3 {
    margin: 0 0 10px 0;
    color: white;
}

.error p {
    margin: 0;
    color: #ffcccc;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.zoomed #viewer-container {
    overflow: auto;
}

.zoomed .handbook-image {
    cursor: grab;
}

.zoomed .handbook-image:active {
    cursor: grabbing;
}

/* BOTTOM BAR - WITH HOME BUTTON FIX */
.bottom-bar {
    background: #2f4a53;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px; /* ← ADDED: spacing between elements */
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    z-index: 100;
}

#pageInfo {
    font-weight: 600;
    color: #fff;
    font-size: 17px;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.3px;
    text-align: center;
}

/* HOME BUTTON STYLES - ADDED */
.home-button {
    background: #1d2e4b;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Poppins', 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-button:hover {
    background: #5577B2;
}

/* Responsive design */
@media (min-width: 1200px) {
    .handbook-image {
        max-width: 60%;
        max-height: 75vh;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .handbook-image {
        max-width: 85%;
        max-height: 85vh;
    }
}

@media (max-width: 768px) {
    .control-bar {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .nav-controls {
        gap: 12px;
    }
    
    .control-bar button {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .toc-button {
        padding: 10px 18px;
        font-size: 14px;
        min-width: 130px;
    }
    
    .handbook-image {
        max-width: 90%;
        max-height: 90vh;
    }
    
    /* HOME BUTTON - TABLET */
    .home-button {
        padding: 8px 14px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 10px 15px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .header h2 {
        font-size: 16px;
    }
    
    .header h3 {
        font-size: 14px;
    }
    
    .control-bar {
        padding: 8px 10px;
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .button-row {
        display: flex;
        width: 100%;
        gap: 10px;
        order: 1;
    }
    
    .button-row button,
    .toc-button {
        height: 46px;
        padding: 12px 18px;
        font-size: 11px;
        font-weight: 500;
        letter-spacing: 0.2px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        flex: 1;
    }
    
    .toc-button {
        width: 100%;
        min-width: auto;
    }
    
    .nav-controls {
        display: none !important;
    }
    
    #prevBtn,
    #nextBtn {
        display: none !important;
    }
    
    /* BOTTOM BAR - MOBILE */
    .bottom-bar {
        padding: 10px 15px;
        gap: 12px; /* ← SMALLER GAP ON MOBILE */
    }
    
    #pageInfo {
        font-size: 15px;
    }
    
    /* HOME BUTTON - MOBILE */
    .home-button {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .handbook-image {
        max-width: 95%;
        max-height: 95vh;
    }
    
    .toc-modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px;
    }
    
    .toc-modal-header {
        padding: 15px 20px;
    }
    
    .toc-modal-header h3 {
        font-size: 18px;
    }
    
    .toc-item {
        padding: 14px 20px;
        font-size: 14px;
    }
    
    .toc-item.major-section {
        padding: 16px 20px;
        font-size: 15px;
    }
}

/* Disable text selection and image dragging */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

/* Custom scrollbar for zoomed view */
#viewer-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#viewer-container::-webkit-scrollbar-track {
    background: #81B4C6;
}

#viewer-container::-webkit-scrollbar-thumb {
    background: #6688C3;
    border-radius: 6px;
}

#viewer-container::-webkit-scrollbar-thumb:hover {
    background: #5577B2;
}

/* Custom scrollbar for modal */
.toc-modal-body::-webkit-scrollbar {
    width: 8px;
}

.toc-modal-body::-webkit-scrollbar-track {
    background: #F3F8FB;
}

.toc-modal-body::-webkit-scrollbar-thumb {
    background: #9BB5CC;
    border-radius: 4px;
}

.toc-modal-body::-webkit-scrollbar-thumb:hover {
    background: #81B4C6;
}

/* Smooth transition styles for page changes */
#image-wrapper {
    will-change: transform;
}

.handbook-image {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

