/* =============================================================================
   FreePDFWorld — PDF Redact Tool  (redact.v2.css)
   Premium design aligned with document-upload.css design language.
   Pink/Purple accent: #ec4899 → #8b5cf6
   ============================================================================= */

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Page Wrapper ──────────────────────────────────────────────────────────── */
.page-wrapper {
    padding: 2rem 1rem;
    overflow-x: clip;
}
@supports not (overflow-x: clip) { .page-wrapper { overflow-x: hidden; } }

/* ── 3-Column Grid ─────────────────────────────────────────────────────────── */
.redact-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 1.5rem;
    align-items: start;
}

/* ── Panel Cards ───────────────────────────────────────────────────────────── */
.panel {
    background: #ffffff;
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
    height: fit-content;
    transition: box-shadow 0.3s ease;
}

.main-panel {
    background: #ffffff;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    min-height: 600px;
}

/* ── Panel Titles ──────────────────────────────────────────────────────────── */
.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.panel-title i { color: #ec4899; font-size: 1rem; }

/* ── Instruction Steps ─────────────────────────────────────────────────────── */
.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f8f9ff;
    border-radius: 10px;
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.5;
    transition: background 0.2s;
}
.instruction-item:hover { background: #f1f4ff; }
.instruction-item i {
    color: #ec4899;
    margin-top: 0.15rem;
    flex-shrink: 0;
    font-size: 0.875rem;
}

/* ── Upload Zone (premium, aligned with duc-* design) ──────────────────────── */
/* fpw-upload-widget wrapper sets CSS variables */
.fpw-upload-widget {
    --duc-accent:     #ec4899;
    --duc-accent-end: #8b5cf6;
    --duc-zone-tint:  #fef3f7;
    --duc-zone-hover: #fce7f3;
    --duc-shadow-rgb: 236,72,153;
}

/* ── PDF Viewer Container ──────────────────────────────────────────────────── */
.pdf-viewer-container {
    display: none;
    position: relative;
    background: #f8fafc;
    border-radius: 14px;
    padding: 1rem;
    min-height: 600px;
    max-height: 820px;
    overflow: auto;
    border: 1px solid #e2e8f0;
}
.pdf-viewer-container.show { display: block; }

/* Page navigation bar */
.page-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.page-controls button {
    padding: 0.45rem 1rem;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: white;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    font-family: inherit;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.page-controls button:hover { opacity: 0.88; transform: translateY(-1px); }
.page-controls button:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
}
.page-controls span {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
}

/* Canvas / Overlay */
.canvas-wrapper {
    position: relative;
    display: inline-block;
    margin: 0 auto;
}
#pdfCanvas {
    display: block;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    cursor: crosshair;
    background: white;
    max-width: 100%;
    height: auto;
    touch-action: none;
    user-select: none;
    border-radius: 4px;
}
.selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    touch-action: none;
}

/* Redaction Box */
.redaction-box {
    position: absolute;
    background: rgba(0, 0, 0, 0.72);
    border: 2px solid #ec4899;
    cursor: pointer;
    pointer-events: all;
    transition: background 0.2s, border-color 0.2s;
    border-radius: 3px;
}
.redaction-box:hover {
    background: rgba(236, 72, 153, 0.35);
    border-color: #be185d;
}
.redaction-box .delete-btn {
    position: absolute;
    top: -11px;
    right: -11px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(239,68,68,0.4);
    transition: transform 0.15s ease;
}
.redaction-box .delete-btn:hover { transform: scale(1.15); background: #dc2626; }

/* ── Redaction List Panel ───────────────────────────────────────────────────── */
.redaction-list {
    max-height: 380px;
    overflow-y: auto;
}
.redaction-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #94a3b8;
}
.redaction-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
    color: #ec4899;
    opacity: 0.5;
}
.redaction-empty p {
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
}

