.hidden {
    display: none !important;
}

svg {
    fill: none;
}

body {
    overflow-x: hidden;
}

body.download-active {
    height: calc(100vh - 81px);
    overflow-y: visible;
}

body.selection-active {
    overflow-y: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.loading-bar-container {
    width: 300px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar {
    position: absolute;
    height: 100%;
    background: #ff6154;
    border-radius: 2px;
    width: 40%;
    will-change: transform;
    animation: loading 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes loading {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(200%); }
    100% { transform: translateX(500%); }
}

.loading-text {
    font-size: 15px;
    color: #666;
    font-weight: 500;
}

/* Container & Upload */
.container {
    background-color: transparent;
    box-sizing: border-box;
    padding: 20px;
    border-radius: 16px;
    max-width: 1400px;
    margin: 0 auto 10px auto;
    overflow: visible;
}

.upload-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 12px;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff6154;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input-label:hover {
    background: #e5554a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.4);
}

.upload-content {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.upload-icon {
    position: absolute;
    width: 24px;
    height: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    transition: opacity 0.3s ease;
}

.file-input-label:hover .upload-icon {
    opacity: 1;
}

.file-input-label:hover .upload-text {
    opacity: 0;
    visibility: hidden;
}

.file-input {
    display: none;
}

/* ============================================
   Selection Panel - Split View
   ============================================ */
.selection-panel {
    margin-top: 0;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    position: fixed;
    top: 81px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 81px);
}

.selection-content {
    display: flex;
    gap: 0;
    align-items: stretch;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Left side - Preview */
.files-preview-section {
    flex: 1;
    background-color: #f5f6f8;
    background-image: radial-gradient(circle, #e0e2e6 1px, transparent 1px);
    background-size: 20px 20px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow-y: auto;
    margin-right: 420px;
    box-sizing: border-box;
    position: relative;
}

.files-preview-section.full-preview-mode {
    justify-content: flex-start;
    padding-top: 56px;
}

/* Preview Mode Toggle */
.preview-mode-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 6px 12px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.preview-mode-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.toggle-switch.active {
    background: #ff6154;
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(20px);
}

.preview-canvas-area {
    max-width: 600px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* Full Preview Mode */
.preview-full-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.preview-full-container .preview-page-wrapper {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    position: relative;
}

.preview-full-container .preview-page-wrapper canvas {
    width: 100%;
    height: auto;
    display: block;
}

.preview-full-container .redaction-overlay-full {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    cursor: crosshair;
    z-index: 10;
}

.preview-page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 6px 8px;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.page-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.page-nav-btn:hover:not(:disabled) {
    background: #f3f4f6;
    color: #ff6154;
}

.page-nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.page-nav-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.page-indicator {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.preview-canvas-wrapper {
    position: relative;
    display: inline-block;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    line-height: 0;
}

#previewCanvas {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 240px);
}

/* ============================================
   Redaction Overlay (drawing area)
   ============================================ */
.redaction-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: crosshair;
    z-index: 10;
}

.redact-rect {
    position: absolute;
    border: 2px solid rgba(255, 97, 84, 0.8);
    background: rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    cursor: move;
    transition: box-shadow 0.15s;
}

.redact-rect:hover {
    box-shadow: 0 0 0 2px rgba(255, 97, 84, 0.5);
}

.redact-rect.active {
    border-color: #ff6154;
    box-shadow: 0 0 0 2px rgba(255, 97, 84, 0.4);
}

.redact-rect-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #ff6154;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 11;
}

.redact-rect:hover .redact-rect-delete,
.redact-rect.active .redact-rect-delete {
    display: flex;
}

.redact-rect-drawing {
    border: 2px dashed rgba(255, 97, 84, 0.9);
    background: rgba(255, 97, 84, 0.15);
    pointer-events: none;
}

/* ============================================
   Right side - Controls Panel
   ============================================ */
.controls-panel {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    box-sizing: border-box;
    padding: 0;
    height: calc(100vh - 81px);
    background: white;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.controls-panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-height: 0;
}

/* ============================================
   Panel Header
   ============================================ */
/* ============================================
   Mode Toggle Bar (Draw / Text Select)
   ============================================ */
.redact-mode-bar {
    display: flex;
    gap: 4px;
    padding: 16px 20px 12px 20px;
}

.redact-mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 9px;
    background: white;
    font-size: 0.76rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.redact-mode-btn:hover {
    border-color: #d1d5db;
    color: #374151;
    background: #f9fafb;
}

.redact-mode-btn.active {
    border-color: #1f2937;
    background: #1f2937;
    color: white;
}

.redact-mode-btn svg {
    flex-shrink: 0;
}

/* ============================================
   Accordion Sections
   ============================================ */
.accordion-section {
    border-bottom: 1px solid #f3f4f6;
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    cursor: pointer;
    width: 100%;
    background: none;
    border: none;
    font-family: inherit;
    transition: background 0.12s;
}

.accordion-header:hover {
    background: #f9fafb;
}

.accordion-header svg:first-child {
    color: #9ca3af;
    flex-shrink: 0;
}

.accordion-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: #374151;
    flex: 1;
    text-align: left;
}

.accordion-chevron {
    color: #9ca3af;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.accordion-section.open .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
    padding: 0 20px;
}

.accordion-section.open .accordion-body {
    max-height: 500px;
    padding: 0 20px 14px 20px;
}

/* ============================================
   Search & Redact (inside accordion)
   ============================================ */
.search-redact-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border-radius: 9px;
    padding: 0 12px;
    transition: all 0.2s;
    border: 1.5px solid transparent;
}

.search-redact-bar:focus-within {
    background: white;
    border-color: #1f2937;
    box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.06);
}

