/* ==========================================================================
   Psion Organiser II Printer 2 Emulator - Design System & Styles
   ========================================================================== */

/* Theme Variables (Slate Dark & Cyber Teal) */
:root {
    --bg-app: #0b0f19;
    --bg-panel: rgba(23, 32, 53, 0.7);
    --bg-panel-solid: #131b2e;
    --border-glow: rgba(0, 242, 254, 0.15);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --color-primary: #00f2fe;     /* Cyber Teal */
    --color-secondary: #00f5d4;   /* Light Emerald */
    --color-text-main: #f8fafc;   /* White Slate */
    --color-text-muted: #94a3b8;  /* Muted Slate */
    --color-accent-red: #ef4444;
    
    --glass-blur: blur(12px);
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;

    /* Thermal Paper Colors */
    --paper-bg: #ffffff;
    --paper-shadow: rgba(0, 0, 0, 0.15);
    --ink-color: #000000;
}

/* Base Reset & Layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-app);
    background-image: 
        radial-gradient(at 0% 0%, rgba(0, 242, 254, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 245, 212, 0.04) 0px, transparent 50%);
    color: var(--color-text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

.app-container {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-grow: 1;
}

/* Header */
.app-header {
    margin-bottom: 4px;
}

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

.retro-badge {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #000;
    font-weight: 800;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 1.5px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.2);
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Main Grid Layout */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: stretch;
    flex-grow: 1;
}

.panel-printer {
    width: 100%;
    max-width: 820px;
    justify-self: center;
}

@media (max-width: 1200px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1201px) {
    body {
        min-height: 100vh;
        overflow-y: auto; /* Allow scrolling the main page down to reveal the footer */
    }
    .app-container {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }
    .workspace-grid {
        height: calc(100vh - 130px); /* Fit header + padding exactly in screen viewport */
        min-height: 580px; /* Prevent workspace from getting too squished */
        flex-shrink: 0; /* Prevent flex box from shrinking panels */
    }
    .panel {
        height: 100%;
    }
}

/* Panels */
.panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color var(--transition-normal);
}

.panel:hover {
    border-color: rgba(0, 242, 254, 0.25);
}

.panel-header {
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.4);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.panel-header i {
    color: var(--color-primary);
    font-size: 1.1rem;
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.5);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    flex-grow: 1;
}

.panel-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

/* Badges */
.badge {
    background: rgba(0, 242, 254, 0.1);
    color: var(--color-primary);
    border: 1px solid rgba(0, 242, 254, 0.3);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Copyable OPL Stubs */
.guide-text {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.note-box {
    display: flex;
    gap: 10px;
    background: rgba(0, 242, 254, 0.05);
    border: 1px solid rgba(0, 242, 254, 0.15);
    border-radius: 8px;
    padding: 12px;
    align-items: flex-start;
}

.note-box i {
    color: var(--color-primary);
    margin-top: 2px;
}

.note-box code {
    color: #fff;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 4px;
    border-radius: 3px;
}

.code-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.code-area {
    width: 100%;
    height: 110px;
    background: rgba(10, 15, 26, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    color: #00f2fe;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    resize: none;
    line-height: 1.4;
    box-shadow: var(--shadow-inset);
    outline: none;
}

.code-area:focus {
    border-color: rgba(0, 242, 254, 0.4);
}

/* Button styles */
.btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #000;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 18px rgba(0, 242, 254, 0.4);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-copy {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--color-text-main);
    padding: 4px 10px;
    font-size: 0.75rem;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-primary);
    color: #fff;
}

.btn-action {
    background: rgba(15, 23, 42, 0.5);
    border-color: var(--border-color);
    color: var(--color-text-main);
    width: 100%;
}

.btn-action:hover {
    border-color: var(--color-primary);
    background: rgba(0, 242, 254, 0.05);
    color: var(--color-primary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-accent-red);
    width: 100%;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--color-accent-red);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
}

/* Control Panel / Settings */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.serial-status-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.unsupported-alert {
    color: var(--color-accent-red);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.15);
    padding: 8px;
    border-radius: 6px;
}

