/* PDFEzy - Tool Styles */

/* Tools Section */
.tools-section {
    padding: 4rem 0;
    background-color: var(--background-light);
}

/* Password Protection Styles */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.password-input-wrapper input {
    flex: 1;
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0;
    font-size: 1.1em;
}

.toggle-password:hover {
    color: #333;
}

.password-strength-meter {
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    margin-bottom: 8px;
}

.strength-bar {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.strength-text {
    font-size: 0.8em;
    margin-left: 4px;
}

.password-match-message {
    font-size: 0.9em;
    margin-top: 4px;
    min-height: 20px;
}

.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-2px, 0, 0); }
    40%, 60% { transform: translate3d(2px, 0, 0); }
}

/* Tool Categories */
.tool-categories {
    display: flex;
    justify-content: center;
    flex-wrap: nowrap; /* Prevent wrapping to ensure single row */
    gap: 1.5rem;
    margin: 2rem 0;
    padding: 1rem;
}

.category {
    background-color: var(--background-white);
    color: var(--text-medium);
    border: 1px solid var(--primary-light);
    padding: 1rem 2rem;
    border-radius: 20px;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category i {
    font-size: 1.2rem;
}

.category:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.category.active {
    background-color: var(--primary-color);
    color: var(--text-light);
    border-color: var(--primary-color);
}

/* Tool Grid */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
    min-height: 200px;
    position: relative;
    transition: all 0.3s ease;
}

/* Drop Zone Styles */
.tool-grid.drag-over {
    border: 2px dashed var(--primary-color);
    background-color: var(--primary-light);
    border-radius: 8px;
    opacity: 0.9;
}

.tool-grid.drag-over::after {
    content: 'Drop PDFs here to merge';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: var(--primary-dark);
    font-weight: 500;
    pointer-events: none;
}

