/* --- GLOBAL STYLES --- */
/* CSS Variables for Scrollbar Colors based on theme */
:root {
    --sb-track: #e5e7eb;
    --sb-thumb: #9ca3af;
}
.dark {
    --sb-track: #2d2d2d;
    --sb-thumb: #555;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--sb-track); 
}
::-webkit-scrollbar-thumb {
    background: var(--sb-thumb); 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #777; 
}

/* Hide scrollbar for Chrome/Safari/Opera */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Tree View Styles */
.tree-item {
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.1s;
}
.tree-item:hover {
    background-color: #e5e7eb; 
    color: #111;
}
.dark .tree-item:hover {
    background-color: #3e3e3e;
    color: #fff;
}
.tree-item.active {
    background-color: #bfdbfe; 
    color: #1e40af; 
    font-weight: 600;
}
.dark .tree-item.active {
    background-color: #3b82f6; 
    color: white;
    font-weight: normal;
}
.tree-children {
    display: none;
    padding-left: 16px;
    border-left: 1px solid #e5e7eb;
}
.dark .tree-children {
    border-left: 1px solid #444;
}
.tree-children.open {
    display: block;
}

/* Drag Overlay */
#drop-overlay {
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
#drop-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Nav Arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 20px 10px;
    cursor: pointer;
    z-index: 20;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0;
}
.nav-arrow:hover {
    background: rgba(59, 130, 246, 0.8);
}
#rhs-panel:hover .nav-arrow {
    opacity: 1;
}

/* Loader */
.spinner {
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top: 3px solid #3b82f6;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Tab Styles */
.tab-btn {
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-size: 0.875rem;
    color: #6b7280; 
    transition: all 0.2s;
}
.dark .tab-btn {
    color: #9ca3af; 
}
.tab-btn:hover {
    background-color: rgba(0,0,0,0.05);
    color: #111;
}
.dark .tab-btn:hover {
    background-color: rgba(255,255,255,0.05);
    color: #fff;
}
.tab-btn.active {
    border-bottom-color: #3b82f6; 
    color: #2563eb; 
    font-weight: 600;
}
.dark .tab-btn.active {
    border-bottom-color: #3b82f6;
    color: #60a5fa; 
}

/* Gradient Text for Icons */
.google-icon-gradient {
    background: linear-gradient(45deg, #4285F4, #EA4335, #FBBC05, #34A853);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Active Tool Button Style */
.tool-btn.active {
    background-color: #eff6ff; /* blue-50 */
    border-color: #3b82f6; /* blue-500 */
    box-shadow: 0 0 0 1px #3b82f6; /* ring effect */
}
.dark .tool-btn.active {
    background-color: #172554; /* blue-950 */
    border-color: #60a5fa; /* blue-400 */
    box-shadow: 0 0 0 1px #60a5fa;
}

/* PRINT STYLES */
@media print {
    body * {
        visibility: hidden;
    }
    #print-gallery, #print-gallery * {
        visibility: visible;
    }
    #print-gallery {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: flex !important;
        flex-direction: column;
        gap: 20px;
        padding: 20px;
        background: white;
        color: black;
        z-index: 9999;
    }
    #print-gallery img {
        max-width: 100%;
        height: auto;
        page-break-inside: avoid;
        border: 1px solid #ccc;
    }
    #print-gallery .print-page-number {
        font-size: 10pt;
        color: #555;
        margin-bottom: 4px;
    }
    #media-wrapper.print-single, #media-wrapper.print-single * {
        visibility: visible;
    }
    #media-wrapper.print-single {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: white;
        z-index: 9999;
    }
    #active-media {
        transform: none !important;
        max-width: 100vw;
        max-height: 100vh;
        object-fit: contain;
        box-shadow: none;
    }
}

/* SNIPPET TOOL STYLES */
#snippet-overlay {
    cursor: crosshair;
}
#selection-box {
    border: 2px dashed #3b82f6;
    background-color: rgba(59, 130, 246, 0.2);
    position: absolute;
    z-index: 210; /* Above overlay */
}