/* LEDs Card */
.led-card {
    background: rgba(10, 15, 26, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.led-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.led-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.led {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #334155;
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* LED Statuses */
.led-status.connected {
    background-color: #22c55e; /* Green */
    box-shadow: 0 0 10px #22c55e, inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.led-status.disconnected {
    background-color: #ef4444; /* Red */
    box-shadow: 0 0 10px #ef4444, inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.led-rx.active {
    background-color: #06b6d4; /* Cyan */
    box-shadow: 0 0 12px #06b6d4, inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.led-buffer.active {
    background-color: #f59e0b; /* Amber */
    box-shadow: 0 0 12px #f59e0b, inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.led-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Status Table */
.status-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.status-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.status-table tr:last-child {
    border-bottom: none;
}

.status-table td {
    padding: 8px 4px;
}

.status-table td:last-child {
    text-align: right;
    color: #fff;
    font-weight: 600;
}

.font-status-card {
    background: rgba(10, 15, 26, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
}

/* Active Settings Controls */
.setting-select {
    background: rgba(10, 15, 26, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    color: #fff;
    font-size: 0.8rem;
    font-family: var(--font-sans);
    outline: none;
    cursor: pointer;
    text-align: right;
    direction: ltr;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.setting-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 6px rgba(0, 242, 254, 0.25);
}

.setting-select option {
    background: var(--bg-panel-solid);
    color: #fff;
    text-align: left;
}

/* Center Column: Printer emulation viewport */
.printer-viewport {
    background: #111827;
    position: relative;
    overflow: hidden;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: stretch;
    height: 100%;
    min-height: 500px;
    box-shadow: var(--shadow-inset);
}

/* Printer Chassis */
.printer-body {
    width: 100%;
    max-width: 780px;
    height: 100%;
    min-height: 0;
    background-color: #374151; /* Grey plastic */
    background-image: 
        linear-gradient(to right, rgba(0, 0, 0, 0.15) 0%, rgba(255, 255, 255, 0.05) 5%, rgba(0, 0, 0, 0) 15%, rgba(0, 0, 0, 0) 85%, rgba(255, 255, 255, 0.05) 95%, rgba(0, 0, 0, 0.25) 100%);
    box-shadow: 
        inset 0 1px 3px rgba(255, 255, 255, 0.1),
        0 10px 25px rgba(0, 0, 0, 0.5);
    border-left: 1px solid #4b5563;
    border-right: 1px solid #1f2937;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Printer Slot / Mouth */
.printer-mouth-shadow {
    height: 16px;
    width: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
    position: absolute;
    bottom: 104px; /* Positioned just below the tear bar */
    left: 0;
    z-index: 11;
    pointer-events: none;
}

.printer-tear-bar {
    height: 4px;
    width: 100%;
    background: repeating-linear-gradient(45deg, #1f2937, #1f2937 4px, #4b5563 4px, #4b5563 8px);
    position: absolute;
    bottom: 120px; /* Sits exactly on top of the smoky cover */
    left: 0;
    z-index: 12;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5), 0 -1px 1px rgba(255, 255, 255, 0.1);
}

/* Smoky Transparent Plastic Cover */
.printer-smoky-cover {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background: rgba(15, 23, 42, 0.65); /* Smoky grey tinted transparent */
    border-top: 1px solid rgba(255, 255, 255, 0.15); /* Highlight top edge */
    box-shadow: 
        inset 0 1px 3px rgba(255, 255, 255, 0.1),
        0 -2px 8px rgba(0, 0, 0, 0.35);
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.cover-logo {
    position: absolute;
    top: 1px; /* Moves it higher up on the plastic cover */
    left: 90px; /* Aligns it over the paper roll (which is centered and starts 70px from the left) */
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 2.25rem; /* Substantially larger font size */
    font-weight: 800;
    font-style: italic;
    letter-spacing: 5px;
    color: rgba(15, 23, 42, 0.15); /* Highly semi-transparent smoky grey, letting prints show through clearly */
    text-shadow: 
        -1px -1px 0px rgba(255, 255, 255, 0.25), /* Light highlight on the top-left edge */
        1.5px 1.5px 2px rgba(0, 0, 0, 0.7); /* Extruded drop shadow on the bottom-right edge */
    opacity: 0.95;
    user-select: none;
}

/* Paper Scroll Area */
.paper-roll-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    background: #1f2937; /* Background under the paper */
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.paper-roll-container::-webkit-scrollbar {
    width: 6px;
}

.paper-roll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.paper-roll {
    width: 640px; /* Native 640px width (1:1 pixel scale) */
    background-color: var(--paper-bg);
    box-shadow: 0 4px 20px var(--paper-shadow), 0 0 1px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    min-height: 100%;
    flex-shrink: 0; /* Prevent flex parent from shrinking the paper roll height */
    padding-bottom: 0; /* Handled by bottom spacer element */
    position: relative;
    border-left: 1px dashed rgba(0, 0, 0, 0.05);
    border-right: 1px dashed rgba(0, 0, 0, 0.05);
    transform-origin: top center;
}

.paper-roll::after {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;  /* Extend outer boundaries over the 1px borders */
    right: -1px; /* Extend outer boundaries over the 1px borders */
    bottom: 0;
    box-shadow: 
        /* Narrow sharp outer edge */
        inset var(--edge-sharp-width, 0px) 0 var(--edge-sharp-blur, 0px) var(--edge-sharp-color, transparent),
        inset calc(-1 * var(--edge-sharp-width, 0px)) 0 var(--edge-sharp-blur, 0px) var(--edge-sharp-color, transparent),
        /* Soft inner transition */
        inset var(--edge-burn-width, 0px) 0 var(--edge-burn-blur, 0px) var(--edge-burn-color, transparent),
        inset calc(-1 * var(--edge-burn-width, 0px)) 0 var(--edge-burn-blur, 0px) var(--edge-burn-color, transparent);
    pointer-events: none;
    z-index: 5; /* Render overlay on top of children */
}

.paper-roll canvas {
    opacity: var(--ink-fade-opacity, 1);
    background-color: var(--paper-bg);
    transition: opacity 0.3s ease;
}

#paperContentWrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    mask-image: var(--degradation-mask, none);
    -webkit-mask-image: var(--degradation-mask, none);
}

#paperTopSpacer {
    width: 100%;
    height: calc(100% - 96px);
    background-color: var(--paper-bg);
    flex-shrink: 0;
}

#paperBottomSpacer {
    width: 100%;
    height: 96px; /* 4 lines of 24px */
    background-color: var(--paper-bg);
    flex-shrink: 0;
}

/* Individual canvas print lines */
.paper-roll canvas {
    width: 640px; /* Lock to exact physical width */
    height: auto; /* Preserve aspect ratio of height */
    flex-shrink: 0; /* Prevent flex container from resizing height */
    display: block;
    image-rendering: pixelated; /* Retro crisp pixels */
    image-rendering: crisp-edges;
}


/* Toast alert system */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast-feedback {
    background: var(--bg-panel-solid);
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    padding: 12px 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-soft);
    font-size: 0.9rem;
    transform: translateY(20px);
    opacity: 0;
    transition: all var(--transition-normal);
}

.toast-feedback.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-feedback i {
    color: var(--color-primary);
    font-size: 1.1rem;
    text-shadow: 0 0 8px rgba(0, 242, 254, 0.5);
}

/* Floating Return to Bottom Button */
.btn-return-bottom {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 20;
    background: var(--bg-panel-solid);
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.25);
    transition: all var(--transition-fast);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

.btn-return-bottom.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.btn-return-bottom:hover {
    background: var(--color-primary);
    color: #000;
    box-shadow: 0 4px 18px rgba(0, 242, 254, 0.45);
}

/* Footer deployment guide */
.app-footer-guide {
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

.app-footer-guide h3 {
    font-size: 1.05rem;
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-footer-guide h3 i {
    color: var(--color-primary);
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 900px) {
    .guide-grid {
        grid-template-columns: 1fr;
    }
}

.guide-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.guide-card h4 {
    font-size: 0.9rem;
    color: var(--color-primary);
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.guide-card code {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--color-secondary);
    font-size: 0.75rem;
}

.copyright {
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 20px;
    margin-bottom: 12px;
}

/* ==========================================================================
   Focus Mode (Printer Only View) & Toggle Switch Styles
   ========================================================================== */

/* Layout Adjustments under Focus Mode */
body.focus-mode .panel-left,
body.focus-mode .panel-controls,
body.focus-mode .app-header,
body.focus-mode .app-footer-guide {
    display: none !important;
}

body.focus-mode .workspace-grid {
    grid-template-columns: 1fr;
    height: calc(100vh - 48px);
}

/* Toggle switch container styling */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 20px;
    transition: all var(--transition-fast);
}

.toggle-container:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(0, 242, 254, 0.3);
}

.toggle-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}

.toggle-container:hover .toggle-label {
    color: var(--color-primary);
}

/* Slider switch wrapper */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

/* Hide checkbox input visually but keep functionality */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Slider background track */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .3s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Slider knob */
.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Active slider track */
input:checked + .slider {
    background-color: var(--color-primary);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.5);
}

/* Active slider knob translation */
input:checked + .slider:before {
    transform: translateX(14px);
}

/* Circle slider round shape */
.slider.round {
    border-radius: 18px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Slide-out Sidebar Panel Trigger Tab */
.sidebar-tab-trigger {
    position: fixed;
    right: 0;
    background: rgba(19, 27, 46, 0.95);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--color-text-main);
    padding: 16px 8px;
    cursor: pointer;
    z-index: 100;
    box-shadow: -4px 0 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: right 0.6s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.2s ease, border-color 0.2s ease;
}

#controls-trigger {
    top: calc(50% + 10px);
    transform: translateY(0);
}

#help-trigger {
    top: calc(50% - 90px);
    transform: translateY(0);
}