.tool-card {
    background-color: var(--background-white);
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    cursor: pointer;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.tool-icon {
    background-color: var(--primary-light);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.tool-icon i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.tool-card h3 {
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin: 0;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: var(--background-white);
    border-radius: 8px;
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

/* PDF Viewer Modal */
.pdf-viewer-modal {
    width: 95vw;
    height: 95vh;
    max-width: none;
    padding: 0;
    background-color: #1a1a1a;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pdf-viewer-modal .modal-header {
    flex-shrink: 0;
}

/* Fills whatever space is left below the header — the toolbar can wrap to a
 * second row on narrow screens, so this must never be a fixed/guessed height
 * (a hardcoded "100vh minus toolbar height" pushed content past the modal's
 * bottom edge with no way to scroll to it whenever the toolbar wrapped). */
.pdf-editor-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.pdf-toolbar {
    flex-shrink: 0;
}

.pdf-viewer-modal .modal-header {
    background: linear-gradient(to bottom, #2c3e50, #2c2c2c);
    padding: 1rem 2rem;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pdf-viewer-modal .modal-header h3 {
    color: #ffffff;
    font-size: 1.2rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pdf-viewer-modal .modal-header h3 i {
    color: #e74c3c;
    font-size: 1.4rem;
}

.pdf-viewer-modal .modal-close {
    color: #ffffff;
    opacity: 0.7;
    transition: all 0.2s ease;
    font-size: 1.8rem;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.pdf-viewer-modal .modal-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.pdf-viewer-modal .modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    background-color: #1a1a1a;
    overflow: hidden;
    min-height: 0; /* Important for proper flexbox scrolling */
    position: relative;
}

/* PDF Toolbar (nav / zoom / rotate / download) — single row, wraps on narrow screens */
.pdf-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(to bottom, #34495e, #2c3e50);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pdf-toolbar .pdf-operations {
    margin-left: auto;
}

/* Workspace: sidebar + canvas area side by side, filling remaining modal height */
.pdf-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #141414;
}

.pdf-tools-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #202020;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    padding: 1rem;
}

.pdf-tools-sidebar .tool-hint {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.82rem;
    line-height: 1.4;
    margin: 0 0 0.6rem;
}

.pdf-tools-sidebar .tools-section {
    padding: 0 0 1.25rem;
    background: transparent;
    margin: 0;
}

.pdf-tools-sidebar .tools-section h4 {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.6rem;
}

.pdf-tools-sidebar .tool-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pdf-tools-sidebar .tool-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.pdf-tools-sidebar .tool-btn.active {
    background: #3498db;
    border-color: #3498db;
}

.pdf-tools-sidebar .tool-btn i {
    width: 1.1em;
    text-align: center;
}

.tool-options {
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-options:empty {
    border-top: none;
    padding-top: 0;
}

.text-options,
.drawing-options,
.shape-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.text-options input[type="text"] {
    flex: 1 1 100%;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.color-palette {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.color-palette button {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 0;
}

.color-palette button.active {
    border-color: #ffffff;
}

/* PDF Controls */
.pdf-controls {
    background: linear-gradient(to bottom, #34495e, #2c3e50);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

/* Control Items Wrapper */
.pdf-control-items {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: auto;
    flex-shrink: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 8px;
}

.pdf-controls .btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.pdf-controls .btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.2);
}

.pdf-controls .btn:active {
    transform: translateY(0);
}

.pdf-controls .btn i {
    font-size: 1.1rem;
}

#page-info {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 120px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 8px;
    margin-left: 1rem;
}

#zoom-level {
    color: #ffffff;
    font-size: 1rem;
    min-width: 80px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* PDF Operations */
.pdf-operations {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-left: 1.5rem;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.operation-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.operation-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #2980b9, #2573a7);
}

.operation-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.operation-btn.edit-btn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.operation-btn.edit-btn:hover {
    background: linear-gradient(135deg, #27ae60, #219a52);
}

.operation-btn i {
    font-size: 1.1rem;
}

/* Navigation Slider */
.pdf-navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 20;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
}

.pdf-slider {
    width: 50%;
    max-width: 400px;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    margin: 0 12px;
}

.pdf-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: 2px solid #2980b9;
    transition: all 0.2s ease;
}

.pdf-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.pdf-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: 2px solid #2980b9;
    transition: all 0.2s ease;
}

.pdf-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

/* PDF Canvas Container */
.pdf-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #141414;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.pdf-canvas-container {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pdf-canvas-container.zooming {
    cursor: zoom-in;
}

.pdf-canvas-stack {
    position: relative;
    display: inline-block;
}

#pdf-canvas {
    display: block;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: white;
    border-radius: 4px;
    transition: transform 0.3s ease;
    width: auto;
    max-width: 100%;
    height: auto !important; /* Force height to maintain aspect ratio */
    margin: 0 auto;
}

#edit-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Movable/resizable image & signature overlay, before it's flattened onto #edit-canvas */
.pdf-image-sticker {
    position: absolute;
    border: 2px dashed #3498db;
    cursor: move;
    touch-action: none;
    user-select: none;
    box-sizing: border-box;
}

.pdf-image-sticker .sticker-content {
    display: block;
    pointer-events: none;
}

.sticker-handle {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: #3498db;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: nwse-resize;
}

.sticker-done {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2ecc71;
    color: #fff;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-size: 0.75rem;
}

/* Scrollbar Styling */
.pdf-canvas-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.pdf-canvas-container::-webkit-scrollbar-track {
    background: transparent;
}

.pdf-canvas-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: all 0.3s ease;
}

.pdf-canvas-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading Animation */
.pdf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 1.25rem 2rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #ffffff;
    font-size: 1.1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

.pdf-loading i {
    animation: spin 1s linear infinite;
    color: #3498db;
    font-size: 1.4rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pdf-viewer-modal.active {
    animation: fadeIn 0.3s ease;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .tool-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .tool-categories {
        gap: 1rem;
    }
    
    .category {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }

    .pdf-controls {
        padding: 0.75rem 1rem;
        gap: 1rem;
    }

    .operation-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .tool-grid {
        grid-template-columns: 1fr;
    }
    
    .category {
        width: 100%;
        justify-content: center;
    }

    .pdf-operations {
        padding-left: 1rem;
        gap: 0.5rem;
    }
}