.search-redact-icon {
    flex-shrink: 0;
    color: #9ca3af;
}

.search-redact-bar:focus-within .search-redact-icon {
    color: #1f2937;
}

.search-redact-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 9px 0;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    color: #1f2937;
    outline: none;
    min-width: 0;
}

.search-redact-input::placeholder {
    color: #9ca3af;
}

.search-redact-clear {
    width: 18px;
    height: 18px;
    border: none;
    background: #d1d5db;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.search-redact-clear:hover {
    background: #9ca3af;
}

.search-redact-results {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-redact-info {
    flex: 1;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b7280;
}

.search-redact-info strong {
    color: #1f2937;
}

.search-redact-all-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 7px;
    background: #1f2937;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-redact-all-btn:hover {
    background: #374151;
}

/* Regex toggle row */
.regex-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
}

.regex-toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b7280;
    flex: 1;
    cursor: pointer;
}

.regex-toggle-label svg {
    color: #9ca3af;
}

.toggle-switch-sm {
    width: 34px;
    height: 20px;
    border-radius: 10px;
    background: #d1d5db;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-switch-sm.active {
    background: #1f2937;
}

.toggle-slider-sm {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch-sm.active .toggle-slider-sm {
    transform: translateX(14px);
}

.regex-bar {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.regex-input {
    flex: 1;
    padding: 8px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    font-size: 0.76rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: #1f2937;
    outline: none;
    min-width: 0;
    transition: all 0.15s;
}

.regex-input:focus {
    border-color: #1f2937;
    background: white;
    box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.06);
}

.regex-input::placeholder {
    color: #9ca3af;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.regex-search-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: #1f2937;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.regex-search-btn:hover {
    background: #374151;
}

/* Search highlight boxes on overlay */
.search-highlight-rect {
    position: absolute;
    background: rgba(255, 200, 0, 0.35);
    border: 1.5px solid rgba(255, 170, 0, 0.7);
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    animation: searchPulse 1.5s ease-in-out infinite;
}

@keyframes searchPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Text selection layer */
.text-select-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    cursor: text;
    z-index: 10;
    user-select: none;
}

.text-item-box {
    position: absolute;
    background: transparent;
    cursor: text;
    transition: background 0.1s;
}

.text-item-box:hover {
    background: rgba(59, 130, 246, 0.08);
}

.text-item-box.selected {
    background: rgba(59, 130, 246, 0.25);
}

.text-item-box.selecting {
    background: rgba(59, 130, 246, 0.18);
}

/* ============================================
   Auto-detect (inside accordion)
   ============================================ */
.auto-detect-scan-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 14px;
    border: 1.5px dashed #d1d5db;
    border-radius: 8px;
    background: #fafafa;
    font-size: 0.72rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    margin-bottom: 8px;
}

.auto-detect-scan-btn:hover {
    border-color: #9ca3af;
    background: #f3f4f6;
}

.auto-detect-scan-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.auto-detect-scan-btn svg {
    flex-shrink: 0;
    color: #9ca3af;
}

.auto-detect-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.auto-detect-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s;
    border: 1px solid transparent;
}

