/* ============================================================
   PDF Editor — Tool Page (tool-page.css)
   Upload zone, file list, interactive PDF workspace, processing, download
   ============================================================ */

/* ── Tool Page Layout ────────────────────────────────────── */
.tool-page {
    padding: calc(80px + var(--space-8)) 0 var(--space-16);
    min-height: 100vh;
}

.tool-page__header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.tool-page__icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto var(--space-4);
}

.tool-page__title {
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-2);
}

.tool-page__desc {
    font-size: var(--text-base);
    color: var(--text-secondary);
    max-width: 550px;
    margin: 0 auto;
}

/* ── Upload Zone ─────────────────────────────────────────── */
.upload-zone {
    position: relative;
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: var(--space-12) var(--space-8);
    text-align: center;
    cursor: pointer;
    background: var(--glass-bg);
    backdrop-filter: blur(12px) saturate(130%);
    -webkit-backdrop-filter: blur(12px) saturate(130%);
    transition: all var(--duration-normal) var(--ease-out-expo);
    overflow: hidden;
    max-width: 800px;
    margin: 0 auto var(--space-6);
}

.upload-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent 30%,
        rgba(255, 255, 255, 0.02) 50%,
        transparent 70%
    );
    background-size: 200% 200%;
    animation: liquid-shimmer 8s ease-in-out infinite;
    pointer-events: none;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: var(--glass-bg-hover);
    transform: scale(1.01);
    box-shadow: 0 0 40px var(--accent-glow);
}

.upload-zone.drag-over {
    border-style: solid;
}

.upload-zone__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    border-radius: var(--radius-xl);
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--accent-primary);
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.upload-zone:hover .upload-zone__icon {
    transform: scale(1.1) translateY(-4px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.upload-zone__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-1);
    color: var(--text-primary);
}

.upload-zone__subtitle {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.upload-zone__input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ── File List ───────────────────────────────────────────── */
.file-list {
    max-width: 800px;
    margin: 0 auto var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.file-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    transition: all var(--duration-fast);
    backdrop-filter: blur(8px);
}

.file-item:hover {
    background: var(--glass-bg-hover);
}

.file-item__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: var(--text-base);
    flex-shrink: 0;
}

.file-item__info {
    flex: 1;
    min-width: 0;
}

.file-item__name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item__size {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.file-item__remove {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast);
    flex-shrink: 0;
}

.file-item__remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ── Interactive PDF Visual Workspace ────────────────────── */
.pdf-workspace {
    margin: var(--space-6) auto;
    padding: var(--space-6);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.pdf-workspace__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--divider);
}

.pdf-workspace__info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.pdf-workspace__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.pdf-workspace__toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* ── PDF Pages Grid ──────────────────────────────────────── */
.pdf-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
    max-height: 520px;
    overflow-y: auto;
    padding: var(--space-2);
    border-radius: var(--radius-lg);
}

.pdf-page-card {
    position: relative;
    background: var(--bg-primary);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all var(--duration-normal) var(--ease-out-expo);
    cursor: pointer;
    user-select: none;
    overflow: hidden;
}

.pdf-page-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.pdf-page-card.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary), 0 8px 20px var(--accent-glow);
}

.pdf-page-card.deleted {
    opacity: 0.35;
    filter: grayscale(1);
    transform: scale(0.95);
    border-style: dashed;
}

.pdf-page-card__header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
}

.pdf-page-card__num {
    background: var(--accent-soft);
    color: var(--accent-primary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
}

.pdf-page-card__actions {
    display: flex;
    gap: 4px;
    opacity: 0.7;
    transition: opacity var(--duration-fast);
}

.pdf-page-card:hover .pdf-page-card__actions {
    opacity: 1;
}

.page-btn {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: all var(--duration-fast);
}

.page-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: transparent;
}

.page-btn--delete:hover {
    background: var(--danger);
    color: white;
}

.pdf-page-canvas-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffffff;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform var(--duration-normal) var(--ease-out-expo);
}

.pdf-page-canvas {
    max-width: 100%;
    height: auto !important;
    display: block;
}

/* Watermark Live Visual Overlay */
.pdf-watermark-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    font-weight: bold;
    text-align: center;
    overflow: hidden;
    user-select: none;
}

/* ── Options Panel ───────────────────────────────────────── */
.options-panel {
    max-width: 800px;
    margin: var(--space-6) auto 0;
    padding: var(--space-6);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(12px);
}

.options-panel__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.option-group {
    margin-bottom: var(--space-4);
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group__label {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.option-group__input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--duration-fast);
}

.option-group__input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.option-group__select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.option-group__select:focus {
    border-color: var(--accent-primary);
}

/* ── Processing State ────────────────────────────────────── */
.processing {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    max-width: 500px;
    margin: 0 auto;
}

.processing__spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-5);
}

.processing__text {
    font-size: var(--text-xl);
    font-weight: var(--weight-medium);
    margin-bottom: var(--space-2);
}

.processing__subtext {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin-bottom: var(--space-6);
}

/* ── Download Section ────────────────────────────────────── */
.download-section {
    text-align: center;
    max-width: 550px;
    margin: 0 auto;
    padding: var(--space-12) var(--space-4);
}

.download-section__icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    margin: 0 auto var(--space-5);
    animation: celebrate 0.6s var(--ease-spring) forwards;
}

.download-section__title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-2);
}

.download-section__info {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin-bottom: var(--space-8);
    font-family: var(--font-mono);
}

.download-section__actions {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    flex-wrap: wrap;
}
