/* ===================================================================
   public/css/pdf-editor.css
   AUDFIX PDF Editor — Mobile-first styles
   =================================================================== */

/* ─── CSS Variables ─────────────────────────────────────────────── */
:root {
    --pde-primary:       #e63946;
    --pde-primary-dark:  #c1121f;
    --pde-bg:            #f8f9fa;
    --pde-surface:       #ffffff;
    --pde-border:        #dee2e6;
    --pde-text:          #212529;
    --pde-text-muted:    #6c757d;
    --pde-sidebar-w:     220px;
    --pde-navbar-h:      52px;
    --pde-radius:        8px;
    --pde-shadow:        0 2px 8px rgba(0, 0, 0, .08);
    --pde-dark-bg:       #1a1a2e;
    --pde-dark-surface:  #16213e;
    --pde-dark-border:   #2a3a5c;
    --pde-dark-text:     #e0e8ff;
    --pde-dark-muted:    #8899cc;
}

/* ─── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* ─── Hub Body ─────────────────────────────────────────────────── */
.pde-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--pde-bg);
    color: var(--pde-text);
    line-height: 1.5;
}

/* ─── Canvas Body ───────────────────────────────────────────────── */
.pde-canvas-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--pde-dark-bg);
    color: var(--pde-dark-text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ─── Navbar ────────────────────────────────────────────────────── */
.pde-navbar {
    display: flex;
    align-items: center;
    height: var(--pde-navbar-h);
    padding: 0 1rem;
    background: var(--pde-surface);
    border-bottom: 1px solid var(--pde-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--pde-shadow);
}

.pde-navbar.pde-navbar-compact {
    background: var(--pde-dark-surface);
    border-bottom-color: var(--pde-dark-border);
    flex-shrink: 0;
}

.pde-navbar-left   { display: flex; align-items: center; gap: .5rem; flex: 1; min-width: 0; }
.pde-navbar-center { display: flex; align-items: center; gap: .5rem; }
.pde-navbar-right  { display: flex; align-items: center; gap: .5rem; justify-content: flex-end; flex: 1; }

.pde-navbar-brand {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-weight: 700;
    font-size: .95rem;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.pde-navbar-compact .pde-navbar-brand { color: var(--pde-dark-text); }

.pde-logo { height: 24px; width: auto; }

.pde-breadcrumb-sep     { color: var(--pde-text-muted); font-size: .9rem; }
.pde-breadcrumb-link    { font-size: .85rem; color: var(--pde-text-muted); text-decoration: none; white-space: nowrap; }
.pde-breadcrumb-link:hover { color: var(--pde-primary); }
.pde-breadcrumb-current {
    font-size: .85rem; color: var(--pde-text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.pde-navbar-compact .pde-breadcrumb-sep,
.pde-navbar-compact .pde-breadcrumb-current { color: var(--pde-dark-muted); }
.pde-rename-btn {
    background: none; border: none; color: var(--pde-dark-muted); cursor: pointer;
    font-size: .65rem; padding: 0 3px; opacity: 0; transition: opacity .15s; line-height: 1; vertical-align: middle;
}
.pde-navbar-left:hover .pde-rename-btn { opacity: .6; }
.pde-rename-btn:hover { opacity: 1 !important; color: var(--pde-primary); }
.pde-rename-input {
    background: rgba(255,255,255,.08); border: 1px solid var(--pde-primary); border-radius: 4px;
    color: var(--pde-dark-text); font-size: .85rem; padding: 2px 8px; outline: none;
    width: 200px; vertical-align: middle;
}

.pde-page-counter { font-size: .8rem; color: var(--pde-dark-muted); }
.pde-user-badge   { font-size: .8rem; color: var(--pde-text-muted); display: flex; align-items: center; gap: .3rem; }

/* ─── Buttons ───────────────────────────────────────────────────── */
.pde-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .9rem;
    border: none;
    border-radius: var(--pde-radius);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, opacity .15s, border-color .15s;
    white-space: nowrap;
}
.pde-btn:disabled { opacity: .5; cursor: not-allowed; }

.pde-btn-primary       { background: var(--pde-primary); color: #fff; }
.pde-btn-primary:hover { background: var(--pde-primary-dark); color: #fff; }
.pde-btn-outline       { background: transparent; border: 1px solid var(--pde-border); color: var(--pde-text); }
.pde-btn-outline:hover { background: var(--pde-bg); }
.pde-btn-ghost         { background: transparent; color: var(--pde-text-muted); }
.pde-btn-ghost:hover   { background: var(--pde-bg); color: var(--pde-text); }
.pde-btn-danger        { background: #dc3545; color: #fff; }
.pde-btn-danger:hover  { background: #b02a37; }
.pde-btn-sm  { padding: .3rem .65rem; font-size: .8rem; }
.pde-btn-lg  { padding: .65rem 1.4rem; font-size: 1rem; }

/* Dark-theme button variants (canvas) */
.pde-navbar-compact .pde-btn-outline {
    border-color: var(--pde-dark-border);
    color: var(--pde-dark-text);
    background: transparent;
}
.pde-navbar-compact .pde-btn-outline:hover { background: rgba(255,255,255,.08); }
.pde-navbar-compact .pde-btn-ghost { color: var(--pde-dark-muted); }
.pde-navbar-compact .pde-btn-ghost:hover { background: rgba(255,255,255,.08); color: var(--pde-dark-text); }

.pde-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: none; border-radius: 6px;
    cursor: pointer;
    background: transparent;
    color: var(--pde-dark-muted);
    font-size: .85rem;
    transition: background .15s, color .15s;
}
.pde-icon-btn:hover { background: rgba(255,255,255,.1); color: var(--pde-dark-text); }

/* ─── Hero ───────────────────────────────────────────────────────── */
.pde-hero {
    background: linear-gradient(135deg, #e63946 0%, #c1121f 100%);
    color: #fff;
    padding: 3.5rem 1.5rem;
    text-align: center;
}
.pde-hero h1               { font-size: 2.2rem; margin-bottom: .5rem; }
.pde-hero h1 i             { margin-right: .4rem; }
.pde-hero-subtitle         { font-size: 1.05rem; opacity: .9; max-width: 560px; margin: 0 auto 1.25rem; }
.pde-hero-actions          { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: .8rem; }
.pde-hero-note             { font-size: .8rem; opacity: .75; }
.pde-hero-note i           { margin: 0 .2rem; }

/* ─── Upload Overlay ─────────────────────────────────────────────── */
.pde-upload-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .65);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pde-upload-card {
    background: #fff;
    border-radius: 12px;
    padding: 2rem 2.5rem;
    text-align: center;
    min-width: 280px;
}
.pde-upload-icon  { font-size: 2rem; color: var(--pde-primary); margin-bottom: .75rem; }
.pde-upload-label { font-size: 1rem; margin-bottom: 1rem; color: var(--pde-text); }
.pde-progress-bar {
    height: 6px; background: #e9ecef; border-radius: 3px; overflow: hidden;
}
.pde-progress-fill {
    height: 100%; width: 0;
    background: var(--pde-primary);
    transition: width .2s ease;
}

/* ─── Container ─────────────────────────────────────────────────── */
.pde-container { max-width: 1100px; margin: 0 auto; padding: 2rem 1rem; }

/* ─── Sections ──────────────────────────────────────────────────── */
.pde-section        { margin-bottom: 2.5rem; }
.pde-section-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.pde-section-header h2 { font-size: 1.15rem; font-weight: 600; }
.pde-doc-count      { font-size: .8rem; color: var(--pde-text-muted); }

/* ─── Badges ────────────────────────────────────────────────────── */
.pde-badge {
    display: inline-block; padding: .2rem .6rem;
    border-radius: 20px; font-size: .72rem; font-weight: 600; text-transform: uppercase;
}
.pde-badge-green { background: #d1fae5; color: #065f46; }

/* ─── Features Grid ─────────────────────────────────────────────── */
.pde-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.pde-tool-card {
    background: var(--pde-surface);
    border: 1px solid var(--pde-border);
    border-radius: var(--pde-radius);
    padding: 1.25rem 1rem;
    text-align: center;
    transition: box-shadow .15s, border-color .15s;
}
.pde-tool-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); border-color: var(--pde-primary); }
.pde-tool-icon    { font-size: 1.6rem; color: var(--pde-primary); margin-bottom: .6rem; }
.pde-tool-card h3 { font-size: .9rem; font-weight: 600; margin-bottom: .35rem; }
.pde-tool-card p  { font-size: .8rem; color: var(--pde-text-muted); }

/* ─── Recent Docs Grid ──────────────────────────────────────────── */
.pde-docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.pde-doc-card {
    display: flex; gap: .85rem;
    background: var(--pde-surface);
    border: 1px solid var(--pde-border);
    border-radius: var(--pde-radius);
    padding: 1rem;
    text-decoration: none; color: inherit;
    transition: box-shadow .15s, border-color .15s;
}
.pde-doc-card:hover { box-shadow: var(--pde-shadow); border-color: var(--pde-primary); }
.pde-doc-icon  { font-size: 2rem; color: var(--pde-primary); flex-shrink: 0; padding-top: .1rem; }
.pde-doc-title { font-size: .9rem; font-weight: 600; margin-bottom: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.pde-doc-meta  { display: flex; gap: .5rem; font-size: .75rem; color: var(--pde-text-muted); margin-bottom: .2rem; flex-wrap: wrap; }
.pde-doc-time  { font-size: .75rem; color: var(--pde-text-muted); }

/* ─── Sign-In CTA ───────────────────────────────────────────────── */
.pde-section-cta { display: flex; justify-content: center; }
.pde-cta-card {
    background: var(--pde-surface);
    border: 1px dashed var(--pde-border);
    border-radius: 12px;
    padding: 2.5rem 3rem;
    text-align: center;
    max-width: 440px;
}
.pde-cta-icon      { font-size: 2.5rem; color: var(--pde-primary); margin-bottom: 1rem; display: block; }
.pde-cta-card h3   { font-size: 1.15rem; font-weight: 600; margin-bottom: .5rem; }
.pde-cta-card p    { font-size: .9rem; color: var(--pde-text-muted); margin-bottom: 1.25rem; }

/* ─── Footer ────────────────────────────────────────────────────── */
.pde-footer {
    text-align: center; padding: 2rem 1rem;
    font-size: .8rem; color: var(--pde-text-muted);
    border-top: 1px solid var(--pde-border);
}
.pde-footer a { color: var(--pde-primary); text-decoration: none; }

/* ==================================================================
   CANVAS  —  Editor Page Layout
   ================================================================== */

.pde-editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - var(--pde-navbar-h));
}

/* ─── Sidebar ───────────────────────────────────────────────────── */
.pde-sidebar {
    width: var(--pde-sidebar-w);
    flex-shrink: 0;
    background: var(--pde-dark-surface);
    border-right: 1px solid var(--pde-dark-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pde-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--pde-dark-border);
    font-size: .8rem;
    color: var(--pde-dark-muted);
    font-weight: 600;
    flex-shrink: 0;
}
.pde-sidebar-actions { display: flex; gap: .25rem; }

.pde-pages-container {
    flex: 1;
    overflow-y: auto;
    padding: .5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
/* Custom scrollbar */
.pde-pages-container::-webkit-scrollbar       { width: 5px; }
.pde-pages-container::-webkit-scrollbar-track { background: transparent; }
.pde-pages-container::-webkit-scrollbar-thumb { background: var(--pde-dark-border); border-radius: 3px; }

.pde-pages-empty {
    display: flex; flex-direction: column; align-items: center;
    padding: 2rem 1rem; color: var(--pde-dark-muted); font-size: .8rem; text-align: center;
}
.pde-pages-empty i { font-size: 1.5rem; margin-bottom: .5rem; }
.pde-pages-empty p { margin-top: .35rem; }

/* ─── Page Thumbnail Item ────────────────────────────────────────── */
.pde-page-item {
    position: relative;
    background: #1e2d4d;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: grab;
    transition: border-color .15s;
    overflow: hidden;
    user-select: none;
}
.pde-page-item:active      { cursor: grabbing; }
.pde-page-item:hover       { border-color: #4a6fa5; }
.pde-page-item.pde-selected { border-color: var(--pde-primary); }
.pde-page-item.sortable-ghost { opacity: .4; }
.pde-page-item.sortable-drag  { opacity: .9; box-shadow: 0 8px 24px rgba(0,0,0,.5); }

/* Canvas wrapper maintains page aspect ratio (A4 default) */
.pde-page-canvas-wrap {
    width: 100%;
    padding-top: 141.4%;   /* height / width = 1.414 for A4 */
    position: relative;
    background: #fff;
    overflow: hidden;
}
.pde-page-canvas-wrap canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.pde-page-number {
    position: absolute; bottom: 0; left: 0; right: 0;
    font-size: .68rem; color: var(--pde-dark-muted);
    text-align: center; padding: .2rem;
    background: rgba(22, 33, 62, .85);
}

.pde-page-del-btn {
    position: absolute; top: 4px; right: 4px;
    width: 20px; height: 20px;
    background: rgba(230, 57, 70, .85);
    color: #fff; border: none; border-radius: 50%;
    font-size: .65rem; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    transition: background .15s;
}
.pde-page-item:hover .pde-page-del-btn { display: flex; }
.pde-page-del-btn:hover { background: var(--pde-primary-dark); }

/* ─── Main Area ─────────────────────────────────────────────────── */
.pde-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--pde-dark-bg);
}

.pde-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem 1rem;
    background: var(--pde-dark-surface);
    border-bottom: 1px solid var(--pde-dark-border);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.pde-toolbar-sep  { width: 1px; height: 22px; background: var(--pde-dark-border); }
.pde-toolbar-info { font-size: .8rem; color: var(--pde-dark-muted); }

.pde-viewer-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 1rem;
}
.pde-viewer-placeholder { text-align: center; color: #4a5a7a; }
.pde-viewer-placeholder i { font-size: 2rem; margin-bottom: .5rem; display: block; }
.pde-viewer-placeholder p { font-size: .85rem; }

.pde-preview-canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    border-radius: 4px;
}

/* ─── Toast ─────────────────────────────────────────────────────── */
.pde-toast {
    position: fixed;
    bottom: 1.5rem; left: 50%;
    transform: translateX(-50%);
    background: var(--pde-dark-surface);
    color: var(--pde-dark-text);
    padding: .65rem 1.25rem;
    border-radius: 8px;
    font-size: .85rem;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    max-width: 400px; text-align: center;
    pointer-events: none;
}
.pde-toast.pde-toast-success { border-left: 3px solid #10b981; }
.pde-toast.pde-toast-error   { border-left: 3px solid var(--pde-primary); }
.pde-toast.pde-toast-info    { border-left: 3px solid #3b82f6; }

/* ─── Metadata Modal ────────────────────────────────────────────── */
.pde-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    z-index: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.pde-modal {
    background: var(--pde-dark-surface);
    border: 1px solid var(--pde-dark-border);
    border-radius: 12px;
    padding: 1.75rem;
    width: 100%; max-width: 500px;
    color: var(--pde-dark-text);
}
.pde-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.25rem;
}
.pde-modal-header h3 { font-size: 1rem; font-weight: 600; }
.pde-modal-close {
    background: transparent; border: none;
    color: var(--pde-dark-muted); cursor: pointer; font-size: 1rem; line-height: 1;
}
.pde-modal-close:hover { color: var(--pde-dark-text); }

.pde-form-group              { margin-bottom: .9rem; }
.pde-form-label              { display: block; font-size: .8rem; color: var(--pde-dark-muted); margin-bottom: .3rem; }
.pde-form-input {
    width: 100%; padding: .5rem .75rem;
    background: var(--pde-dark-bg);
    border: 1px solid var(--pde-dark-border);
    border-radius: 6px;
    color: var(--pde-dark-text);
    font-size: .85rem;
    font-family: inherit;
}
.pde-form-input:focus { outline: none; border-color: var(--pde-primary); }
.pde-form-row .pde-form-group { flex: 1; }
.pde-form-row                { display: flex; gap: .75rem; }

.pde-modal-footer {
    display: flex; justify-content: flex-end; gap: .75rem;
    margin-top: 1.25rem; padding-top: 1rem;
    border-top: 1px solid var(--pde-dark-border);
}

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .pde-sidebar                     { width: 152px; }
    .pde-hero h1                     { font-size: 1.6rem; }
    .pde-tools-grid                  { grid-template-columns: 1fr 1fr; }
    .pde-docs-grid                   { grid-template-columns: 1fr; }
    .pde-cta-card                    { padding: 1.75rem 1.25rem; }
    .pde-form-row                    { flex-direction: column; gap: 0; }
}