.auto-detect-row:hover {
    background: #f9fafb;
}

.auto-detect-row.checked {
    background: #eff6ff;
    border-color: #dbeafe;
}

.auto-detect-cb {
    width: 15px;
    height: 15px;
    accent-color: #1f2937;
    flex-shrink: 0;
    cursor: pointer;
}

.auto-detect-icon {
    width: 26px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 0.58rem;
    font-weight: 800;
    color: #6b7280;
    flex-shrink: 0;
    font-family: monospace;
}

.auto-detect-row.checked .auto-detect-icon {
    background: #dbeafe;
    color: #1e40af;
}

.auto-detect-label {
    flex: 1;
    font-size: 0.72rem;
    font-weight: 600;
    color: #374151;
}

.auto-detect-count {
    font-size: 0.66rem;
    font-weight: 800;
    color: #6b7280;
    background: #f3f4f6;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.auto-detect-row.checked .auto-detect-count {
    background: #dbeafe;
    color: #1e40af;
}

.auto-detect-empty {
    font-size: 0.7rem;
    color: #9ca3af;
    padding: 4px 0;
    text-align: center;
}

.auto-detect-actions {
    margin-top: 8px;
    display: flex;
}

.auto-detect-redact-btn {
    flex: 1;
    padding: 7px 14px;
    border: none;
    border-radius: 7px;
    background: #1f2937;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.auto-detect-redact-btn:hover {
    background: #374151;
}

/* Auto-detect highlight boxes on overlay */
.auto-detect-highlight {
    position: absolute;
    background: rgba(239, 68, 68, 0.2);
    border: 1.5px solid rgba(239, 68, 68, 0.6);
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    animation: autoDetectPulse 2s ease-in-out infinite;
}

@keyframes autoDetectPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============================================
   Redact Toolbar
   ============================================ */
.redact-toolbar {
    padding: 18px 28px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.redact-toolbar-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.redact-toolbar-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #9ca3af;
    min-width: 42px;
    flex-shrink: 0;
}

.redact-toolbar-divider {
    height: 1px;
    background: #f3f4f6;
}

/* Color options */
.redact-color-options {
    display: flex;
    align-items: center;
    gap: 8px;
}

.redact-color-btn {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    outline: none;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.redact-color-btn:hover {
    transform: scale(1.12);
}

.redact-color-btn.active {
    border-color: #ff6154;
    box-shadow: 0 0 0 2px white, 0 0 0 3.5px #ff6154, inset 0 0 0 1px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

/* Scope toggle */
.redact-scope-toggle {
    display: flex;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.scope-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.scope-btn:hover {
    color: #374151;
}

.scope-btn.active {
    background: white;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ============================================
   Redaction List
   ============================================ */
.redact-list-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 28px 10px 28px;
}

.redact-list-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #9ca3af;
}

.redact-list-count {
    font-size: 0.7rem;
    font-weight: 700;
    background: #f3f4f6;
    color: #6b7280;
    padding: 1px 7px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.redact-clear-link {
    margin-left: auto;
    border: none;
    background: none;
    font-size: 0.72rem;
    font-weight: 600;
    color: #d1d5db;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    transition: color 0.15s;
}

.redact-clear-link:hover:not(:disabled) {
    color: #ef4444;
}

.redact-clear-link:disabled {
    opacity: 0;
    pointer-events: none;
}

.redact-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 16px 20px;
}

.redact-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 16px;
}

.redact-list-empty-icon {
    margin-bottom: 4px;
}

.redact-list-empty-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #9ca3af;
}

.redact-list-empty-hint {
    font-size: 0.74rem;
    color: #d1d5db;
    text-align: center;
    line-height: 1.4;
}

.redact-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 10px;
    transition: all 0.15s;
    cursor: pointer;
    margin-bottom: 2px;
}

.redact-list-item:hover {
    background: #f9fafb;
}

.redact-list-item.active {
    background: #fff5f4;
    box-shadow: inset 0 0 0 1px rgba(255, 97, 84, 0.15);
}

.redact-list-item-preview {
    width: 28px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.redact-list-item-info {
    flex: 1;
    min-width: 0;
}

.redact-list-item-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
}

.redact-list-item-dims {
    font-size: 0.66rem;
    color: #c4c8cf;
}

.redact-list-item-delete {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #d1d5db;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.15s;
    flex-shrink: 0;
    opacity: 0;
}

.redact-list-item:hover .redact-list-item-delete {
    opacity: 1;
}