.redaction-item {
    padding: 0.7rem 0.875rem;
    background: #fdf2f8;
    border-radius: 9px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    border: 1px solid #fbcfe8;
    transition: background 0.2s;
}
.redaction-item:hover { background: #fce7f3; }
.redaction-item-text {
    flex: 1;
    word-break: break-all;
    margin-right: 0.5rem;
    color: #831843;
    font-weight: 500;
}
.redaction-item-page {
    font-size: 0.75rem;
    color: #9f1239;
    display: block;
    margin-bottom: 0.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.redaction-item-size { color: #be185d; font-size: 0.8rem; }

.remove-redaction-btn {
    background: #fecdd3;
    color: #be123c;
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
    flex-shrink: 0;
    font-family: inherit;
}
.remove-redaction-btn:hover { background: #ef4444; color: white; }

/* ── Action Buttons ──────────────────────────────────────────────────────────── */
.action-btn {
    width: 100%;
    padding: 0.875rem 1rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
}
.action-btn:last-child { margin-bottom: 0; }

.btn-primary {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: white;
    box-shadow: 0 4px 14px rgba(236,72,153,0.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(236,72,153,0.45);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: white;
    color: #ec4899;
    border: 2px solid #ec4899;
}
.btn-secondary:hover {
    background: #fce7f3;
    transform: translateY(-1px);
}

/* Redaction count badge */
#redactionCount {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: white;
    border-radius: 11px;
    font-size: 0.72rem;
    font-weight: 800;
    margin-left: 0.25rem;
}

/* ── Progress Section ─────────────────────────────────────────────────────── */
.progress-section {
    display: none;
    text-align: center;
    padding: 3rem 1.5rem;
}
.progress-section.show { display: block; }

.progress-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid #f3e8ff;
    border-top-color: #ec4899;
    border-radius: 50%;
    animation: redact-spin 0.9s linear infinite;
    margin: 0 auto 1.5rem;
}
@keyframes redact-spin { to { transform: rotate(360deg); } }

.progress-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}

.progress-bar-wrapper {
    width: 100%;
    max-width: 320px;
    height: 8px;
    background: #e9d5ff;
    border-radius: 10px;
    overflow: hidden;
    margin: 1.25rem auto 0.875rem;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ec4899, #8b5cf6);
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 10px;
}

.progress-text {
    color: #6b7280;
    font-size: 0.9rem;
}

/* ── Result / Success Section ─────────────────────────────────────────────── */
.result-section {
    display: none;
    animation: redact-fadeUp 0.5s ease-out;
}
.result-section.show { display: block; }

@keyframes redact-fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-card {
    background: linear-gradient(135deg, #fce7f3 0%, #fdf2f8 100%);
    border: 2px solid #f9a8d4;
    border-radius: 18px;
    padding: 2rem 1.5rem;
    text-align: center;
}

.result-success-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    color: white;
    font-size: 1.75rem;
    box-shadow: 0 8px 24px rgba(236,72,153,0.35);
}

.result-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #831843;
    margin: 0 0 0.5rem;
}

.result-message {
    color: #9f1239;
    font-size: 0.9375rem;
    margin: 0 0 1rem;
    line-height: 1.6;
}

.result-security-note {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    background: rgba(236,72,153,0.08);
    border-radius: 999px;
    color: #be185d;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(236,72,153,0.2);
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 420px;
    margin: 0 auto;
}

.result-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.0625rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(236,72,153,0.35);
    font-family: inherit;
    text-decoration: none;
}
.result-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 35px rgba(236,72,153,0.45);
}
.result-download-btn:active { transform: translateY(0); }

.result-reset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.75rem;
    background: white;
    color: #ec4899;
    border: 2px solid #ec4899;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}
.result-reset-btn:hover { background: #fce7f3; transform: translateY(-1px); }

/* ── Tools Suggestion inside result ────────────────────────────────────────── */
#toolsSuggestionInline {
    margin-top: 1.5rem;
    text-align: left;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .redact-container {
        grid-template-columns: 1fr;
    }
    .main-panel      { order: 1; }
    .panel:last-child { order: 2; }
    .panel:first-child { order: 3; }
}

@media (max-width: 768px) {
    .page-wrapper { padding: 1rem 0.5rem; }

    .panel, .main-panel {
        padding: 1.25rem;
        border-radius: 14px;
    }

    .pdf-viewer-container {
        padding: 0.5rem;
        overflow-x: auto;
        max-height: none;
    }

    #pdfCanvas {
        max-width: 100% !important;
        height: auto !important;
        width: auto !important;
    }

    .canvas-wrapper {
        max-width: 100%;
        overflow-x: auto;
        display: flex;
        justify-content: center;
    }

    .redaction-box .delete-btn {
        width: 30px;
        height: 30px;
        top: -12px;
        right: -12px;
        font-size: 13px;
    }

    .page-controls { flex-wrap: wrap; gap: 0.75rem; }

    .result-actions { max-width: 100%; }
    .result-download-btn { width: 100%; }
    .result-reset-btn { width: 100%; }
    .result-title { font-size: 1.25rem; }

    /* Mobile touch hint */
    .page-header::after {
        content: '👆 Touch and drag to select areas to redact';
        display: block;
        margin-top: 0.75rem;
        padding: 0.625rem 0.875rem;
        background: linear-gradient(135deg, #fef3f7 0%, #fce7f3 100%);
        border-radius: 8px;
        font-size: 0.8125rem;
        color: #ec4899;
        font-weight: 600;
        border: 1px solid rgba(236,72,153,0.2);
    }
}

@media (max-width: 480px) {
    .result-card { padding: 1.5rem 1rem; }
    .result-title { font-size: 1.125rem; }
    .result-success-icon { width: 52px; height: 52px; font-size: 1.4rem; }
}

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
    text-align: center;
    margin-bottom: 1.75rem;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1a1a2e;
    margin: 0 0 0.4rem;
}
.page-header p {
    color: #6b7280;
    font-size: 0.9375rem;
    margin: 0;
    line-height: 1.5;
}

