:root {
    --primary: #ff0000;
    --primary-hover: #cc0000;
    --black: #050505;
    --black-light: #151515;
    --text-main: #f5f5f5;
    --text-muted: #a0a0a0;
    --surface: rgba(25, 25, 25, 0.4);
    --surface-hover: rgba(45, 45, 45, 0.6);
    --border: rgba(255, 255, 255, 0.1);
    --radius: 12px;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

[data-theme="light"] {
    --primary: #e60000;
    --primary-hover: #b30000;
    --black: #ffffff;
    --black-light: #f9f9f9;
    --text-main: #111111;
    --text-muted: #666666;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-hover: rgba(240, 240, 240, 1);
    --border: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] header.scrolled .logo,
[data-theme="light"] header.scrolled nav a,
[data-theme="light"] header.scrolled .dropbtn,
[data-theme="light"] header.scrolled .mobile-menu-btn,
[data-theme="light"] header.scrolled #theme-toggle {
    color: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--black);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.6;
    transition: background-color var(--transition), color var(--transition);
}

/* Background Animation */
#particles-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    /* ensure light mode keeps a subtle particle effect */
    background: radial-gradient(circle at center, hsla(0, 100%, 50%, 0.1) 0%, var(--black) 100%);
    transition: background var(--transition);
}

.particle {
    position: absolute;
    color: var(--primary);
    opacity: 0.15;
    animation: float infinite linear;
    transition: color var(--transition);
}

@keyframes float {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) scale(1);
        opacity: 0;
    }
}

/* Typography & Utilities */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    transition: color var(--transition);
}

a {
    color: var(--text-main);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 5%;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    transform: scale(1);
}

.btn:hover {
    transform: scale(1.05);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.5);
}

/* Glassmorphism Classes */
.glass {
    background: var(--surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Header & Nav */
header {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

header.scrolled {
    background: rgba(5, 5, 5, 0.9);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--border);
    padding: 10px 5%;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo img {
    height: 70px;
    width: auto;
    object-fit: contain;
    transition: var(--transition);
}

.logo:hover img {
    transform: scale(1.1) rotate(5deg);
}

nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

nav a {
    font-weight: 500;
    font-size: 0.95rem;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.dropdown:hover .dropbtn {
    color: var(--primary);
}

.dropdown-content {
    display: none;
    position: absolute;
    background: var(--black-light);
    border: 1px solid var(--border);
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 8px;
    overflow: hidden;
    top: 100%;
    left: 0;
}
.dropdown-content.multi-column {
    display: none;
    flex-wrap: nowrap;
    min-width: 600px;
    padding: 20px;
    gap: 20px;
    left: 50%;
    transform: translateX(-50%);
}
.dropdown-section {
    flex: 1;
    min-width: 150px;
}
.dropdown-section h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
    letter-spacing: 1px;
}

.dropdown-content a {
    color: var(--text-main);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background: rgba(255, 0, 0, 0.1);
    color: #fff;
    padding-left: 20px;
}

.dropdown:hover .dropdown-content {
    display: flex; /* Changed from block to flex for multi-column compatibility */
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}
.dropdown:hover .dropdown-content.multi-column {
    display: flex;
    flex-direction: row;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 120px 20px 60px;
    position: relative;
}

.hero h1 {
    font-size: 3.5rem;
    max-width: 800px;
    background: linear-gradient(to right, var(--text-main), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: fadeInUp 0.8s ease;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 20px auto 40px;
    animation: fadeInUp 1s ease;
}

/* Tools Grid Section */
.tools-section {
    padding: 80px 0;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 50px;
}

.section-title span {
    color: var(--primary);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.tool-card {
    padding: 30px 20px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 3px;
    background: var(--primary);
    transition: var(--transition);
}

.tool-card:hover {
    transform: translateY(-10px);
    background: var(--surface-hover);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.tool-card:hover::before {
    left: 0;
}

.tool-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 20px;
    transition: var(--transition);
}

.tool-card:hover .tool-icon {
    transform: scale(1.1) rotate(5deg);
}

.tool-card h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.tool-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    flex-grow: 1;
}

.tool-card .btn {
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 20px;
}

/* Inner Page Templates */
.page-header {
    padding: 150px 0 60px;
    text-align: center;
    background: linear-gradient(180deg, rgba(255,0,0,0.05) 0%, rgba(0,0,0,0) 100%);
}

.page-header h1 {
    font-size: 2.8rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 700px;
    margin: 15px auto 0;
}

.content-section {
    padding: 60px 0;
}

.tool-workspace {
    max-width: 900px;
    margin: -40px auto 60px;
    padding: 40px;
    text-align: center;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 60px 20px;
    transition: var(--transition);
    cursor: pointer;
    background: rgba(255,255,255,0.02);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(255,0,0,0.05);
}

.upload-icon {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.upload-area input[type="file"] {
    display: none;
}

.upload-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 10px;
}

.workspace-actions {
    margin-top: 30px;
    display: none; /* Shown via JS when files dropped */
}

/* Footer structure */
footer {
    background: var(--black-light);
    padding: 80px 5% 30px;
    margin-top: 60px;
    border-top: 1px solid var(--border);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-grid h3 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-main);
}

.footer-grid p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-links a:hover {
    color: var(--primary);
    padding-left: 5px;
}

.social-icons {
    display: flex;
    gap: 15px;
}

.social-icons a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(128,128,128,0.15);
    color: var(--text-main);
    transition: var(--transition);
}

.social-icons a:hover {
    background: var(--primary);
    transform: translateY(-3px);
}

.footer-bottom {
    margin-top: 60px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* SEO Content Area */
.seo-content {
    max-width: 900px;
    margin: 80px auto;
}

.seo-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    margin-top: 40px;
}

.seo-content h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    margin-top: 30px;
}

.seo-content p {
    color: var(--text-muted);
    margin-bottom: 15px;
}

.seo-content ul {
    color: var(--text-muted);
    margin-left: 20px;
    margin-bottom: 20px;
}

.seo-content li {
    margin-bottom: 10px;
}

/* Tool output / UI states */
.loading-indicator {
    display: none;
    margin-top: 20px;
}

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

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

/* Generic Layout */
.file-list {
    text-align: left;
    margin-top: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.05);
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.file-item .remove-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
}