.redact-list-item-delete:hover {
    background: #fef2f2;
    color: #ef4444;
}

/* ============================================
   Apply Section (pinned bottom)
   ============================================ */
.apply-section {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: white;
}

.btn-apply {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    background-color: #ff6154;
    color: white;
    font-family: inherit;
}

.btn-apply:hover:not(:disabled) {
    background: #e5554a;
    box-shadow: 0 6px 16px rgba(255, 97, 84, 0.4);
    transform: translateY(-2px);
}

.btn-apply:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-apply-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.btn-apply-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.btn-apply-desc {
    font-size: 0.74rem;
    opacity: 0.8;
    font-weight: 400;
}

.btn-apply-arrow {
    width: 22px;
    height: 22px;
    stroke: white;
    flex-shrink: 0;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.btn-apply:hover:not(:disabled) .btn-apply-arrow {
    transform: translateX(4px);
}

.btn-apply.btn-loading .btn-apply-arrow {
    display: none;
}

.btn-spinner {
    width: 0;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s ease, width 0.2s ease, margin 0.2s ease;
    margin-right: -16px;
}

.btn-apply.btn-loading .btn-spinner {
    width: 20px;
    opacity: 1;
    margin-right: 0;
    animation: spinner 0.6s linear infinite;
}

.btn-apply.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   Download Screen
   ============================================ */
.download-screen {
    display: none;
    padding: 0;
    max-width: 100%;
    margin: 0;
    min-height: calc(100vh - 81px);
    background: #f5f6f8;
}

.download-screen.active {
    display: block;
}

.download-content {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 81px);
}

.pdf-preview-section {
    flex: 1;
    background: #f5f6f8;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    margin-right: 420px;
    height: calc(100vh - 81px);
    box-sizing: border-box;
}

.preview-canvas-container {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.preview-page-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    position: relative;
}

.preview-page-wrapper canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-number-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10;
}

/* Download Actions Sidebar */
.download-actions-section {
    position: fixed;
    right: 0;
    top: 81px;
    width: 420px;
    height: calc(100vh - 81px);
    background: white;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 40px;
    overflow-y: auto;
    box-sizing: border-box;
}

.back-button {
    background: transparent;
    color: #6b7280;
    border: none;
    padding: 12px 20px;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    position: absolute;
    margin-top: -10px;
    left: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: none;
    color: #ff6154;
    box-shadow: none;
    transform: translateX(-2px);
}

.back-button svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

#download-files-list {
    margin-top: 50px;
    margin-bottom: 24px;
}

