/* ==========================================================================
   Antigravity PDF Studio - Modern Dark Mode & Glassmorphism Design System
   ========================================================================== */

:root {
    --bg-main: #0f172a;
    --bg-deep: #0b1220;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-glass: rgba(30, 41, 59, 0.75);
    
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.35);
    --accent-ai: #8b5cf6;
    --accent-ai-hover: #7c3aed;
    --accent-ai-glow: rgba(139, 92, 246, 0.4);
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-active: rgba(59, 130, 246, 0.5);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

body.eyedropper-active {
    cursor: crosshair !important;
}

body.dragging-active {
    cursor: grabbing !important;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header & Toolbar */
/* Header & Toolbar - Streamlined Modern iLovePDF Style */
.top-header {
    height: 62px;
    background: rgba(18, 22, 34, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    gap: 16px;
    flex-wrap: nowrap;
    z-index: 100;
}

.brand {
    order: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #e11d48, #be123c);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.35);
}

.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff;
    line-height: 1.1;
}

.brand-text .badge {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.toolbar {
    order: 2;
    margin: 0 auto;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 6px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    gap: 3px;
    width: auto;
    justify-content: center;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.tool-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.tool-btn.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

.tool-separator {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0 3px;
}

.header-actions {
    order: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

/* Tools Dropdown Menu */
.tools-dropdown-wrapper {
    position: relative;
}

.tools-dropdown-card {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: #181c28;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    padding: 6px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Rotate Dropdown Menu - Sleek Compact Layout (Non Sborda) */
.rotate-dropdown-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.rotate-dropdown-card {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 235px;
    max-width: calc(100vw - 24px);
    background: rgba(18, 22, 34, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    padding: 6px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-sizing: border-box;
    animation: rotateDropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rotateDropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tool-btn.menu-open {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
}

.tool-btn .dropdown-chevron {
    font-size: 0.65rem;
    margin-left: 3px;
    transition: transform 0.2s ease;
}

.tool-btn.menu-open .dropdown-chevron {
    transform: rotate(180deg);
}

.rotate-menu-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px 4px 10px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.rotate-menu-header i {
    font-size: 0.72rem;
    color: #60a5fa;
}

.rotate-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #cbd5e1;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    box-sizing: border-box;
}

.rotate-menu-item:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #ffffff;
    transform: translateX(1px);
}

.rotate-menu-item:active {
    transform: scale(0.98);
}

.rotate-menu-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.14);
    color: #60a5fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.rotate-menu-item:hover .rotate-menu-icon {
    background: rgba(59, 130, 246, 0.28);
    color: #93c5fd;
}

.rotate-menu-icon-all {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
}

.rotate-menu-item:hover .rotate-menu-icon-all {
    background: rgba(168, 85, 247, 0.3);
    color: #e9d5ff;
}

.rotate-menu-text {
    flex: 1;
    white-space: nowrap;
}

.rotate-menu-kbd {
    font-size: 0.65rem;
    font-family: inherit;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.07);
    color: #94a3b8;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.rotate-menu-badge {
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(168, 85, 247, 0.18);
    color: #d8b4fe;
    padding: 2px 6px;
    border-radius: 4px;
}

.rotate-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 4px 6px;
}

.dropdown-item-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #cbd5e1;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    width: 100%;
}

.dropdown-item-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.dropdown-item-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.dropdown-item-btn i {
    font-size: 1rem;
    color: #3b82f6;
    width: 20px;
    text-align: center;
}

.dropdown-item-btn div strong {
    display: block;
    font-size: 0.8rem;
    color: #f1f5f9;
}

.dropdown-item-btn div small {
    display: block;
    font-size: 0.68rem;
    color: #64748b;
}

/* Vibrant iLovePDF-style Download Button */
.btn-ilovepdf {
    background: linear-gradient(135deg, #e11d48, #be123c) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    padding: 8px 18px !important;
    border: none !important;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35) !important;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}

.btn-ilovepdf:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.5) !important;
    background: linear-gradient(135deg, #f43f5e, #e11d48) !important;
}