.sidebar-tab-trigger:hover {
    background-color: rgba(23, 32, 53, 0.98);
    border-color: var(--color-primary);
    color: #ffffff;
}

.sidebar-tab-trigger.panel-open {
    right: 360px; /* slides with the panel */
}

.tab-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
}

/* Slide-out Sidebar Panel Styling (Right Side) */
.sidebar-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 360px;
    background-color: var(--bg-panel-solid);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.85);
    z-index: 99;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    backdrop-filter: var(--glass-blur);
}

.sidebar-panel.open {
    transform: translateX(0);
}

/* Slide-out Sidebar Panel Styling (Left Side) */
.sidebar-panel-left {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 360px;
    background-color: var(--bg-panel-solid);
    border-right: 1px solid var(--border-color);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.85);
    z-index: 99;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    backdrop-filter: var(--glass-blur);
}

.sidebar-panel-left.open {
    transform: translateX(0);
}

.sidebar-tab-trigger-left {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(19, 27, 46, 0.95);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: var(--color-text-main);
    padding: 16px 8px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 4px 0 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: left 0.6s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-tab-trigger-left:hover {
    background-color: rgba(23, 32, 53, 0.98);
    border-color: var(--color-primary);
    color: #ffffff;
}

.sidebar-tab-trigger-left.panel-open {
    left: 360px; /* slides with the panel */
}

/* Sidebar Internal Elements */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn-close-sidebar {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color var(--transition-fast);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-sidebar:hover {
    color: var(--color-accent-red);
}

/* Override rules for guides inside vertical help panel */
#help-panel .guide-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#help-panel .guide-card h4 {
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

#help-panel .guide-card h4 i {
    color: var(--color-primary);
}

#help-panel .guide-card p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* GPRINT Dialog Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-card {
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

.modal-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h2 i {
    color: var(--color-primary);
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-close-modal:hover {
    color: var(--color-accent-red);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-step-section h4 {
    font-size: 0.85rem;
    color: #fff;
    font-weight: 600;
    margin-bottom: 4px;
}

.modal-step-section p {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.setup-steps {
    margin-left: 20px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.setup-steps li strong {
    color: var(--color-primary);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Warning & Info Boxes */
.warning-box {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.warning-box i {
    color: var(--color-accent-red);
    margin-top: 2px;
}

.info-box {
    background: rgba(0, 242, 254, 0.05);
    border: 1px solid rgba(0, 242, 254, 0.15);
    color: var(--color-text-muted);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.info-box i {
    color: var(--color-primary);
    margin-top: 2px;
}

/* Progress Bar */
.progress-container {
    background: rgba(255, 255, 255, 0.05);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
    margin-bottom: 4px;
    width: 100%;
}

.progress-bar {
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    height: 100%;
    width: 0%;
    transition: width 0.15s linear;
}

.status-msg {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    transition: all var(--transition-fast);
}

.status-msg.awaiting {
    color: #f59e0b; /* Amber */
    font-weight: 700;
    font-size: 0.85rem;
    animation: statusPulse 1s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Startup Tab Attention Grabbing (Pulse & Peek) */
.sidebar-tab-trigger.pulse-glow {
    animation: tabPulseGlow 1.5s ease-in-out 4; /* Pulse 4 times (6 seconds total) */
}

@keyframes tabPulseGlow {
    0%, 100% {
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow: -4px 0 25px var(--color-primary), 0 0 10px var(--color-primary);
        border-color: var(--color-primary);
    }
}

/* Peek drawer hint styles */
.sidebar-panel.peek {
    transform: translateX(calc(100% - 60px));
}

.sidebar-tab-trigger.peek {
    right: 60px;
}

/* Psion Keyboard Key Styling */
.psion-key {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

/* Psion Screen Text / Option Styling */
.psion-screen {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: #f59e0b; /* Amber */
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Print Media Styles (Prints ONLY the paper roll, hiding the UI) */
@media print {
    /* Hide everything on the page by default */
    body * {
        visibility: hidden !important;
    }
    
    /* Show ONLY the paper roll, container, and its content wrapper elements */
    .paper-roll-container,
    .paper-roll,
    #paperContentWrapper,
    #paperContentWrapper *,
    .paper-roll::after {
        visibility: visible !important;
    }
    
    /* Position and center the paper roll for physical page margins */
    .paper-roll-container {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        display: flex !important;
        justify-content: center !important;
        background: none !important;
    }
    
    .paper-roll {
        position: relative !important;
        box-shadow: none !important;
        border: none !important;
        min-height: auto !important;
        height: auto !important;
        background-color: var(--paper-bg) !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
    
    /* Hide top/bottom spacers and return buttons when printing */
    #paperTopSpacer,
    #paperBottomSpacer,
    .btn-return-bottom {
        display: none !important;
        visibility: hidden !important;
    }
}

