/**
 * OnlinePrinter - Master Styling
 * CodingRider Architecture - 2026 Modern SaaS Aesthetic
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700;800&display=swap');

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --accent-purple: #7c3aed;
    --secondary-color: #475569;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --paper-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.06);
    --card-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(226, 232, 240, 0.8);
    --border-radius: 16px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e293b;
    --secondary-color: #94a3b8;
    --bg-body: #0a0f1d;
    --bg-surface: #131c2e;
    --bg-sidebar: #0f172a;
    --border-color: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --paper-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.25s ease, color 0.25s ease;
    letter-spacing: -0.15px;
}

/* Custom Smooth Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #334155;
}

/* Navbar */
.navbar-brand-badge {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #ffffff;
    padding: 7px 12px;
    border-radius: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 8px;
    padding: 6px 12px !important;
}

.nav-link.active-tab {
    color: var(--primary-color) !important;
    font-weight: 700;
    position: relative;
    background: rgba(37, 99, 235, 0.08);
}
.nav-link.active-tab::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 10px;
    right: 10px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 3px;
}

/* Main Studio Layout */
.studio-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 65px);
}

.studio-sidebar {
    width: 370px;
    min-width: 340px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 10;
}

.studio-viewport {
    flex: 1;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Studio Toolbar */
.studio-toolbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* Paper Stage Area */
.paper-stage {
    flex: 1;
    overflow: auto;
    padding: 40px 20px 80px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-image: radial-gradient(var(--border-color) 1.2px, transparent 1.2px);
    background-size: 24px 24px;
}

/* The Paper Sheet */
.paper-sheet {
    background: #ffffff;
    color: #000000;
    box-shadow: var(--paper-shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), width 0.2s ease, height 0.2s ease, filter 0.2s ease;
    transform-origin: top center;
    box-sizing: border-box;
    margin-bottom: 30px;
    overflow: hidden;
}

/* Dynamic Paper Sizes (96 DPI base for screen simulation) */
.paper-size-A4.portrait   { width: 794px; min-height: 1123px; }
.paper-size-A4.landscape  { width: 1123px; min-height: 794px; }

.paper-size-A3.portrait   { width: 1123px; min-height: 1587px; }
.paper-size-A3.landscape  { width: 1587px; min-height: 1123px; }

.paper-size-A5.portrait   { width: 559px; min-height: 794px; }
.paper-size-A5.landscape  { width: 794px; min-height: 559px; }

.paper-size-Letter.portrait  { width: 816px; min-height: 1056px; }
.paper-size-Letter.landscape { width: 1056px; min-height: 816px; }

.paper-size-Legal.portrait   { width: 816px; min-height: 1344px; }
.paper-size-Legal.landscape  { width: 1344px; min-height: 816px; }

.paper-size-Receipt_80mm.portrait,
.paper-size-Receipt_80mm.landscape { width: 302px; min-height: 600px; }

.paper-size-Receipt_58mm.portrait,
.paper-size-Receipt_58mm.landscape { width: 220px; min-height: 480px; }

.paper-size-Photo_4x6.portrait  { width: 384px; min-height: 576px; }
.paper-size-Photo_4x6.landscape { width: 576px; min-height: 384px; }

/* Color Mode Filters on Paper */
.paper-sheet.filter-grayscale {
    filter: grayscale(100%);
}
.paper-sheet.filter-monochrome {
    filter: grayscale(100%) contrast(200%);
}

/* Margin Guides */
.paper-margin-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.margin-none { padding: 0 !important; }
.margin-minimum { padding: 18px !important; } /* ~5mm */
.margin-normal { padding: 45px !important; }  /* ~15mm */
.margin-maximum { padding: 75px !important; } /* ~25mm */

/* Document Content Elements Inside Paper */
.paper-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    position: relative;
}

.paper-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
}

.paper-content canvas {
    max-width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.paper-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}

.paper-content .text-doc-render {
    width: 100%;
    height: 100%;
    font-family: 'JetBrains Mono', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: #111;
}

/* Watermark / Header & Footer */
.sheet-header, .sheet-footer {
    position: absolute;
    left: 20px;
    right: 20px;
    font-size: 10px;
    color: #888;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}
.sheet-header { top: 12px; }
.sheet-footer { bottom: 12px; }

/* Modern Dropzone */
.upload-dropzone {
    border: 2px dashed #94a3b8;
    border-radius: var(--radius-md);
    padding: 26px 16px;
    text-align: center;
    background: var(--bg-surface);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: translateY(-2px);
}

/* Sidebar Section Cards */
.setting-group {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.setting-title {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Cards & Modern Elevate */
.card {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius);
    background: var(--bg-surface);
    box-shadow: var(--card-shadow);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    border: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

/* Batch Drawer */
.batch-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -8px 25px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1050;
    max-height: 260px;
}
.batch-drawer.open {
    transform: translateY(0);
}

.batch-thumb-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 12px 20px;
}
.batch-item-card {
    min-width: 140px;
    max-width: 140px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}
.batch-item-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}
.batch-item-card:hover {
    transform: translateY(-2px);
}

.batch-thumb-preview {
    width: 100%;
    height: 80px;
    background: #ffffff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 6px;
    border: 1px solid #e2e8f0;
}

/* Page Thumbnails for PDF */
.pdf-page-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 12px 6px;
}
.pdf-page-thumb {
    min-width: 74px;
    max-width: 74px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    background: #ffffff;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: all 0.2s;
}
.pdf-page-thumb.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}
.pdf-page-thumb canvas {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* Pulse Dot */
.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Pin Pill */
.pin-pill {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 2px;
    font-family: 'JetBrains Mono', monospace;
    background: #eff6ff;
    color: #1e40af;
    padding: 5px 12px;
    border-radius: 10px;
    display: inline-block;
    border: 1px solid #bfdbfe;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
[data-theme="dark"] .loading-overlay {
    background: rgba(10, 15, 29, 0.88);
}

/* Invisible Print Container */
#printFrameContainer {
    position: absolute;
    top: -9999px;
    left: -9999px;
    width: 0;
    height: 0;
    overflow: hidden;
}