/* Toast Animation */
@keyframes fade-in-out {
    0% { opacity: 0; transform: translateY(20px) translateX(-50%); }
    10% { opacity: 1; transform: translateY(0) translateX(-50%); }
    90% { opacity: 1; transform: translateY(0) translateX(-50%); }
    100% { opacity: 0; transform: translateY(-20px) translateX(-50%); }
}
.toast-msg {
    animation: fade-in-out 3s forwards;
}

/* Media Viewer Styles for Zoom/Pan */
#media-wrapper {
    overflow: auto; /* Enable Scrollbars */
    cursor: grab;
}
#media-wrapper.grabbing {
    cursor: grabbing;
}

/* Context Menu Styles */
#context-menu {
    position: absolute;
    z-index: 1000;
    width: 150px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    display: none;
}
.dark #context-menu {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}
.ctx-item {
    padding: 8px 12px;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ctx-item:hover {
    background-color: #f3f4f6;
}
.dark .ctx-item:hover {
    background-color: #374151;
}
.ctx-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 4px 0;
}
.dark .ctx-divider {
    background-color: #374151;
}

/* Filter Active States */
.filter-active {
    color: #3b82f6;
}
.dark .filter-active {
    color: #60a5fa;
}

/* --- QR VIEWER STYLES (Scoped to tab-qr) --- */
#tab-qr {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    color: #333; /* Force dark text for readability in light mode */
}
.dark #tab-qr {
    background: #111827; /* dark:bg-gray-900 */
    color: #e5e7eb;
}
#tab-qr h2 {
    text-align: center;
    margin: 20px 0;
    font-size: 1.5rem;
    font-weight: bold;
}
#tab-qr .qr-container {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px;
    height: calc(100% - 80px);
    overflow: auto;
}
#tab-qr .qr-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.dark #tab-qr .qr-panel {
    background: #1f2937;
    border-color: #374151;
}
#tab-qr .left-panel {
    flex: 1 1 340px;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#tab-qr .right-panel {
    flex: 2 1 600px;
    min-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#tab-qr .drop-zone {
    border: 2px dashed #bbb;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
}
.dark #tab-qr .drop-zone {
    background: #374151;
    border-color: #4b5563;
}
#tab-qr .drop-zone.dragover {
    border-color: #007bff;
    background: #eef5ff;
}
.dark #tab-qr .drop-zone.dragover {
    background: #1e3a8a;
}
#tab-qr .small-text {
    font-size: 12px;
    color: #666;
}
.dark #tab-qr .small-text {
    color: #9ca3af;
}
#tab-qr button {
    margin: 4px 4px 4px 0;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #999;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 13px;
    color: #333;
}
.dark #tab-qr button {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}
#tab-qr button.primary {
    background: #007bff;
    color: white;
    border-color: #007bff;
}
#tab-qr button.danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}
#tab-qr button:disabled {
    opacity: 0.5;
    cursor: default;
}
#tab-qr #resultText {
    margin-top: 8px;
    font-size: 13px;
    border: 1px solid #eee;
    padding: 8px;
    border-radius: 4px;
    min-height: 80px;
    background: #fcfcfc;
    width: 100%;
    resize: vertical;
    box-sizing: border-box;
    color: #333;
}
.dark #tab-qr #resultText {
    background: #111827;
    border-color: #374151;
    color: #e5e7eb;
}
#tab-qr .section-title {
    font-weight: bold;
    margin-top: 4px;
    margin-bottom: 4px;
    font-size: 14px;
}
#tab-qr .row-space-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
#tab-qr .preview-wrapper {
    margin-top: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    overflow: auto;
    background: #fafafa;
    height: 140px;
}
.dark #tab-qr .preview-wrapper {
    background: #111827;
    border-color: #374151;
}
#tab-qr #preview {
    display: block;
    max-width: 100%;
    height: auto;
}
#tab-qr #pdfViewer {
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
}

/* QR Modal Styles */
#tab-qr .qr-modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
}
#tab-qr .qr-modal-content {
    background-color: #fefefe;
    margin: 15% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 320px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    color: #333;
}
.dark #tab-qr .qr-modal-content {
    background-color: #1f2937;
    border-color: #4b5563;
    color: #e5e7eb;
}
#tab-qr .qr-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}
#tab-qr .qr-modal-actions button {
    width: 100%;
    margin: 0;
    padding: 10px;
    font-size: 14px;
}