/* ===== CSS Variables & Reset ===== */
:root {
    --primary: #e44d4d;
    --primary-dark: #c0392b;
    --secondary: #3498db;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --gray: #95a5a6;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
.header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.logo i {
    font-size: 1.8rem;
}

.nav {
    display: flex;
    gap: 30px;
}

.nav a {
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
    transition: var(--transition);
}

.nav a:hover {
    color: var(--primary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--dark);
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #e74c3c 50%, #c0392b 100%);
    color: var(--white);
    text-align: center;
    padding: 80px 20px;
}

.hero h1 {
    font-size: 2.8rem;
    margin-bottom: 15px;
    font-weight: 800;
}

.hero p {
    font-size: 1.2rem;
    max-width: 650px;
    margin: 0 auto;
    opacity: 0.95;
}

/* ===== Tools Section ===== */
.tools-section {
    padding: 60px 0;
}

.tools-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 40px;
    color: var(--dark);
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.tool-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    border: 2px solid transparent;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.tool-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.8rem;
    color: var(--white);
}

.tool-icon.edit { background: #2980b9; }
.tool-icon.merge { background: #e74c3c; }
.tool-icon.split { background: #9b59b6; }
.tool-icon.compress { background: #2ecc71; }
.tool-icon.rotate { background: #3498db; }
.tool-icon.watermark { background: #1abc9c; }
.tool-icon.pagenumbers { background: #e67e22; }
.tool-icon.protect { background: #34495e; }
.tool-icon.unlock { background: #27ae60; }
.tool-icon.jpg-to-pdf { background: #f39c12; }
.tool-icon.pdf-to-jpg { background: #8e44ad; }
.tool-icon.addtext { background: #16a085; }
.tool-icon.reorder { background: #d35400; }

.tool-card h3 {
    font-size: 1.15rem;
    margin-bottom: 8px;
    color: var(--dark);
}

.tool-card p {
    font-size: 0.9rem;
    color: var(--gray);
}

/* ===== Workspace ===== */
.workspace {
    padding: 40px 0 80px;
    min-height: 70vh;
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    transition: var(--transition);
}

.back-btn:hover {
    color: var(--primary-dark);
}

.workspace-header {
    text-align: center;
    margin-bottom: 40px;
}

.workspace-header h2 {
    font-size: 2rem;
    color: var(--dark);
    margin-bottom: 8px;
}

.workspace-header p {
    color: var(--gray);
    font-size: 1.05rem;
}

/* ===== Upload Area ===== */
.upload-area {
    border: 3px dashed #ddd;
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    background: var(--white);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: #fef5f5;
}

.upload-area i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.upload-area h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--gray);
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ===== File List ===== */
.file-list {
    margin: 20px 0;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--white);
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.file-item .file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-item .file-info i {
    color: var(--primary);
    font-size: 1.2rem;
}

.file-item .file-name {
    font-weight: 500;
}

.file-item .file-size {
    color: var(--gray);
    font-size: 0.85rem;
}

.file-item .remove-btn {
    background: none;
    border: none;
    color: var(--gray);
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

.file-item .remove-btn:hover {
    color: var(--primary);
}

/* ===== Options Panel ===== */
.options-panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    margin: 20px 0;
    box-shadow: var(--shadow);
}

.options-panel h4 {
    margin-bottom: 16px;
    color: var(--dark);
}

.option-group {
    margin-bottom: 16px;
}

.option-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}

.option-group input,
.option-group select,
.option-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.option-group input:focus,
.option-group select:focus,
.option-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.option-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.option-row .option-group {
    flex: 1;
    min-width: 200px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-secondary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: var(--white);
}

.btn-success:hover {
    background: #219a52;
}

.action-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* ===== Progress Bar ===== */
.progress-container {
    margin: 20px 0;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--gray);
}

/* ===== Result Area ===== */
.result-area {
    text-align: center;
    padding: 40px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 20px;
    display: none;
}

.result-area i {
    font-size: 3rem;
    color: #27ae60;
    margin-bottom: 15px;
}

.result-area h3 {
    margin-bottom: 8px;
}

.result-area p {
    color: var(--gray);
    margin-bottom: 20px;
}

/* ===== Preview Area ===== */
.preview-area {
    margin: 20px 0;
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.preview-area canvas {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border: 1px solid #eee;
}

.page-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.page-thumb {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.page-thumb:hover {
    border-color: var(--primary);
}

.page-thumb.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(228, 77, 77, 0.2);
}

.page-thumb canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-thumb .page-num {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* ===== Sortable Pages ===== */
.sortable-pages {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.sortable-page {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
    transition: var(--transition);
    background: white;
}

.sortable-page:active {
    cursor: grabbing;
}

.sortable-page.dragging {
    opacity: 0.5;
    border-color: var(--primary);
}

.sortable-page canvas {
    width: 100%;
    height: auto;
    display: block;
}

.sortable-page .page-label {
    text-align: center;
    padding: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #f8f9fa;
}

/* ===== Features Section ===== */
.features-section {
    padding: 60px 0;
    background: var(--white);
}

.features-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 40px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
}

.feature-card {
    text-align: center;
    padding: 30px 20px;
}

.feature-card i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.feature-card h3 {
    margin-bottom: 10px;
}

.feature-card p {
    color: var(--gray);
    font-size: 0.95rem;
}

/* ===== About Section ===== */
.about-section {
    padding: 60px 0;
    text-align: center;
}

.about-section h2 {
    font-size: 2rem;
    margin-bottom: 16px;
}

.about-section p {
    max-width: 700px;
    margin: 0 auto;
    color: #555;
    font-size: 1.05rem;
    line-height: 1.8;
}

/* ===== Footer ===== */
.footer {
    background: var(--dark);
    color: var(--white);
    text-align: center;
    padding: 24px;
}

.footer p {
    opacity: 0.8;
    font-size: 0.9rem;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--dark);
    color: var(--white);
    padding: 14px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success { border-left: 4px solid #27ae60; }
.toast.error { border-left: 4px solid #e74c3c; }
.toast.info { border-left: 4px solid #3498db; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Loading Spinner ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    .nav.active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        padding: 20px;
        box-shadow: var(--shadow);
        gap: 15px;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }

    .tool-card {
        padding: 20px 16px;
    }

    .tool-icon {
        width: 55px;
        height: 55px;
        font-size: 1.4rem;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .option-row {
        flex-direction: column;
    }
}


/* ===== PDF Editor ===== */
.editor-container {
    display: flex;
    gap: 20px;
    min-height: 600px;
}

.editor-toolbar {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 60px;
    align-items: center;
}

.editor-toolbar button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 8px;
    background: #f0f0f0;
    cursor: pointer;
    font-size: 1rem;
    color: var(--dark);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-toolbar button:hover {
    background: #e0e0e0;
}

.editor-toolbar button.active {
    background: var(--primary);
    color: white;
}

.editor-toolbar .separator {
    width: 30px;
    height: 1px;
    background: #ddd;
    margin: 4px 0;
}

.editor-canvas-wrap {
    flex: 1;
    background: #e0e0e0;
    border-radius: var(--radius);
    overflow: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}

.editor-canvas-wrap canvas {
    box-shadow: var(--shadow-lg);
    cursor: crosshair;
}

.editor-sidebar {
    width: 240px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.editor-sidebar h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--gray);
    letter-spacing: 0.5px;
}

.editor-sidebar .prop-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.editor-sidebar .prop-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #555;
}

.editor-sidebar .prop-group input,
.editor-sidebar .prop-group select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
}

.editor-page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    background: var(--white);
    padding: 10px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.editor-page-nav button {
    padding: 6px 12px;
    border: none;
    background: #f0f0f0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.editor-page-nav button:hover {
    background: var(--primary);
    color: white;
}

.editor-page-nav span {
    font-weight: 600;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
    }
    .editor-toolbar {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
    }
    .editor-sidebar {
        width: 100%;
    }
}


/* ===== Inline Text Editor Overlays ===== */
#textOverlayContainer {
    user-select: text;
}

.text-overlay-item {
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.text-overlay-item[contenteditable="true"] {
    caret-color: #2c3e50;
}

.inline-edit-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #fffbe6;
    border: 1px solid #f1c40f;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.inline-edit-bar i {
    color: #f39c12;
}

.inline-edit-bar button {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.inline-edit-bar .apply-btn {
    background: #27ae60;
    color: white;
}

.inline-edit-bar .apply-btn:hover {
    background: #219a52;
}

.inline-edit-bar .cancel-btn {
    background: #e0e0e0;
    color: #333;
}

.inline-edit-bar .cancel-btn:hover {
    background: #ccc;
}