.btn-ilovepdf:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none !important;
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
}

.btn-primary {
    background: var(--accent-primary);
    color: #ffffff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
}

.btn-ai-toggle {
    background: linear-gradient(135deg, var(--accent-ai), #6366f1);
    color: #ffffff;
    box-shadow: 0 0 15px var(--accent-ai-glow);
}

.btn-ai-toggle:hover {
    background: linear-gradient(135deg, var(--accent-ai-hover), #4f46e5);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Properties Bar */
.properties-bar {
    min-height: 48px;
    height: auto;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    font-size: 0.85rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.document-status-bar {
    min-height: 40px;
    padding: 7px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(15, 23, 42, 0.92);
    border-bottom: 1px solid rgba(16, 185, 129, 0.24);
    color: var(--text-muted);
    font-size: 0.78rem;
}

.document-status-bar[hidden] {
    display: none;
}

.document-status-main,
.document-status-metrics {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.document-status-icon,
.local-processing-badge {
    color: #6ee7b7;
}

.document-status-name {
    color: var(--text-main);
    font-weight: 600;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-status-metrics strong {
    color: var(--text-main);
}

.local-processing-badge {
    padding: 4px 8px;
    border: 1px solid rgba(16, 185, 129, 0.28);
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.08);
    font-weight: 600;
}

.prop-group {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    flex: 0 0 auto;
}

.prop-group label {
    font-weight: 500;
}

.prop-group input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
}

.prop-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.prop-group input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: 50%;
}

.prop-group input[type="range"] {
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.prop-group select {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    outline: none;
}

.prop-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.btn-icon {
    width: 34px;
    height: 34px;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-surface-hover);
}

.btn-icon.danger:hover:not(:disabled) {
    background: var(--accent-danger);
    border-color: var(--accent-danger);
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Workspace Layout */
.workspace {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.sidebar-pages {
    width: 220px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-actions .btn-icon {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

.thumbnails-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-thumbnails-state {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
}

.empty-thumbnails-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.thumb-card {
    position: relative;
    background: var(--bg-main);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.thumb-card:hover {
    border-color: var(--border-color-active);
}

.thumb-card.active {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.thumb-card canvas {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    display: block;
}

.thumb-actions-overlay {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.thumb-card:hover .thumb-actions-overlay {
    opacity: 1;
}

.thumb-rotate-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.thumb-rotate-btn:hover {
    background: var(--accent-primary, #2563eb);
    color: #ffffff;
    transform: scale(1.12);
    border-color: rgba(255, 255, 255, 0.5);
}

.rotate-quick-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.thumb-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 500;
}

/* PDF Structural Object Inspector Panel */
.sidebar-inspector {
    width: 340px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    z-index: 70;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
}

.sidebar-inspector.open {
    display: flex;
}

.inspector-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(59, 130, 246, 0.1);
}

.inspector-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-primary);
}

.inspector-title h3 {
    font-size: 0.9rem;
    font-weight: 700;
}

.inspector-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-inspector-state {
    text-align: center;
    color: var(--text-muted);
    margin: 40px 10px;
}

.empty-inspector-state i {
    font-size: 2.2rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.scan-diagnostic-card {
    padding: 20px 16px;
    text-align: center;
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.12), rgba(15, 23, 42, 0.7));
    border: 1px solid rgba(96, 165, 250, 0.35);
    border-radius: var(--radius-md);
}

.scan-diagnostic-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    display: grid;
    place-items: center;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.16);
    border-radius: 14px;
    font-size: 1.25rem;
}

.scan-diagnostic-card h4 {
    margin: 0 0 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    line-height: 1.35;
}

.scan-diagnostic-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

.scan-ocr-action {
    width: 100%;
    margin-top: 16px;
    justify-content: center;
}

/* PDF Object Item Card */
.pdf-block-card {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s ease;
}

.pdf-block-card:hover {
    border-color: var(--border-color-active);
}

.pdf-block-card.selected {
    border-color: var(--accent-primary);
    box-shadow: inset 0 0 0 1px var(--accent-primary);
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.block-id {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent-primary);
    background: rgba(59, 130, 246, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

.font-badge {
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.font-badge.subset {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
}

.font-badge.embedded {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
}

.block-text-preview {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.block-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.block-details-grid span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.native-text-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.native-text-editor textarea {
    width: 100%;
    min-height: 72px;
    resize: vertical;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #0f172a;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    line-height: 1.4;
    outline: none;
    user-select: text;
}

.native-text-editor textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.native-text-editor-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.native-text-status {
    flex: 1 1 120px;
    color: var(--text-muted);
    font-size: 0.68rem;
    line-height: 1.35;
}

.native-text-status.success {
    color: var(--accent-success);
}

.native-text-status.error {
    color: var(--accent-danger);
}

.native-text-apply {
    flex: 0 0 auto;
    padding: 7px 10px;
    font-size: 0.72rem;
}

.inspector-notice {
    margin-bottom: 10px;
    padding: 9px 10px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    font-size: 0.72rem;
    line-height: 1.4;
}

.inspector-notice.error {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
}

.pdf-compatibility-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
    padding: 9px 10px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(59, 130, 246, 0.1);
    color: #bfdbfe;
    font-size: 0.72rem;
}

.pdf-compatibility-card div {
    font-weight: 700;
    color: #60a5fa;
}

.pdf-compatibility-card span {
    font-family: var(--font-mono);
    font-size: 0.68rem;
}

.pdf-compatibility-card small {
    color: var(--text-muted);
    line-height: 1.35;
}

.stage-container {
    flex: 1;
    background-color: #12151e;
    background-image: radial-gradient(circle at 50% 15%, #1c2232 0%, #0e1118 75%);
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 36px 40px;
    position: relative;
}

.upload-dropzone {
    margin: auto;
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.dropzone-card {
    background: var(--bg-surface);
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.dropzone-icon {
    width: 72px;
    height: 72px;
    background: var(--accent-glow);
    color: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 8px;
}

.dropzone-card h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.dropzone-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.features-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.features-list i {
    color: #10b981;
    margin-right: 6px;
}

.pdf-viewport {
    display: flex;
    justify-content: center;
    align-items: center;
}

.page-wrapper {
    position: relative;
    background: #ffffff;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

#pdf-render-canvas {
    display: block;
}

/* Native PDF Text Layer - Direct Click & Edit Priority */
.text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 15;
}

.text-layer span {
    position: absolute;
    color: transparent;
    cursor: text !important;
    pointer-events: auto;
    border-radius: 1px;
    user-select: text;
    -webkit-user-select: text;
    box-sizing: border-box;
    z-index: 15;
    line-height: 1.0;
    outline: none;
    white-space: pre;
}

.text-layer span::selection {
    background: rgba(59, 130, 246, 0.35);
    color: #000000;
}

/* Annotation Layer (Sits ON TOP of Text Layer so user modifications can be clicked directly) */
.annotation-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
}

/* Editable Overlay Items & Strict Z-Index Hierarchy */
.pdf-element {
    position: absolute;
    cursor: move;
    user-select: none;
    border: 2px dashed rgba(59, 130, 246, 0.5);
    padding: 0px;
    border-radius: 2px;
    will-change: left, top, width, height;
    touch-action: none;
    pointer-events: auto !important;
    z-index: 30;
}

.pdf-whiteout-element {
    background-color: #ffffff;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
    z-index: 15 !important;
    pointer-events: none !important;
}

.pdf-whiteout-element .resize-handle,
.pdf-whiteout-element .element-drag-bar {
    display: none !important;
}

.pdf-element.selected {
    z-index: 30 !important;
}

.pdf-element.selected:not(.pdf-rect-element):not(.pdf-text-element) {
    outline: 1.5px solid var(--accent-primary);
    outline-offset: 2px;
}

.pdf-rect-element.selected {
    outline: 1.5px dashed #2563eb;
    outline-offset: 3px;
}

.pdf-text-element {
    border: none !important;
    padding: 0px !important;
    margin: 0px !important;
    cursor: text;
    transition: none;
}

.pdf-text-element:hover {
    outline: 1px dashed rgba(37, 99, 235, 0.45);
    outline-offset: 1px;
}

.pdf-text-element.selected {
    outline: 1.5px solid #2563eb !important;
    outline-offset: 1px;
    box-shadow: none !important;
}

.pdf-text-content {
    margin: 0px !important;
    padding: 0px !important;
    border: none !important;
    line-height: 1.0 !important;
    display: inline-block !important;
    white-space: nowrap !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
}

/* Ephemeral In-Place Editor (Solid Background, Zero Displacement, Zero Shift, Text 100% Contained) */
.ephemeral-editing {
    box-sizing: content-box !important;
    border: none !important;
    outline: 1.5px solid #2563eb !important;
    outline-offset: 2px !important;
    border-radius: 2px !important;
    padding: 0px 2px !important;
    margin: 0px !important;
    display: block !important;
    overflow: visible !important;
    cursor: text !important;
    user-select: text !important;
    z-index: 100 !important;
}

.ephemeral-editing .resize-handle,
.ephemeral-editing .element-drag-bar,
.pdf-text-element .element-drag-bar {
    display: none !important;
}

/* Dedicated Top Drag Bar Handle */
.pdf-element .element-drag-bar {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #3b82f6;
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 4px 4px 0 0;
    font-size: 0.65rem;
    cursor: grab;
    display: none;
    z-index: 40;
    white-space: nowrap;
}

.pdf-element:hover .element-drag-bar,
.pdf-element .element-drag-bar {
    display: none !important;
}

/* Pristine Rectangle Element (iLovePDF Style) */
.pdf-rect-element {
    box-sizing: border-box;
    cursor: move !important;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.pdf-rect-element:hover {
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

.pdf-rect-element.selected {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25) !important;
}

/* Modern Corner Control Handles (Figma / iLovePDF Style) */
.pdf-element .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border: 2px solid #2563eb;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    display: none;
    z-index: 50;
    pointer-events: auto;
    transition: transform 0.1s ease;
}

.pdf-element.selected .resize-handle {
    display: block;
}

.pdf-element .resize-handle:hover {
    transform: scale(1.35);
    background: #2563eb;
    border-color: #ffffff;
}

.pdf-element .resize-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.pdf-element .resize-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.pdf-element .resize-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.pdf-element .resize-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.pdf-element .resize-handle.n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.pdf-element .resize-handle.s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.pdf-element .resize-handle.w  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }
.pdf-element .resize-handle.e  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }

/* Text Content Container */
.pdf-text-content {
    color: inherit;
    outline: none;
    min-width: 30px;
    white-space: pre-wrap;
    font-family: inherit;
    line-height: 1.15;
    background: transparent;
    padding: 0px;
    margin: 0px;
    cursor: text;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

.pdf-text-content[contenteditable="true"]:focus {
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Versione 2: AI Assistant Sidebar */
.sidebar-ai {
    width: 320px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
    z-index: 80;
}

.sidebar-ai.open {
    display: flex;
}

.ai-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(139, 92, 246, 0.1);
}

.ai-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-ai);
}

.ai-title h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.ai-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-welcome-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
}

.ai-welcome-card h4 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--accent-ai);
}

.ai-welcome-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.ai-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.ai-action-btn:hover {
    border-color: var(--accent-ai);
    background: rgba(139, 92, 246, 0.15);
    color: #ffffff;
    transform: translateX(2px);
}

.ai-action-btn i {
    color: var(--accent-ai);
    font-size: 0.95rem;
}

.ai-chat-output {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.ai-message {
    display: flex;
    gap: 10px;
    font-size: 0.82rem;
    line-height: 1.4;
    padding: 10px;
    border-radius: var(--radius-md);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
}

.ai-message.system i {
    color: var(--accent-ai);
    font-size: 1.1rem;
    margin-top: 2px;
}

.ai-message.user {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    align-self: flex-end;
}

.ai-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.8);
}

.ai-input-group {
    display: flex;
    gap: 8px;
}

.ai-input-group input {
    flex: 1;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.82rem;
    outline: none;
}

.ai-input-group input:focus {
    border-color: var(--accent-ai);
}

.ai-input-group button {
    width: 36px;
    height: 36px;
    background: var(--accent-ai);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-input-group button:hover {
    background: var(--accent-ai-hover);
}

/* Floating Navigation Controls */
.floating-controls {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.nav-controls, .zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.page-indicator input {
    width: 40px;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    font-family: inherit;
}

/* Modal Signature */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 560px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-card-compact {
    width: min(460px, calc(100vw - 32px));
}

.modal-card-ocr {
    width: min(680px, calc(100vw - 32px));
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.modal-subtitle {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.modal-body {
    padding: 24px;
}

.modal-field {
    display: grid;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.modal-field input,
.modal-field select,
.ocr-result {
    width: 100%;
    color: var(--text-main);
    background: var(--bg-deep);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    font: inherit;
    box-sizing: border-box;
}

.modal-field input:focus,
.modal-field select:focus,
.ocr-result:focus {
    outline: 2px solid rgba(59, 130, 246, 0.3);
    border-color: var(--accent-primary);
}

.ocr-result {
    min-height: 240px;
    margin-top: 16px;
    resize: vertical;
    line-height: 1.5;
}

.modal-help,
.modal-error {
    min-height: 18px;
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.modal-error {
    color: #fb7185;
}

.find-replace-body {
    display: grid;
    gap: 16px;
}

.find-replace-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
}

.check-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
}

.check-field input {
    accent-color: var(--accent-primary);
}

.find-replace-summary {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(59, 130, 246, 0.08);
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.find-replace-summary strong {
    color: var(--text-main);
}

.modal-card-signature {
    width: min(640px, calc(100vw - 32px));
}

.sig-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 24px 0;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
}

.sig-tab-btn {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.sig-tab-btn:hover {
    color: var(--text-bright);
}

.sig-tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 6px 6px 0 0;
}

.sig-modal-body {
    padding: 20px 24px;
    min-height: 280px;
}

.sig-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}

.sig-section-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 10px 0;
}

.sig-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sig-preview-card {
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    text-align: center;
    position: relative;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sig-preview-card:hover {
    transform: translateY(-2px);
    border-color: #60a5fa;
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.25);
}

.sig-preview-card.active {
    border-color: #2563eb !important;
    background: #f8fafc;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sig-preview-card.active::after {
    content: "✓";
    position: absolute;
    top: 6px;
    right: 8px;
    background: #2563eb;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sig-preview-text {
    font-size: 1.8rem;
    color: #1d4ed8;
    line-height: 1.3;
    user-select: none;
    padding: 4px 0;
}

.sig-style-name {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sig-draw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.sig-baseline {
    width: 90%;
    height: 1px;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.2);
    position: absolute;
    bottom: 35px;
    left: 5%;
    pointer-events: none;
}

.signature-pad-wrapper {
    position: relative;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

#signature-pad-canvas {
    display: block;
    cursor: crosshair;
    width: 100%;
}

.sig-draw-tools {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.sig-upload-dropzone {
    border: 2px dashed rgba(59, 130, 246, 0.4);
    border-radius: 10px;
    padding: 30px 20px;
    text-align: center;
    background: rgba(15, 23, 42, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

.sig-upload-dropzone:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.sig-upload-dropzone i {
    font-size: 2.2rem;
    color: #3b82f6;
    margin-bottom: 8px;
}

.sig-color-options {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sig-color-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s;
}

.sig-color-btn:hover {
    transform: scale(1.15);
}

.sig-color-btn.active {
    border-color: #ffffff;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.7);
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
}

.btn-lg {
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

@media (max-width: 900px) {
    .brand-text .badge {
        display: none;
    }

    .header-actions .btn,
    .tool-btn {
        padding: 8px 10px;
    }

    .sidebar-pages {
        width: 170px;
    }

    .properties-bar {
        padding: 6px 12px;
        gap: 12px;
    }
}

@media (max-width: 680px) {
    .brand-text h1 {
        font-size: 0.95rem;
    }

    .header-actions {
        width: 100%;
        order: 2;
    }

    .document-status-bar,
    .document-status-metrics {
        align-items: flex-start;
        flex-direction: column;
    }

    .document-status-bar {
        gap: 8px;
    }

    .toolbar {
        justify-content: flex-start;
    }

    .sidebar-pages {
        width: 120px;
    }

    .tool-btn,
    .header-actions .btn {
        white-space: nowrap;
    }
}

/* ==========================================================================
   Floating Formatting Bar & Direct In-Place Text Targets
   ========================================================================== */

.floating-format-bar {
    position: absolute;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(18, 20, 29, 0.95);
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    transform: translate(-50%, -100%);
    margin-top: -12px;
    user-select: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.ff-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0 2px;
}

.ff-select {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-bright);
    font-size: 0.75rem;
    border-radius: 6px;
    padding: 3px 6px;
    outline: none;
}

.ff-size-group {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 1px 4px;
}

.ff-size-group span {
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
    color: var(--text-bright);
}

.ff-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.ff-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-bright);
}

.ff-btn.active {
    background: #2563eb;
    color: #ffffff;
}

.ff-style-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.ff-colors {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ff-color-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
}

.ff-color-dot:hover {
    transform: scale(1.25);
    border-color: white;
}

.ff-color-dot.active {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.ff-color-input {
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
}

.ff-separator {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 2px;
}

#ff-btn-delete {
    color: #ef4444;
}

#ff-btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Floating Shape Format Bar (iLovePDF Style) */
.floating-shape-bar {
    gap: 6px;
}

.ff-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 2px;
}

.ff-btn-trans {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.4);
    background: transparent;
    color: #ef4444;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s, border-color 0.15s;
}

.ff-btn-trans:hover {
    border-color: #ef4444;
    transform: scale(1.2);
}

/* Direct Text Target Overlays in Text Layer (Pristine Word/iLovePDF Document Look) */
.pdf-direct-text-target {
    position: absolute;
    cursor: text !important;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    user-select: none;
    pointer-events: auto !important;
    z-index: 16;
}

.pdf-direct-text-target:hover {
    background: rgba(37, 99, 235, 0.08) !important;
    border: 1px dashed rgba(37, 99, 235, 0.5) !important;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.2);
}

.pdf-direct-text-target.active-target {
    background: rgba(16, 185, 129, 0.12);
    border: 1px dashed rgba(16, 185, 129, 0.6);
}

/* In-place editor highlight */
.inline-text-editor-active {
    box-shadow: 0 0 0 2px #3b82f6, 0 8px 24px rgba(0, 0, 0, 0.4);
    background: white !important;
    color: black !important;
    border-radius: 3px;
}

/* ==========================================================================
   Monetization & Ad Units Layout (Google AdSense / High-CTR Sponsor Slots)
   ========================================================================== */

.ad-unit {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 8px 12px 12px;
    margin: 12px auto;
    text-align: center;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.ad-unit:hover {
    border-color: #334155;
}

.ad-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.ad-content-box {
    width: 100%;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* 1. Leaderboard Home Banner (728x90) */
.ad-unit-leaderboard {
    width: 100%;
    max-width: 728px;
    margin: 20px auto 0;
}

.ad-leaderboard-box {
    height: 75px;
    background: #1e293b;
    border: 1px dashed #334155;
    border-radius: 6px;
    color: #94a3b8;
}

.ad-placeholder-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: #94a3b8;
}

.ad-placeholder-inner i {
    color: #3b82f6;
    font-size: 1.1rem;
}

/* 2. Sidebar Ad Unit (Compact) */
.ad-unit-sidebar {
    width: 90%;
    margin: 14px auto 8px;
    padding: 8px;
}

.ad-sidebar-box {
    height: 90px;
    background: #1e293b;
    border: 1px dashed #334155;
    border-radius: 6px;
}

.ad-sidebar-box .ad-placeholder-inner {
    flex-direction: column;
    gap: 4px;
}

.ad-sidebar-box strong {
    font-size: 0.8rem;
    color: #e2e8f0;
}

.ad-sidebar-box small {
    font-size: 0.7rem;
    color: #64748b;
}

/* 3. Modal Download Completato (High-CTR Post-Download Monetization) */
.download-success-card {
    max-width: 520px;
    width: 95%;
    border-radius: 12px;
    background: #0f172a;
    border: 1px solid #1e293b;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.success-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    margin-right: 12px;
}

.success-header-text h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.success-header-text .modal-subtitle {
    font-size: 0.82rem;
    color: #94a3b8;
    margin: 2px 0 0;
}

.ad-unit-modal {
    width: 100%;
    background: #1e293b;
    border: 1px solid #334155;
    padding: 10px;
    margin-bottom: 16px;
}

.sponsor-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border: 1px solid #3b82f644;
    border-radius: 8px;
    padding: 16px 14px;
    text-align: left;
    width: 100%;
}

.sponsor-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.sponsor-card h3 {
    font-size: 0.95rem;
    color: #f1f5f9;
    margin: 0 0 6px;
    font-weight: 600;
}

.sponsor-card p {
    font-size: 0.8rem;
    color: #94a3b8;
    margin: 0 0 12px;
    line-height: 1.4;
}

.btn-sponsor {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-sponsor:hover {
    background: #1d4ed8;
}

.share-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 12px;
}

.share-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.share-input-group {
    display: flex;
    gap: 8px;
}

.share-input-group input {
    flex: 1;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #38bdf8;
    font-size: 0.82rem;
    padding: 6px 10px;
    outline: none;
}

.share-input-group button {
    white-space: nowrap;
}

/* ==========================================================================
   Cookie Consent Banner (GDPR Compliant for Google AdSense)
   ========================================================================== */
.cookie-consent-banner {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 960px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 18px 24px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 10000;
    animation: slideUpCookie 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpCookie {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.cookie-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.cookie-banner-text {
    flex: 1;
    min-width: 280px;
}

.cookie-banner-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: #f8fafc;
    margin-bottom: 6px;
}

.cookie-banner-text p {
    font-size: 0.82rem;
    color: #94a3b8;
    line-height: 1.5;
    margin: 0;
}

.cookie-banner-text a {
    color: #38bdf8;
    text-decoration: underline;
}

.cookie-banner-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* ==========================================================================
   Landing Page Educational & SEO Content (AdSense Thin Content Prevention)
   ========================================================================== */
.landing-seo-section {
    width: 100%;
    max-width: 900px;
    margin: 36px auto 0;
    text-align: left;
    color: #cbd5e1;
}

.seo-block-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.seo-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 36px;
}

.seo-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 20px;
    transition: transform 0.2s, border-color 0.2s;
}

.seo-card:hover {
    border-color: #38bdf844;
    transform: translateY(-2px);
}

.seo-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.seo-card h3 {
    font-size: 1rem;
    color: #f1f5f9;
    margin: 0 0 8px;
    font-weight: 600;
}

.seo-card p {
    font-size: 0.84rem;
    color: #94a3b8;
    line-height: 1.5;
    margin: 0;
}

/* FAQ Accordion */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
}

.faq-item {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 16px 20px;
}

.faq-item summary {
    font-weight: 600;
    font-size: 0.95rem;
    color: #f1f5f9;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.75rem;
    color: #64748b;
    transition: transform 0.2s;
}

.faq-item[open] summary::after {
    transform: rotate(180deg);
}

.faq-item p {
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.6;
    margin: 10px 0 0;
}

/* Institutional Footer */
.landing-footer {
    border-top: 1px solid #1e293b;
    padding: 24px 0 16px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.82rem;
    color: #64748b;
}

.landing-footer-links {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.landing-footer-links a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.15s;
}

.landing-footer-links a:hover {
    color: #38bdf8;
}


