/* ============================================
   PDF TEXT EDITOR - STYLES
   ============================================ */

:root {
    --primary: #6C63FF;
    --primary-dark: #5A52D5;
    --primary-bg: rgba(108, 99, 255, 0.08);
    --success: #00C9A7;
    --danger: #FF6B6B;
    --bg: #F6F8FC;
    --bg-card: #FFFFFF;
    --bg-hover: #F0F2F6;
    --text: #1A1A2E;
    --text-secondary: #4A4A6A;
    --text-muted: #8A8AA8;
    --border: #E4E6F0;
    --border-light: #F0F2F6;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.10);
    --radius: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 1440px; margin: 0 auto; padding: 0 24px; }

/* ============================================
   PRELOADER
   ============================================ */
.preloader {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}
.preloader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.preloader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preloader p { margin-top: 16px; font-size: 0.9rem; color: var(--text-secondary); }

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: #e74c3c;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text);
}
.logo-text span { color: #e74c3c; }
.logo-text span:last-child { color: var(--primary); }

.logo-badge {
    background: var(--success);
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
    text-transform: uppercase;
}

.theme-toggle {
    width: 38px;
    height: 38px;
    border: none;
    background: var(--bg-hover);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}
.theme-toggle:hover { background: var(--border); color: var(--text); }

/* ============================================
   HERO
   ============================================ */
.hero {
    padding: 24px 0 16px;
    text-align: center;
}
.hero h1 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -1px;
}
.hero h1 span { color: var(--primary); }
.hero h1 span:first-of-type { color: #e74c3c; }

.hero p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 4px 0 12px;
}

.hero-features {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}
.hero-features span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
}
.hero-features i { color: var(--success); }

/* ============================================
   EDITOR LAYOUT
   ============================================ */
.editor-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    padding: 10px 0 30px;
}

/* ============================================
   LEFT PANEL
   ============================================ */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg);
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-bg); }
.upload-zone.dragover { border-color: var(--primary); background: rgba(108,99,255,0.08); }