.single-file-card {
    background: none;
    border: none;
    border-radius: 12px;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.single-file-thumb {
    width: 68px;
    height: 82px;
    background: white;
    border-radius: 6px;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.single-file-thumb canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.single-file-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.single-file-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.single-file-name:hover {
    background: #f0f1f3;
}

.single-file-name-base {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.single-file-name-ext {
    white-space: nowrap;
    flex-shrink: 0;
    color: #9ca3af;
    margin-left: auto;
}

.single-file-info {
    font-size: 0.7rem;
    color: #9ca3af;
}

.single-file-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-more-btn {
    background: #f9f9f9;
    border: none;
    border-radius: 8px;
    padding: 8px 6px;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.file-more-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.file-more-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    animation: modalFadeIn 0.15s ease;
}

.file-more-overlay.hidden {
    display: none !important;
}

.file-more-sheet {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: sheetSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

.file-more-group {
    background: white;
    border-radius: 16px;
    overflow: hidden;
}

.file-more-action {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background 0.15s;
}

.file-more-action:hover {
    background: #f9fafb;
}

.file-more-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-more-action-icon svg {
    color: #374151;
}

.file-more-action-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.file-more-action-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: #1f2937;
}

.file-more-action-desc {
    font-size: 0.75rem;
    color: #9ca3af;
}

.file-more-divider {
    height: 1px;
    background: #f3f4f6;
    margin: 0 18px;
}

.file-more-cancel {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: white;
    color: #6b7280;
    font-size: 0.92rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.file-more-cancel:hover {
    background: #f9fafb;
    color: #374151;
}

/* Rename Modal */
.rename-modal-card {
    background: #f5f6f8;
    border-radius: 24px;
    padding: 24px;
    width: 320px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
    animation: modalSlideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.rename-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 16px;
}

.rename-modal-input-wrap {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.rename-modal-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 14px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    color: #1f2937;
    outline: none;
    min-width: 0;
}

.rename-modal-ext {
    padding: 12px 14px 12px 0;
    font-size: 0.92rem;
    font-weight: 600;
    color: #9ca3af;
    flex-shrink: 0;
}

.rename-modal-actions {
    display: flex;
    gap: 8px;
}

.rename-modal-cancel {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: white;
    color: #6b7280;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.rename-modal-cancel:hover {
    background: #f9fafb;
    color: #374151;
}

.rename-modal-save {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: #1f2937;
    color: white;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.rename-modal-save:hover {
    background: #374151;
}

.done-button {
    background: #10b981;
    color: white;
    padding: 2px 7px;
    border-radius: 8px;
    font-size: 0.6rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 3px;
}

.done-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
}

.download-primary {
    width: 100%;
    padding: 18px 32px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #ff6154;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.download-primary:hover {
    background: #e5554a;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.35);
    transform: translateY(-1px);
}

.download-primary svg {
    width: 20px;
    height: 20px;
    stroke: white;
    fill: none;
}

.extract-another-btn {
    width: 100%;
    padding: 13px 32px;
    margin-top: 12px;
    background: transparent;
    color: #ff6154;
    border: 1.5px solid #ff6154;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.another-btn-text,
.another-btn-arrow {
    transition: opacity 0.25s ease;
}

.another-btn-arrow {
    position: absolute;
    opacity: 0;
}

.extract-another-btn:hover {
    background: #fff5f4;
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.2);
}

.extract-another-btn:hover .another-btn-text {
    opacity: 0;
}

.extract-another-btn:hover .another-btn-arrow {
    opacity: 1;
}

.content-hidden {
    display: none !important;
}

/* Scrollbar */
.controls-panel::-webkit-scrollbar,
.controls-panel-scroll::-webkit-scrollbar,
.files-preview-section::-webkit-scrollbar,
.pdf-preview-section::-webkit-scrollbar,
.download-actions-section::-webkit-scrollbar,
*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: #f3f4f6;
}

*::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

*::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1200px) {
    .controls-panel {
        width: 380px;
    }
    .files-preview-section {
        margin-right: 380px;
    }
    .download-actions-section {
        width: 380px;
    }
    .pdf-preview-section {
        margin-right: 380px;
    }
}

@media (max-width: 968px) {
    body.selection-active {
        overflow-y: auto;
    }

    .selection-panel {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .selection-content {
        flex-direction: column;
        height: auto;
    }

    .controls-panel {
        position: relative;
        width: 100%;
        height: auto;
        top: 0;
        border-left: none;
        border-bottom: 1px solid #e5e7eb;
        order: 1;
    }

    .controls-panel-scroll {
        overflow-y: visible;
    }

    .files-preview-section {
        margin-right: 0;
        height: auto;
        order: 2;
        padding: 32px 24px;
        overflow-y: visible;
    }

    .download-screen {
        position: relative;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .download-content {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 81px);
    }

    .download-actions-section {
        position: relative;
        width: 100%;
        height: auto;
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }

    .pdf-preview-section {
        margin-right: 0;
        padding: 100px 20px 20px 20px;
        height: auto;
        min-height: 50vh;
    }

    .back-button {
        top: 20px;
        left: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .files-preview-section {
        padding: 24px 16px 40px 16px;
        min-height: auto;
    }

    .controls-panel {
        padding: 0;
    }

    .controls-panel-scroll {
        padding: 20px 16px 12px 16px;
    }

    .apply-section {
        padding: 12px 16px;
    }

    .pdf-preview-section {
        padding: 80px 16px 24px 16px;
    }

    .download-actions-section {
        padding: 24px 16px;
    }

    .back-button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .redact-toolbar {
        padding: 14px 16px;
    }

    .redact-list-header {
        padding: 12px 16px 8px 16px;
    }

    .redact-list {
        padding: 0 12px 12px 12px;
    }

    .apply-section {
        padding: 12px 16px;
    }

    .redact-color-btn {
        width: 22px;
        height: 22px;
    }

    .scope-btn {
        padding: 5px 10px;
        font-size: 0.72rem;
    }

    .redact-mode-bar {
        padding: 12px 16px 8px 16px;
    }

    .accordion-header {
        padding: 10px 16px;
    }

    .accordion-section.open .accordion-body {
        padding: 0 16px 12px 16px;
    }

    .search-redact-results {
        flex-direction: column;
        align-items: stretch;
    }
}