/* Responsive */
@media (max-width: 900px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .hero h1 { font-size: 2.5rem; }
    
    .mobile-menu-btn {
        display: block;
    }
    
    nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 250px;
        height: 100vh;
        background: rgba(10,10,10,0.95);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding-top: 80px;
        transition: 0.4s ease;
        border-left: 1px solid var(--border);
    }
    
    nav.active {
        right: 0;
    }
    
    nav a, .dropbtn {
        font-size: 1.1rem;
        padding: 15px 20px;
        width: 100%;
        text-align: left;
    }
    
    .dropdown-content {
        position: static;
        box-shadow: none;
        border: none;
        background: transparent;
        display: none;
    }

    .dropdown.active .dropdown-content {
        display: block;
    }
    
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .social-icons {
        justify-content: center;
    }
    
    .footer-links {
        align-items: center;
    }
}

.native-text-block {
    position: absolute;
    cursor: text;
    border: 1px dashed transparent;
    background-color: transparent;
    transition: all 0.2s ease;
}

.native-text-block:hover {
    border: 1px dashed var(--primary);
    background-color: rgba(37, 99, 235, 0.05);
}

.inline-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}
.toolbar-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    color: var(--text-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.toolbar-icon-btn:hover, .toolbar-icon-btn.active {
    background: var(--border);
}
.toolbar-select, .toolbar-input {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px;
    background: var(--bg-card);
    color: var(--text-color);
    font-size: 0.9rem;
    appearance: auto;
}

.toolbar-select option {
    background-color: var(--bg-card);
    color: var(--text-color);
}
.inline-toolbar select, .inline-toolbar option {
    background-color: var(--bg-card);
    color: var(--text-color);
}

/* PDF Editor Consolidated Styles - Refined V3 */
#pdf-editor-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    background: white;
    max-width: none;
    transform-origin: top center;
}
#pdf-render-canvas {
    display: block;
    pointer-events: none;
}
#pdf-interaction-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;
    cursor: inherit;
}
#pdf-dom-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.pdf-text-input {
    position: absolute;
    background: transparent;
    border: none !important;
    outline: none !important;
    color: black;
    font-family: inherit;
    padding: 0 !important;
    margin: 0 !important;
    pointer-events: auto;
    z-index: 10;
    line-height: 1.1;
    white-space: pre !important;
    resize: none !important;
    overflow: hidden !important;
    vertical-align: top;
    box-sizing: border-box !important;
    letter-spacing: normal;
}
.pdf-text-input:focus {
    background: rgba(255,255,255,0.05);
}
.pdf-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    background: var(--black-light);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 10px;
    z-index: 100;
}
.toolbar-group {
    display: flex;
    gap: 5px;
    align-items: center;
    border-right: 1px solid var(--border);
    padding-right: 10px;
}
.toolbar-group:last-child {
    border-right: none;
}
.tool-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
    gap: 5px;
}
.tool-btn i {
    font-size: 1.1rem;
}
.tool-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border);
}
.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
#scroll-container {
    overflow: hidden; /* Navigation handled by Panning tool */
    max-height: 75vh;
    min-height: 500px;
    padding: 60px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #0a0a0a;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    position: relative;
    cursor: default;
}
#scroll-container.panning {
    cursor: grab;
}
#scroll-container.panning:active {
    cursor: grabbing;
}
.pdf-element {
    position: absolute;
    pointer-events: auto;
    cursor: move;
    border: 1px solid transparent;
}
.pdf-element:hover {
    border: 1px dashed var(--primary);
}
.pdf-element.selected {
    border: 2px solid var(--primary);
    background-color: rgba(255, 0, 0, 0.05);
    box-shadow: 0 0 15px rgba(255,0,0,0.3);
}
.pdf-image {
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    right: -6px;
    bottom: -6px;
    cursor: nwse-resize;
    display: none;
    border-radius: 50%;
    border: 2px solid white;
}
.pdf-element.selected .resize-handle {
    display: block;
}
.pdf-form-input {
    position: absolute;
    background: rgba(0, 150, 255, 0.1);
    border: 1px solid #0096ff;
    color: black;
    outline: none;
    pointer-events: auto;
}
.editor-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}
.editor-modal-content {
    background-color: var(--black-light);
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
}
#sub-toolbar {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    padding: 12px 20px;
}

/* Pages Grid for Remove/Extract/Organize */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius);
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.page-thumbnail {
    position: relative;
    background: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.page-thumbnail:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.page-thumbnail.selected {
    border-color: var(--primary);
    background: rgba(255, 0, 0, 0.05);
}

.page-thumbnail canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.page-number {
    margin-top: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
}

[data-theme="dark"] .page-number {
    color: #333; /* Keep it dark on white background of thumbnail */
}

.page-thumbnail .select-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    opacity: 0;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 5;
}

.page-thumbnail.selected .select-badge {
    opacity: 1;
}

/* For Remove Pages tool specifically */
.page-thumbnail.to-remove {
    opacity: 0.4;
    filter: grayscale(0.8);
    border-color: #666;
}

.page-thumbnail.to-remove .select-badge {
    background: #444;
    opacity: 1;
}