.upload-icon { font-size: 2.2rem; color: #e74c3c; margin-bottom: 4px; }
.upload-zone h3 { font-size: 0.9rem; font-weight: 600; }
.upload-zone p { color: var(--text-secondary); font-size: 0.8rem; }
.upload-zone .browse-link { color: var(--primary); font-weight: 600; cursor: pointer; }
.upload-zone .browse-link:hover { text-decoration: underline; }
.upload-formats { margin-top: 4px; font-size: 0.6rem; color: var(--text-muted); }

/* Page Nav */
.page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.page-nav-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-nav-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.page-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

#pageInfo { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); min-width: 70px; text-align: center; }

.page-zoom { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.page-zoom i { cursor: pointer; color: var(--text-muted); transition: var(--transition); font-size: 0.9rem; }
.page-zoom i:hover { color: var(--primary); }
#zoomLevel { font-size: 0.7rem; font-weight: 500; color: var(--text-secondary); min-width: 40px; text-align: center; }

/* Stats */
.stats-panel {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.stat-item {
    text-align: center;
}
.stat-label { display: block; font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.stat-value { display: block; font-size: 1.1rem; font-weight: 700; color: var(--text); }

/* Actions */
.actions-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.btn-primary {
    grid-column: 1 / -1;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary), #5A52D5);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(108,99,255,0.3); }

.btn-secondary {
    padding: 8px 12px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

.btn-danger {
    padding: 8px 12px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-danger:hover:not(:disabled) { background: #c0392b; }

.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   PREVIEW
   ============================================ */
.preview-panel {
    display: flex;
    flex-direction: column;
}

.preview-container {
    flex: 1;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    min-height: 500px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pdf-viewer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 20px;
    cursor: pointer;
}

.pdf-viewer canvas {
    display: block;
    max-width: 100%;
    height: auto;
    box-shadow: var(--shadow);
    border-radius: 4px;
}

.pdf-empty {
    text-align: center;
    color: var(--text-muted);
}
.pdf-empty i { font-size: 4rem; display: block; margin-bottom: 12px; opacity: 0.3; }
.pdf-empty h3 { font-size: 1rem; color: var(--text-secondary); }
.pdf-empty p { font-size: 0.85rem; margin-bottom: 12px; }

.preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ============================================
   TEXT EDIT MODAL
   ============================================ */
.text-edit-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99998;
}

.text-edit-content {
    background: var(--bg-card);
    padding: 28px 32px;
    border-radius: var(--radius-lg);
    max-width: 450px;
    width: 90%;
    box-shadow: 0 30px 80px rgba(0,0,0,0.2);
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.text-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.text-edit-header h3 { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.text-edit-header h3 i { color: var(--primary); }

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.modal-close:hover { color: var(--text); }

.text-edit-field { margin-bottom: 14px; }
.text-edit-field label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

.original-text {
    background: var(--bg-hover);
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    color: var(--text);
    border: 1px solid var(--border);
    word-break: break-all;
}

.text-edit-field input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.95rem;
    background: var(--bg-card);
    color: var(--text);
    transition: var(--transition);
}
.text-edit-field input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
    outline: none;
}

.text-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.text-edit-actions .btn-secondary { flex: 1; }
.text-edit-actions .btn-primary { flex: 2; }
.text-edit-actions .btn-danger { flex: 1; }

/* ============================================
   TOAST
   ============================================ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
    width: 100%;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.4s ease;
    border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: #FFB84D; }
.toast.info { border-left-color: #4D9AFF; }

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

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-icon.success { color: var(--success); }
.toast-icon.error { color: var(--danger); }
.toast-icon.warning { color: #FFB84D; }
.toast-icon.info { color: #4D9AFF; }

.toast-content { flex: 1; min-width: 0; }
.toast-content strong { display: block; font-size: 0.85rem; color: var(--text); }
.toast-content p { font-size: 0.75rem; color: var(--text-secondary); margin: 0; }

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.loading-container {
    background: var(--bg-card);
    padding: 36px 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 30px 80px rgba(0,0,0,0.2);
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}

.loading-container h3 { font-size: 1rem; font-weight: 600; }
.loading-container p { font-size: 0.8rem; color: var(--text-secondary); }

.loading-progress { margin-top: 14px; }
.loading-progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.loading-progress-fill { height: 100%; background: linear-gradient(135deg, var(--primary), #5A52D5); border-radius: 3px; transition: width 0.4s ease; width: 0%; }
#loadingProgressText { display: block; margin-top: 6px; font-size: 0.7rem; color: var(--text-secondary); font-weight: 500; }

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 16px 0;
    margin-top: 10px;
}
.footer-bottom { text-align: center; font-size: 0.75rem; color: var(--text-muted); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    .editor-layout { grid-template-columns: 1fr; }
    .left-panel { order: 2; }
    .preview-panel { order: 1; min-height: 400px; }
    .preview-container { min-height: 400px; }
}

@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .hero h1 { font-size: 1.6rem; }
    .stats-panel { grid-template-columns: 1fr 1fr 1fr; }
    .page-nav { flex-wrap: wrap; }
    .page-zoom { margin-left: 0; }
    .text-edit-content { padding: 20px; }
    .text-edit-actions { flex-wrap: wrap; }
    .text-edit-actions .btn-primary, .text-edit-actions .btn-secondary, .text-edit-actions .btn-danger { flex: 1; min-width: 80px; }
}

@media (max-width: 480px) {
    .hero h1 { font-size: 1.3rem; }
    .hero-features { gap: 8px; }
    .hero-features span { font-size: 0.65rem; padding: 2px 10px; }
    .actions-panel { grid-template-columns: 1fr 1fr; }
    .btn-primary { grid-column: 1 / -1; }
    .preview-container { min-height: 300px; }
    .text-edit-content { padding: 16px; }
}


/* ============================================
   TEXT EDIT ROW (Font & Size)
   ============================================ */
.text-edit-row {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.text-edit-field.half {
    flex: 1;
    min-width: 0;
}

.text-edit-field select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    background: var(--bg-card);
    color: var(--text);
    transition: var(--transition);
    appearance: auto;
}

.text-edit-field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
    outline: none;
}

.text-edit-field input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    background: var(--bg-card);
    color: var(--text);
    transition: var(--transition);
}

.text-edit-field input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
    outline: none;
}

/* Responsive */
@media (max-width: 480px) {
    .text-edit-row {
        flex-direction: column;
        gap: 8px;
    }
}