/**
 * Copyright (c) 2026 TheAlgrow (thealgrow.com)
 * All rights reserved.
 * 
 * This code is proprietary and NOT public.
 * Unauthorized copying, modification, or distribution of this code 
 * via any medium is strictly prohibited. 
 * Any such unauthorized use will be subject to legal action.
 * 
 * Contact: contact@thealgrow.com
 */

:root {
    --primary-color: #0005FB;
    --secondary-color: #e74c3c;
    --accent-color: #3498db;
    --bg-color: #e9ecef;
    --panel-bg: #ffffff;
    --text-color: #333;
    --border-color: #ddd;
    --header-height: 80px;
    --toolbar-height: 60px;
    --sidebar-width: 250px;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

.main-header {
    background: url('/files/GTA-headerbg.png') no-repeat center center;
    background-size: cover;
    height: var(--header-height);
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--panel-bg);
    z-index: 1000;
}

.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-logo {
    max-height: 50px;
    /* Fits comfortably within the 80px header height */
    width: auto;
    object-fit: contain;
    transition: transform 0.2s;
}

.brand-logo:hover {
    transform: scale(1.02);
}

.main-nav {
    display: flex;
    gap: 25px;
}

.nav-link {
    text-decoration: none;
    color: #555;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link:hover {
    color: var(--secondary-color);
}

.admin-btn {
    background: var(--primary-color);
    color: #fff !important;
    padding: 8px 16px;
    border-radius: 4px;
}

/* Mobile Nav Elements (Hidden on Desktop) */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    padding: 8px 16px;
}

.mobile-menu-overlay {
    display: none;
}

.mobile-menu-header {
    display: none;
}

/* Toolbar */
.toolbar-wrapper {
    background: #fff;
    height: var(--toolbar-height);
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    z-index: 900;
    position: sticky;
    top: 0;
}

.toolbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}

.toolbar-content::-webkit-scrollbar {
    height: 6px;
}

.toolbar-content::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

.mobile-bottom-toolbar {
    display: contents;
    /* Strip this wrapper visually on desktop */
}

.toolbar-left,
.toolbar-center,
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    /* Keep elements from crushing on small screens */
}