/* =============================================================================
   DARK THEME OVERRIDES
   ============================================================================= */
[data-theme="dark"] body {
    background: linear-gradient(135deg, #5b1c6b 0%, #2d1b4b 100%) !important;
}

[data-theme="dark"] .panel {
    background: #1e293b !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4) !important;
}
[data-theme="dark"] .main-panel {
    background: #1e293b !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5) !important;
}
[data-theme="dark"] .panel-title         { color: #f1f5f9 !important; }
[data-theme="dark"] .panel-title i       { color: #f472b6 !important; }
[data-theme="dark"] .page-header h1      { color: #f1f5f9 !important; }
[data-theme="dark"] .page-header p       { color: #94a3b8 !important; }
[data-theme="dark"] .instruction-item    { background: #0f172a !important; color: #cbd5e1 !important; }
[data-theme="dark"] .instruction-item:hover { background: #172035 !important; }
[data-theme="dark"] .instruction-item i  { color: #f472b6 !important; }

/* Upload zone — duc-* dark overrides */
[data-theme="dark"] .fpw-upload-widget   {
    --duc-zone-tint:  #1e293b;
    --duc-zone-hover: #2d1b4b;
}
[data-theme="dark"] .duc-header .duc-title-block h1 { color: #f1f5f9 !important; }
[data-theme="dark"] .duc-header .duc-title-block > p { color: #94a3b8 !important; }
[data-theme="dark"] .duc-trust-badge {
    background: rgba(255,255,255,0.05) !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-theme="dark"] .duc-drop-zone {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .duc-drop-zone:hover,
[data-theme="dark"] .duc-drop-zone.duc-drag-over {
    background: linear-gradient(135deg, #2d1b4b 0%, #1e293b 100%) !important;
    border-color: #ec4899 !important;
}
[data-theme="dark"] .duc-drop-icon       { color: #f472b6 !important; }
[data-theme="dark"] .duc-drop-zone h3    { color: #f1f5f9 !important; }
[data-theme="dark"] .duc-drop-zone > p   { color: #94a3b8 !important; }
[data-theme="dark"] .duc-btn-gdrive {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}
[data-theme="dark"] .duc-size-limit      { color: #64748b !important; }

/* PDF viewer */
[data-theme="dark"] .pdf-viewer-container {
    background: #0f172a !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .page-controls {
    background: #1e293b !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .page-controls span  { color: #e2e8f0 !important; }
[data-theme="dark"] .page-controls button:disabled {
    background: #334155 !important;
    color: #64748b !important;
}

/* Redaction items */
[data-theme="dark"] .redaction-item {
    background: #0f172a !important;
    border-color: #334155 !important;
}
[data-theme="dark"] .redaction-item:hover { background: #172035 !important; }
[data-theme="dark"] .redaction-item-text  { color: #f9a8d4 !important; }
[data-theme="dark"] .redaction-item-page  { color: #f472b6 !important; }
[data-theme="dark"] .redaction-item-size  { color: #f9a8d4 !important; }
[data-theme="dark"] .redaction-empty      { color: #64748b !important; }
[data-theme="dark"] .remove-redaction-btn {
    background: rgba(239,68,68,0.15) !important;
    color: #fca5a5 !important;
}
[data-theme="dark"] .remove-redaction-btn:hover { background: #ef4444 !important; color: white !important; }

/* Action buttons */
[data-theme="dark"] .btn-secondary {
    background: #1e293b !important;
    color: #f472b6 !important;
    border-color: #ec4899 !important;
}
[data-theme="dark"] .btn-secondary:hover { background: rgba(236,72,153,0.1) !important; }

/* Progress */
[data-theme="dark"] .progress-bar-wrapper { background: #334155 !important; }
[data-theme="dark"] .progress-title        { color: #f1f5f9 !important; }
[data-theme="dark"] .progress-text         { color: #94a3b8 !important; }

/* Result */
[data-theme="dark"] .result-card {
    background: linear-gradient(135deg, rgba(236,72,153,0.08) 0%, rgba(139,92,246,0.08) 100%) !important;
    border-color: rgba(236,72,153,0.3) !important;
}
[data-theme="dark"] .result-title   { color: #f9a8d4 !important; }
[data-theme="dark"] .result-message { color: #e879f9 !important; }
[data-theme="dark"] .result-security-note {
    background: rgba(236,72,153,0.1) !important;
    color: #f472b6 !important;
    border-color: rgba(236,72,153,0.2) !important;
}
[data-theme="dark"] .result-reset-btn {
    background: #1e293b !important;
    color: #f472b6 !important;
    border-color: #ec4899 !important;
}
[data-theme="dark"] .result-reset-btn:hover { background: rgba(236,72,153,0.1) !important; }