.btn-tool {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-tool:hover {
    background: #f8f9fa;
    border-color: #bbb;
    color: var(--primary-color);
}

.btn-clip {
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.btn-clip:hover,
.btn-clip.active {
    background: var(--secondary-color);
    color: #fff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid #eee;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8f9fa;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid #eee;
    margin-left: 15px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.btn-icon:hover {
    transform: scale(1.1);
    color: var(--primary-color);
}

#page-num-display,
#zoom-level {
    font-weight: 700;
    min-width: 60px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

.page-select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.main-container {
    display: flex;
    flex: 1;
    position: relative;
    /* Allow sidebar sticky to work */
    align-items: flex-start;
}

.sidebar-thumbnails {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 800;

    /* Sticky Positioning & Scrolling */
    position: sticky;
    top: var(--toolbar-height);
    max-height: calc(100vh - var(--toolbar-height));
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    background: #fdfdfd;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h3 {
    font-size: 1rem;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 1px;
}

.thumbnails-grid {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.thumb-item {
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    transition: all 0.2s;
    background: #eee;
    flex-shrink: 0;
}

.thumb-item:hover {
    border-color: #ddd;
    transform: translateY(-2px);
}

.thumb-item.active {
    border-color: var(--secondary-color);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.2);
}

.thumb-item canvas {
    display: block;
    width: 100%;
    height: auto;
}

.thumb-label {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 3px 8px;
    font-size: 0.75rem;
    border-top-left-radius: 4px;
}

.viewer-area {
    flex: 1;
    position: relative;
    overflow: auto;
}

.viewer-area:fullscreen {
    padding: 0;
    background: #525659;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.viewer-area:fullscreen .pdf-container {
    margin: auto;
}

.fullscreen-controls {
    display: none;
}

.viewer-area:fullscreen .fullscreen-controls {
    position: fixed;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.btn-fs-action {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    font-size: 1.2rem;
}

.btn-fs-action:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.btn-fs-close {
    position: absolute;
    top: 20px;
    right: 20px;
}

.fs-nav-wrapper {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    transform: translateY(-50%);
}

.pdf-container {
    margin: 20px auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    position: relative;
    height: fit-content;
    width: fit-content;
    flex-shrink: 0;
}

.pdf-viewer {
    background: #fff;
    line-height: 0;
    /* Remove gap under canvas */
}

#pdf-canvas {
    display: block;
    /* Ensure it behaves as a block */
}

.crop-overlay-wrapper {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
    display: flex;
    flex-direction: column;
    cursor: crosshair !important;
}

.crop-overlay-wrapper.dimmed {
    background: rgba(0, 0, 0, 0.7) !important;
    /* Forces darker dim */
}

.crop-overlay-wrapper.dimmed img {
    filter: brightness(0.5);
    transition: filter 0.3s;
}

.crop-instruction {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px 25px;
    border-radius: 50px;
    font-weight: 600;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: opacity 0.3s;
}

.crop-overlay-wrapper.active-interaction .crop-instruction {
    opacity: 0;
}

.cropper-drag-box {
    cursor: crosshair !important;
}

.cropper-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    gap: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.btn-crop-action {
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.confirm {
    background: var(--secondary-color);
    color: #fff;
}

.cancel {
    background: #eee;
    color: #333;
}

.share-toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 10px;
    padding-left: 15px;
    border-left: 1px solid #eee;
}

.share-label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.share-icons-row {
    display: flex;
    gap: 5px;
}

.share-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
    text-decoration: none;
    transition: transform 0.2s;
}

.share-icon:hover {
    transform: translateX(-3px);
}

.facebook {
    background: #3b5998;
}

.x-twitter {
    background: #000;
    color: #fff;
}

.whatsapp {
    background: #25d366;
}

.telegram {
    background: #0088cc;
}

.tiktok {
    background: #010101;
}

.print {
    background: #7f8c8d;
}

.email {
    background: #ea4335;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #eee;
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.main-footer {
    background: #222;
    color: #fff;
    padding: 10px 0;
    text-align: center;
    font-size: 0.85rem;
    z-index: 1000;
    margin-top: auto;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.clip-result-container {
    margin: 20px 0;
    border: 1px solid #eee;
    padding: 10px;
    background: #f9f9f9;
    max-height: 400px;
    overflow: auto;
}

.clip-result-container img {
    max-width: 100%;
    height: auto;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.btn-action {
    display: inline-block;
    background: var(--primary-color);
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
}

.share-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.share-btn {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
}

.share-btn.fb {
    background: #3b5998;
}

.share-btn.tw {
    background: #1da1f2;
}

.share-btn.wa {
    background: #25d366;
}

.share-btn.x-twitter {
    background: #000;
    color: #fff;
}

.share-btn.tg {
    background: #0088cc;
}

.share-btn.tt {
    background: #010101;
}

.share-btn.pr {
    background: #7f8c8d;
}

.share-btn.em {
    background: #ea4335;
}

@media (max-width: 768px) {
    .sidebar-thumbnails {
        display: none;
    }

    .toolbar-left,
    .toolbar-right {
        gap: 8px;
    }

    .brand-logo {
        max-height: 40px;
        /* Make it slightly smaller on mobile */
    }

    .share-sidebar {
        display: none;
    }

    /* Hide share sidebar on mobile */

    /* Mobile Bottom Toolbar (Docked above footer) */
    .mobile-bottom-toolbar {
        display: flex;
        position: relative;
        /* Changed from fixed */
        width: 100%;
        background: #fff;
        align-items: center;
        justify-content: flex-start;
        padding: 8px 10px;
        /* Compress padding */
        border-top: 1px solid #eee;
        z-index: 10;
        overflow-x: auto;
        gap: 10px;
        /* Universal gap */
    }

    /* Flatten wrappers on mobile to make all children respect the same parent gap */
    .mobile-bottom-toolbar .toolbar-left,
    .mobile-bottom-toolbar .toolbar-center,
    .mobile-bottom-toolbar .toolbar-actions {
        display: contents;
    }

    /* Compress Pagination & Zoom Elements */
    .pagination-controls,
    .zoom-controls {
        padding: 4px 8px;
        gap: 10px;
        /* Match the main toolbar gap */
        display: flex;
        align-items: center;
        margin: 0;
    }

    .btn-icon {
        width: 32px;
        /* Slightly larger targets for mobile */
        height: 32px;
    }

    /* Adjust page-select margin */
    .page-select {
        margin: 0;
    }

    .btn-icon {
        width: 28px;
        height: 28px;
    }

    /* Hide unneeded zoom elements */
    #zoom-out,
    #zoom-level,
    #zoom-in {
        display: none !important;
    }

    /* Simplify & Hide Labels on Tools */
    .btn-tool {
        font-size: 0 !important;
        /* Hides text nodes */
        padding: 6px 10px;
        gap: 0 !important;
        justify-content: center;
    }

    .btn-tool i {
        font-size: 1.2rem;
        margin: 0;
    }

    body.epaper-body {
        padding-bottom: 0;
        /* Remove padding since it's no longer fixed */
    }

    .toolbar-content {
        justify-content: center;
        /* Center share buttons on top */
        padding-bottom: 0;
    }

    .share-toolbar-group {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
    }

    /* Mobile Hamburger Menu */
    .mobile-menu-btn {
        display: block;
    }

    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1049;
        /* fade-in transition could be added here if desired */
    }

    .mobile-menu-overlay.active {
        display: block;
    }

    .main-nav {
        display: flex;
        /* override desktop flex */
        position: fixed;
        top: 0;
        right: -100%;
        width: 90%;
        max-width: 320px;
        height: 100vh;
        background: #fff;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        padding: 20px;
        gap: 15px;
        z-index: 1050;
        transition: right 0.3s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    }

    .main-nav.open {
        right: 0;
    }

    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid #eee;
    }

    .mobile-menu-header h3 {
        font-size: 1.2rem;
        color: var(--primary-color);
        margin: 0;
    }

    .mobile-menu-close {
        background: transparent;
        border: none;
        font-size: 2rem;
        cursor: pointer;
        color: #555;
        line-height: 1;
    }

    .nav-link {
        width: 100%;
        padding: 12px 0;
        font-size: 1.1rem;
        border-bottom: 1px solid #f5f5f5;
    }

    .admin-btn {
        text-align: center;
        margin-top: 10px;
        border-bottom: none;
        padding: 12px 16px;
        border-radius: 4px;
    }

    /* Make PDF fit screen perfectly on mobile */
    .pdf-container {
        width: 100%;
        margin: 0;
        box-shadow: none;
    }

    #pdf-canvas {
        width: 100% !important;
        /* Force override inline styles from pdf.js */
        height: auto !important;
        /* Maintain aspect ratio */
    }

    /* Stretch the viewer area to push the footer down */
    .main-container {
        align-items: stretch;
        /* override flex-start from desktop */
    }

    .viewer-area {
        flex: 1;
        min-height: calc(100vh - var(--header-height) - var(--toolbar-height) - 70px);
    }

    /* Fix Fullscreen Controls on Mobile */
    .viewer-area:fullscreen .fullscreen-controls {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: center;
        padding-bottom: 20px;
    }

    .btn-fs-close {
        top: 15px !important;
        right: 15px !important;
        width: 40px !important;
        height: 40px !important;
    }

    .fs-nav-wrapper {
        position: relative !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        justify-content: center !important;
        gap: 30px !important;
        padding: 0 !important;
    }

    .btn-fs-nav {
        width: 45px !important;
        height: 45px !important;
    }

    .modal-actions {
        flex-direction: column;
        gap: 15px;
    }

    .share-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
}