/* ==========================================================================
   CSS GENERAL STYLESHEET: Saudi Medicine Label Printer
   Theme: Saudi Premium Health (Emerald Green & Dark Glassmorphism)
   ========================================================================== */

:root {
    /* Color Tokens (Dark Theme Defaults) */
    --bg-app: #0b0f14;
    --bg-card: #121922;
    --bg-card-hover: #18222f;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #10b981;
    
    --primary: #10b981; /* KSA Emerald Green */
    --primary-hover: #059669;
    --primary-alpha: rgba(16, 185, 129, 0.15);
    
    --secondary: #3b82f6; /* Medical Blue */
    --secondary-alpha: rgba(59, 130, 246, 0.12);
    
    --accent-red: #ef4444;
    --accent-red-alpha: rgba(239, 68, 68, 0.1);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-inverse: #0b0f14;
    
    --font-app: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.2);
    --radius-lg: 16px;
    --radius-md: 10px;
    
    --transition-smooth: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

/* Light Theme Variables Switch */
body.light-theme {
    --bg-app: #f4f6f8;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-focus: #059669;
    
    --primary: #059669;
    --primary-alpha: rgba(5, 150, 105, 0.08);
    
    --text-main: #1f2937;
    --text-muted: #6b7280;
    
    --shadow-glow: 0 10px 25px rgba(5, 150, 105, 0.1);
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-app);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

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

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* APP SHELL GRID LAYOUT */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* HEADER STYLE */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    gap: 15px;
    color: var(--primary);
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.3));
}

.logo-text h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.logo-text span {
    font-size: 11px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.action-btn {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.status-badge {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    background: var(--accent-red-alpha);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    font-weight: 700;
    font-size: 12px;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.status-badge.connected {
    background: var(--primary-alpha);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--primary);
}

#apiStatusDot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}

.status-badge.connected #apiStatusDot {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

/* BODY GRID SYSTEM */
.app-body {
    display: block;
    padding: 25px 30px;
    flex-grow: 1;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

/* CARDS COMMON DESIGN */
.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 25px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s ease;
}

.panel-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.panel-header {
    margin-bottom: 20px;
}

.panel-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}

.panel-header p {
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================================================
   COLUMN 1: FORM INPUT CONTROLS
   ========================================================================== */
.form-panel {
    max-height: 85vh;
    overflow-y: auto;
}

.form-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 20px;
}

body.light-theme .form-section {
    background: rgba(0, 0, 0, 0.01);
}

.section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.relative {
    position: relative;
}

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.form-control, input[type="text"], input[type="tel"], input[type="date"], input[type="month"], select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-app);
    font-size: 13px;
    transition: var(--transition-smooth);
    outline: none;
}

body.light-theme .form-control, 
body.light-theme input[type="text"], 
body.light-theme input[type="tel"], 
body.light-theme input[type="date"], 
body.light-theme input[type="month"], 
body.light-theme select, 
body.light-theme textarea {
    background: rgba(255, 255, 255, 0.8);
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--primary-alpha);
    background: rgba(0, 0, 0, 0.35);
}

body.light-theme .form-control:focus, 
body.light-theme input:focus, 
body.light-theme select:focus, 
body.light-theme textarea:focus {
    background: #ffffff;
}

.input-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: -2px;
}

/* Visual Pictograms Selector */
.picto-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.picto-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

body.light-theme .picto-btn {
    background: rgba(0, 0, 0, 0.02);
}

.picto-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--text-muted);
}

.picto-btn.active {
    background: var(--primary-alpha);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.picto-btn.active .picto-icon {
    transform: scale(1.15);
    filter: drop-shadow(0 0 5px var(--primary));
}

.picto-icon {
    font-size: 20px;
    transition: var(--transition-smooth);
}

.picto-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
}

.picto-btn.active .picto-label {
    color: var(--primary);
}

/* Warnings checkboxes grid */
.warnings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

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

.warning-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.warning-checkbox:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.warning-checkbox input[type="checkbox"] {
    accent-color: var(--primary);
    transform: scale(1.1);
    margin-top: 2px;
    cursor: pointer;
}

.warning-checkbox input[type="checkbox"]:checked + span {
    color: var(--text-main);
    font-weight: 700;
}

/* Autocomplete Medicine Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    background: #141c26;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    z-index: 50;
    display: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

body.light-theme .autocomplete-dropdown {
    background: #ffffff;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 12px;
    transition: var(--transition-smooth);
}

body.light-theme .autocomplete-item {
    border-bottom-color: rgba(0, 0, 0, 0.03);
}

.autocomplete-item:hover {
    background: var(--primary-alpha);
    color: var(--primary);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-app);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--secondary);
    color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-muted);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--text-main);
    color: var(--text-main);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 6px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

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

.pulse-primary {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

@keyframes pulseBorder {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* ==========================================================================
   COLUMN 2: THERMAL TICKET PREVIEW CARD
   ========================================================================== */
.preview-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.preview-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.preview-controls .btn {
    flex: 0 1 auto;
    width: auto;
    font-size: 11px;
    padding: 8px 16px;
    gap: 8px;
}

/* THE PRINTER CAROUSEL CONTAINER STAGE */
.label-printer-stage {
    background: #0f1620;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    margin-bottom: 20px;
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.4);
    min-height: 380px;
}

body.light-theme .label-printer-stage {
    background: #e2e8f0;
}

/* THERMAL PAPER DESIGN */
.label-ticket-paper {
    background: #ffffff;
    color: #000000;
    width: 400px;  /* 4 inches aspect ratio representation */
    height: 200px; /* 2 inches aspect ratio */
    border-radius: 4px;
    padding: 12px 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    user-select: none;
    font-family: 'Cairo', 'Tajawal', sans-serif;
    overflow: hidden;
    border: 1px solid #ddd;
}

/* Simulated Thermal Printhead Effect (Static warm tint without subpixel Moiré scanlines) */
.label-ticket-paper.thermal-effect {
    background: #fdfcf7 !important;
    filter: contrast(1.06);
}

.label-ticket-paper.thermal-effect::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(245, 240, 225, 0.12);
    pointer-events: none;
    z-index: 10;
}

/* Ticket Structure */
.label-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.pharmacy-info h4 {
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
}

.pharmacy-info p {
    font-size: 9px;
    color: #444;
}

.moh-sfda-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.sfda-tag {
    font-size: 7px;
    font-weight: 800;
    border: 1px solid #000;
    padding: 1px 3px;
    letter-spacing: 0.2px;
}

.rx-badge {
    background: #000;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 2px;
}

.label-divider {
    border-top: 1px dotted #000;
    margin: 4px 0;
}

/* Patient info box */
.label-patient-box {
    font-size: 9px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-weight: 500;
}

.info-row strong {
    font-weight: 800;
    font-size: 10px;
}

.mono {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Medicine section */
.label-medicine-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.04);
    padding: 3px 6px;
    border: 1px solid #000;
}

.med-tag {
    font-family: 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 800;
    line-height: 1;
}

.med-details {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.med-details strong {
    font-size: 10px;
    font-weight: 800;
}

.med-strength {
    font-size: 8px;
    color: #333;
    font-weight: 600;
}

/* Usage Box (The main focus) */
.label-usage-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.usage-text-main {
    font-size: 12px;
    font-weight: 800;
    flex-grow: 1;
    line-height: 1.3;
}

.label-pictograms {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.label-picto {
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #000;
    padding: 2px 3px;
    border-radius: 3px;
    width: 28px;
    line-height: 1;
}

.label-picto.hidden {
    display: none !important;
}

.picto-img {
    font-size: 12px;
}

.picto-txt {
    font-size: 6px;
    font-weight: 800;
    margin-top: 1px;
}

/* Warnings Tray */
.label-warnings-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
}

.warning-tag {
    font-size: 8px;
    font-weight: 800;
    border: 1px solid #000;
    background: #000;
    color: #fff;
    padding: 1px 4px;
    border-radius: 2px;
}

/* Footer structure */
.label-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 2px;
}

.footer-qr {
    width: 38px;
    height: 38px;
    border: 1px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1px;
    background: #fff;
}

#qrcode canvas, #qrcode img,
.footer-qr canvas, .footer-qr img {
    width: 100% !important;
    height: 100% !important;
}

.footer-dates-pharmacist {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: left;
    font-size: 7.5px;
    line-height: 1.2;
}

.footer-dates {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #888;
    padding-bottom: 2px;
    margin-bottom: 2px;
    font-weight: 600;
}

.footer-pharmacist {
    font-weight: 700;
    text-align: right;
}

/* Actions box below stage */
.print-actions-grid {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.print-actions-grid .btn {
    flex: 0 1 auto;
    width: auto;
    gap: 10px;
    height: 52px;
    padding: 0 25px;
}

/* ==========================================================================
   COLUMN 3: TECHNICAL CODE PLATFORM & HISTORY
   ========================================================================== */
.tech-panel {
    max-height: 85vh;
    overflow-y: auto;
}

.tech-subpanel {
    display: flex;
    flex-direction: column;
}

/* Code Tabs system */
.tabs-container {
    margin-top: 15px;
}

.tab-triggers {
    display: flex;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 12px;
}

.tab-trigger {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--font-app);
    font-weight: 700;
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition-smooth);
}

.tab-trigger.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Dotted Dotted Code Box */
.code-box-container {
    position: relative;
    background: #090d12;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 8px;
    overflow: hidden;
}

pre {
    margin: 0;
    max-height: 140px;
    overflow-y: auto;
}

code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: #34d399;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-box-actions {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 6px;
}

.code-box-actions .btn-icon-only {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-smooth);
}

.code-box-actions .btn-icon-only:hover {
    background: var(--primary-alpha);
    border-color: var(--primary);
    color: var(--primary);
}

.code-info {
    font-size: 10px;
    color: var(--text-muted);
}

/* Patient Archive List Section */
.history-search-wrapper {
    margin: 15px 0 10px 0;
}

#searchHistoryInput {
    font-size: 12px;
    padding: 8px 12px;
}

.history-list-wrapper {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-inline-end: 4px;
}

.empty-history {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    background: rgba(255,255,255,0.01);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.history-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
}

body.light-theme .history-card {
    background: rgba(0, 0, 0, 0.01);
}

.history-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary-alpha);
}

.history-card-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.h-patient-name {
    font-weight: 700;
    font-size: 13px;
}

.h-med-name {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
}

.h-meta {
    font-size: 10px;
    color: var(--text-muted);
}

.history-card-actions {
    display: flex;
    gap: 8px;
}

/* ==========================================================================
   GLOBAL NOTIFICATIONS & TOASTS SYSTEM
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    font-family: var(--font-app);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 4px solid var(--primary);
}

.toast.error {
    border-right-color: var(--accent-red);
}

.toast.info {
    border-right-color: var(--secondary);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================================================
   GS1 BARCODE SCANNER & CAMERA SIMULATOR WIDGET STYLING
   ========================================================================== */

.barcode-scan-widget {
    background: rgba(16, 185, 129, 0.03);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

body.light-theme .barcode-scan-widget {
    background: rgba(5, 150, 105, 0.03);
    border-color: rgba(5, 150, 105, 0.15);
}

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

.scanner-header label {
    font-weight: 700;
    color: var(--primary);
    font-size: 13px;
}

.scanner-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.scanner-laser-line {
    position: absolute;
    right: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    border-radius: 4px 0 0 4px;
    opacity: 0.85;
}

@keyframes scannerPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

#gs1BarcodeScanner {
    padding-inline-start: 18px;
    padding-inline-end: 45px;
    font-family: var(--font-mono);
    color: var(--primary);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.scan-camera-trigger {
    position: absolute;
    left: 8px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-smooth);
    z-index: 5;
    font-size: 15px;
}

.scan-camera-trigger:hover {
    background: var(--primary-alpha);
    border-color: var(--primary);
    color: var(--primary);
}

/* Parsed Information Badges Grid */
.parsed-badges-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    animation: fadeInDown 0.3s ease;
}

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

.badge-item {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
}

.badge-item strong {
    color: var(--primary);
}

.badge-item span {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-main);
}

/* VIRTUAL CAMERA VIEWPORT SIMULATOR */
.virtual-camera-simulator {
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
    animation: expandCam 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes expandCam {
    from { height: 0; opacity: 0; }
    to { height: 180px; opacity: 1; }
}

.sim-viewport {
    position: relative;
    width: 100%;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.05) 0%, rgba(0,0,0,0.9) 80%);
}

/* Views Focus Target Corner Box */
.scan-target-box {
    position: absolute;
    width: 120px;
    height: 90px;
    border: 2px dashed rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.scan-target-box::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--primary);
    top: -3px; right: -3px;
    border-bottom: none; border-left: none;
    border-radius: 0 6px 0 0;
}

.scan-target-box::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid var(--primary);
    bottom: -3px; left: -3px;
    border-top: none; border-right: none;
    border-radius: 0 0 0 6px;
}

/* Glowing red scanning laser line */
.scanner-laser {
    position: absolute;
    width: 100%;
    height: 3px;
    background: #ef4444;
    box-shadow: 0 0 12px 2px #ef4444;
    animation: laserScan 2.5s infinite linear;
    z-index: 1;
}

@keyframes laserScan {
    0% { top: 10%; }
    50% { top: 90%; }
    100% { top: 10%; }
}

.sim-camera-label {
    position: absolute;
    bottom: 12px;
    font-size: 11px;
    color: var(--primary);
    font-weight: 700;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
    animation: blinkText 1.5s infinite;
}

@keyframes blinkText {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.cancel-cam-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 10px;
    padding: 4px 8px;
    height: 24px;
    z-index: 5;
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

.cancel-cam-btn:hover {
    background: #ef4444;
    color: #fff;
}

/* Print Guidelines Warning Card (Screen View Only) */
.print-guidelines-alert {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 12px;
    color: var(--text-main);
    line-height: 1.5;
}

body.light-theme .print-guidelines-alert {
    background: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.35);
}

.print-guidelines-alert strong {
    color: #f59e0b;
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.print-guidelines-alert ul {
    margin-right: 18px;
    list-style-type: disc;
}

.print-guidelines-alert li {
    margin-bottom: 4px;
    font-size: 11.5px;
    color: var(--text-muted);
}

.print-guidelines-alert li strong {
    color: var(--text-main);
    display: inline;
    font-weight: 600;
}

/* ==========================================================================
   NAVIGATION TAB SYSTEM & NEW LAYOUT STRUCTURE
   ========================================================================== */

.app-nav {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 30px;
    gap: 15px;
    position: sticky;
    top: 73px; /* Sits right below app-header */
    z-index: 99;
    justify-content: flex-start;
}

.nav-tab {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 18px 20px;
    color: var(--text-muted);
    font-family: var(--font-app);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.nav-tab:hover {
    color: var(--text-main);
    border-bottom-color: var(--border-color);
}

.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 800;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

/* TAB PANES */
.tab-pane {
    display: none;
    width: 100%;
}

.tab-pane.active {
    display: block;
}

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

/* COMPACT PREVIEW STAGE FOR TAB 1 */
.compact-preview-panel {
    margin-bottom: 0;
    padding: 22px;
}

.preview-stage-flex {
    display: flex;
    gap: 25px;
    align-items: center;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

body.light-theme .preview-stage-flex {
    background: rgba(0, 0, 0, 0.01);
}

@media (max-width: 1100px) {
    .preview-stage-flex {
        flex-direction: column;
        align-items: stretch;
    }
    .mini-stage-wrapper {
        align-self: center;
    }
}

.mini-stage-wrapper {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0f1620;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px 20px;
    box-shadow: inset 0 4px 15px rgba(0,0,0,0.4);
    width: 440px;
    min-height: 240px;
    overflow: hidden;
}

body.light-theme .mini-stage-wrapper {
    background: #e2e8f0;
}

.label-printer-stage-mini {
    transform: none;
    transform-origin: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-actions-column {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 15px;
}

.preview-actions-column .print-guidelines-alert {
    margin-bottom: 0;
    padding: 10px 15px;
    background: rgba(245, 158, 11, 0.05);
}

.preview-actions-column .print-guidelines-alert ul {
    margin-right: 12px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    list-style-type: disc;
}

.preview-actions-column .print-guidelines-alert li {
    margin-bottom: 0;
}

.preview-actions-column .print-actions-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.preview-actions-column .print-actions-grid .btn {
    flex: 0 1 auto;
    width: auto;
    height: 48px;
    font-size: 14px;
    padding: 0 20px;
}

.preview-actions-column .preview-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.preview-actions-column .preview-controls .btn {
    flex: 0 1 auto;
    width: auto;
    height: 38px;
    font-size: 12px;
    padding: 0 15px;
}

.form-panel-new {
    padding: 25px;
    margin-bottom: 25px;
}

/* ==========================================================================
   MEDICINE DATABASE TAB STYLING
   ========================================================================== */

.medicine-db-layout {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 25px;
}

@media (max-width: 950px) {
    .medicine-db-layout {
        grid-template-columns: 1fr;
    }
}

.add-med-panel {
    height: fit-content;
}

.gtin-input-wrapper {
    display: flex;
    gap: 10px;
}

.gtin-input-wrapper input {
    flex-grow: 1;
}

.gtin-input-wrapper .btn {
    flex-shrink: 0;
    padding: 0 15px;
}

.db-count-badge {
    background: var(--primary-alpha);
    color: var(--primary);
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
}

.search-db-wrapper {
    margin-bottom: 15px;
}

.db-table-scroll {
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 13px;
}

.db-table th, .db-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.db-table th {
    background: #0d121a;
    font-weight: 700;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 5;
}

body.light-theme .db-table th {
    background: #e2e8f0;
}

.db-table tbody tr {
    /* No transition on table rows to keep large tables fast */
}

.db-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

body.light-theme .db-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.01);
}

.db-table tbody tr:last-child td {
    border-bottom: none;
}

.db-action-btn {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
    transition: var(--transition-smooth);
}

.db-action-btn:hover {
    background: var(--accent-red-alpha);
    border-color: var(--accent-red);
    color: #ef4444;
}

.db-action-btn.edit-btn {
    border-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.db-action-btn.edit-btn:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
    color: #f59e0b;
}

@keyframes pulseHighlight {
    0% { box-shadow: 0 0 0 0px rgba(245, 158, 11, 0.4); }
    100% { box-shadow: 0 0 0 15px rgba(245, 158, 11, 0); }
}

.edit-mode-highlight {
    border-color: rgba(245, 158, 11, 0.5) !important;
    animation: pulseHighlight 1.5s ease-out;
}

/* ==========================================================================
   SETTINGS TAB LAYOUT
   ========================================================================== */

.settings-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 25px;
}

@media (max-width: 1000px) {
    .settings-grid-layout {
        grid-template-columns: 1fr;
    }
}

/* Independent Print History Style & Pinned Panel */
.history-split-layout {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 20px;
    align-items: start;
}

.history-split-layout .history-list-wrapper {
    max-height: 550px;
}

.pinned-history-card {
    border-color: var(--primary-alpha);
}

.history-card.is-pinned-card {
    border-right: 3px solid #f59e0b;
}

.btn-pin-toggle {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.btn-pin-toggle:hover,
.btn-pin-toggle.active {
    background: #f59e0b;
    color: #fff;
    border-color: #d97706;
}

@media (max-width: 1000px) {
    .history-split-layout {
        grid-template-columns: 1fr;
    }
}

.full-width-history {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.full-width-history .history-list-wrapper {
    max-height: 520px;
}

.connection-status-box {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
}

body.light-theme .connection-status-box {
    background: rgba(0, 0, 0, 0.01);
}

.status-indicator-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-label {
    font-weight: 700;
    font-size: 13px;
}

.status-description {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.setup-guide-box {
    background: rgba(16, 185, 129, 0.03);
    border: 1px solid rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 12px;
}

.setup-guide-box strong {
    color: var(--primary);
    display: block;
    margin-bottom: 6px;
}

.setup-guide-box ol {
    margin-right: 18px;
    list-style-type: decimal;
}

.setup-guide-box li {
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 11.5px;
}

/* ==========================================================================
   MULTI-MEDICINE SLOTS & BATCH PRINTING STYLING
   ========================================================================== */

/* Preview selector pill bar */
.preview-selector-bar {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 15px;
    margin: 10px 0 20px 0;
    gap: 15px;
    width: 100%;
}

body.light-theme .preview-selector-bar {
    background: rgba(0, 0, 0, 0.02);
}

.selector-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.selector-pills {
    gap: 10px;
}

.preview-pill {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.preview-pill:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

.preview-pill.active {
    background: var(--primary-alpha);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

/* Medicine slots layout */
.medicine-slots-wrapper {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 15px;
}

.medicine-slot-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-smooth);
    overflow: hidden;
}

.medicine-slot-card:hover {
    background: rgba(255, 255, 255, 0.025);
    border-color: rgba(255, 255, 255, 0.12);
}

body.light-theme .medicine-slot-card {
    background: rgba(0, 0, 0, 0.005);
}
body.light-theme .medicine-slot-card:hover {
    background: rgba(0, 0, 0, 0.012);
}

/* Active Slot Indicator */
.medicine-slot-card.active-slot {
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.015);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
body.light-theme .medicine-slot-card.active-slot {
    border-color: rgba(5, 150, 105, 0.25);
    background: rgba(5, 150, 105, 0.01);
}

/* Header of card */
.slot-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 18px;
    justify-content: space-between;
    font-weight: 700;
    transition: var(--transition-smooth);
}

.medicine-slot-card.active-slot .slot-header {
    background: rgba(16, 185, 129, 0.05);
    border-bottom-color: rgba(16, 185, 129, 0.2);
}
body.light-theme .medicine-slot-card.active-slot .slot-header {
    background: rgba(5, 150, 105, 0.04);
    border-bottom-color: rgba(5, 150, 105, 0.15);
}

.slot-title {
    font-size: 14px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.slot-status-badge {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 700;
}

.slot-status-badge.empty {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.slot-status-badge.filled {
    background: var(--primary-alpha);
    border: 1px solid var(--primary);
    color: var(--primary);
}

.slot-body {
    padding: 18px;
}

.warnings-label-wrapper {
    margin-top: 15px;
}
.warnings-label-wrapper label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

/* Dynamic Display Multi-Medicine slots */
.hidden-slot {
    display: none !important;
}

/* ==========================================================================
   EXCEL IMPORT PANEL STYLING
   ========================================================================== */
.import-med-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.import-dropzone-container {
    border: 2px dashed rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-md);
    padding: 25px 15px;
    text-align: center;
    cursor: pointer;
    background: rgba(16, 185, 129, 0.01);
    transition: var(--transition-smooth);
    margin-top: 15px;
}

.import-dropzone-container:hover, .import-dropzone-container.dragover {
    border-color: var(--primary);
    background: rgba(16, 185, 129, 0.04);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.dropzone-text {
    color: var(--text-main);
    font-size: 13px;
}

body.light-theme .import-dropzone-container {
    background: rgba(5, 150, 105, 0.01);
    border-color: rgba(5, 150, 105, 0.25);
}

body.light-theme .import-dropzone-container:hover, body.light-theme .import-dropzone-container.dragover {
    background: rgba(5, 150, 105, 0.04);
}

/* NATIVE WINDOW CONTROLS STYLING */
.window-controls {
    display: flex;
    gap: 8px;
    margin-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 10px;
}

.win-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.win-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.win-close:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}

/* Light Theme support */
body.light-theme .window-controls {
    border-left-color: rgba(0, 0, 0, 0.1);
}
body.light-theme .win-btn {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: #64748b;
}
body.light-theme .win-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #0f172a;
}
body.light-theme .win-close:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
}

/* PREMIUM AHL NAV & MODAL STYLES */
.nav-btn-action {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.12));
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 15px;
    align-self: center;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.1);
    font-family: var(--font-app);
}

.nav-btn-action:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(5, 150, 105, 0.22));
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.nav-btn-action:active {
    opacity: 0.9;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 15, 30, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: rgba(18, 25, 41, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
    padding: 0;
}

.modal-close-btn:hover {
    color: #ef4444;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 20px;
}

body.light-theme .modal-card {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

body.light-theme .modal-header {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .modal-footer {
    border-top-color: rgba(0, 0, 0, 0.05);
}


/* ==========================================================================
   DYNAMIC SCREEN PREVIEW THEMES & SHOW / HIDE CONTENT RULES
   ========================================================================== */

.label-ticket-paper {
    /* Base Font Variables for screen preview stage (scaled by --fit-factor for auto-fit) */
    --fit-factor: 1;
    --label-padding: calc(6px * var(--fit-factor, 1)) calc(10px * var(--fit-factor, 1));
    --pharmacy-title-size: calc(10pt * var(--fit-factor, 1));
    --pharmacy-desc-size: calc(6.8pt * var(--fit-factor, 1));
    --rx-badge-size: calc(6pt * var(--fit-factor, 1));
    --info-row-size: calc(7.2pt * var(--fit-factor, 1));
    --info-strong-size: calc(8pt * var(--fit-factor, 1));
    --med-title-size: calc(8.5pt * var(--fit-factor, 1));
    --usage-text-size: calc(10pt * var(--fit-factor, 1));
    --warning-tag-size: calc(6pt * var(--fit-factor, 1));
    --footer-text-size: calc(6pt * var(--fit-factor, 1));
    --qr-box-size: calc(32px * var(--fit-factor, 1));
    --label-divider-margin: calc(1.5px * var(--fit-factor, 1)) 0;
    padding: var(--label-padding) !important;
    font-size: calc(7.5pt * var(--fit-factor, 1)) !important;
    line-height: 1.15 !important;
}

.label-ticket-paper * {
    line-height: 1.15;
}

/* Base font-size overrides for preview elements based on variables */
.label-ticket-paper .pharmacy-info h4 {
    font-size: var(--pharmacy-title-size) !important;
    line-height: 1.15 !important;
}
.label-ticket-paper .pharmacy-info p {
    font-size: var(--pharmacy-desc-size) !important;
    line-height: 1.15 !important;
}
.label-ticket-paper .moh-sfda-badge {
    gap: calc(1.5px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .sfda-tag {
    font-size: calc(5.2pt * var(--fit-factor, 1)) !important;
    padding: calc(0.5px * var(--fit-factor, 1)) calc(2.5px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .rx-badge {
    font-size: var(--rx-badge-size) !important;
    padding: calc(0.5px * var(--fit-factor, 1)) calc(3.5px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .info-row {
    font-size: var(--info-row-size) !important;
    margin-top: 0 !important;
}
.label-ticket-paper .info-row + .info-row {
    margin-top: calc(1px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .info-row strong {
    font-size: var(--info-strong-size) !important;
}
.label-ticket-paper .med-tag {
    font-size: calc(11pt * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .med-details strong {
    font-size: var(--med-title-size) !important;
}
.label-ticket-paper .label-usage-box {
    gap: calc(6px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .usage-text-main {
    font-size: var(--usage-text-size) !important;
    line-height: 1.2 !important;
}
.label-ticket-paper .label-warnings-tray {
    gap: calc(2px * var(--fit-factor, 1)) !important;
    margin-top: calc(1px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .label-warnings-tray:empty {
    display: none !important;
}
.label-ticket-paper .warning-tag {
    font-size: var(--warning-tag-size) !important;
    padding: calc(1px * var(--fit-factor, 1)) calc(3.5px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .footer-dates-pharmacist {
    font-size: var(--footer-text-size) !important;
    line-height: 1.12 !important;
}
.label-ticket-paper .footer-dates {
    gap: calc(6px * var(--fit-factor, 1)) !important;
    padding-bottom: calc(1px * var(--fit-factor, 1)) !important;
    margin-bottom: calc(1px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .footer-qr {
    width: var(--qr-box-size) !important;
    height: var(--qr-box-size) !important;
    flex-shrink: 0 !important;
    cursor: pointer;
}
.label-ticket-paper .label-divider {
    margin: var(--label-divider-margin) !important;
}
.label-ticket-paper .label-medicine-box {
    padding: calc(1.5px * var(--fit-factor, 1)) calc(5px * var(--fit-factor, 1)) !important;
    gap: calc(4px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .label-pictograms {
    gap: calc(2.5px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .label-picto {
    padding: calc(1px * var(--fit-factor, 1)) calc(2px * var(--fit-factor, 1)) !important;
    width: calc(24px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .picto-img {
    font-size: calc(10px * var(--fit-factor, 1)) !important;
}
.label-ticket-paper .picto-txt {
    font-size: calc(5px * var(--fit-factor, 1)) !important;
}

/* ==========================================================================
   DYNAMIC SHOW / HIDE CONTENT RULES FOR PREVIEW
   ========================================================================== */
.label-ticket-paper.hide-pharmacy .label-header {
    display: none !important;
}
.label-ticket-paper.hide-pharmacy .label-divider:nth-of-type(1) {
    display: none !important;
}

.label-ticket-paper.hide-patient .label-patient-box {
    display: none !important;
}
.label-ticket-paper.hide-patient .label-divider:nth-of-type(2) {
    display: none !important;
}

.label-ticket-paper.hide-pictograms .label-pictograms {
    display: none !important;
}

.label-ticket-paper.hide-warnings .label-warnings-tray {
    display: none !important;
}
.label-ticket-paper.hide-warnings .label-divider:nth-of-type(4) {
    display: none !important;
}

.label-ticket-paper.hide-dates .footer-dates {
    display: none !important;
}

.label-ticket-paper.hide-qrcode .footer-qr {
    display: none !important;
}

.label-ticket-paper.hide-pharmacist .footer-pharmacist {
    display: none !important;
}


/* ==========================================================================
   THEMES & TEMPLATES PREVIEW STYLING (SCREEN REPRESENTATION)
   ========================================================================== */

/* 1. EMERALD THEME (Default Premium) - Already configured in general styles */

/* 2. MONOCHROME THEME (High-Contrast Minimalist) */
.label-ticket-paper.theme-monochrome {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}
.label-ticket-paper.theme-monochrome * {
    color: #000000 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}
.label-ticket-paper.theme-monochrome .label-divider {
    border-color: #000000 !important;
}
.label-ticket-paper.theme-monochrome .label-medicine-box {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
}
.label-ticket-paper.theme-monochrome .warning-tag {
    background: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #000000 !important;
}
.label-ticket-paper.theme-monochrome .rx-badge {
    background: #000000 !important;
    color: #ffffff !important;
}

/* 3. BOLD WARNING-FOCUSED THEME */
.label-ticket-paper.theme-bold-warning {
    border-color: #f59e0b !important;
}
.label-ticket-paper.theme-bold-warning .label-usage-box {
    background: #1e1e1e !important;
    color: #ffffff !important;
    padding: 6px 12px !important;
    border-radius: 4px !important;
    margin: 2px 0 !important;
}
.label-ticket-paper.theme-bold-warning .usage-text-main {
    color: #ffffff !important;
}
.label-ticket-paper.theme-bold-warning .label-picto {
    border-color: #ffffff !important;
    background: #ffffff !important;
    color: #000000 !important;
}
.label-ticket-paper.theme-bold-warning .label-warnings-tray {
    background: rgba(245, 158, 11, 0.08) !important;
    padding: 4px 8px !important;
    border: 1px dashed #f59e0b !important;
    border-radius: var(--radius-sm) !important;
}
.label-ticket-paper.theme-bold-warning .warning-tag {
    border-color: #ef4444 !important;
    background: #ef4444 !important;
    color: #ffffff !important;
}

/* 4. COMPACT DUAL-COLUMN THEME */
.label-ticket-paper.theme-compact {
    display: grid !important;
    grid-template-columns: calc(105px * var(--fit-factor, 1)) 1fr !important;
    grid-template-rows: auto 1fr auto !important;
    gap: calc(5px * var(--fit-factor, 1)) !important;
    padding: var(--label-padding) !important;
}
.label-ticket-paper.theme-compact .label-header {
    grid-column: 1 / 2 !important;
    grid-row: 1 / 2 !important;
    border-bottom: none !important;
    margin-bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: start !important;
}
.label-ticket-paper.theme-compact .label-header .moh-sfda-badge {
    display: none !important;
}
.label-ticket-paper.theme-compact .label-footer {
    grid-column: 1 / 2 !important;
    grid-row: 2 / 4 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-inline-end: 1px dashed var(--border-color) !important;
    padding-inline-end: 8px !important;
    margin-top: 4px !important;
    height: 100% !important;
}
.label-ticket-paper.theme-compact .footer-dates-pharmacist {
    align-items: center !important;
    text-align: center !important;
    font-size: 6.5pt !important;
}
.label-ticket-paper.theme-compact .footer-dates {
    flex-direction: column !important;
    gap: 2px !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 2px !important;
}
.label-ticket-paper.theme-compact .label-patient-box {
    grid-column: 2 / 3 !important;
    grid-row: 1 / 2 !important;
    margin: 0 !important;
}
.label-ticket-paper.theme-compact .label-medicine-box {
    grid-column: 2 / 3 !important;
    grid-row: 2 / 3 !important;
    align-self: start !important;
    margin-top: 2px !important;
}
.label-ticket-paper.theme-compact .label-usage-box {
    grid-column: 2 / 3 !important;
    grid-row: 2 / 3 !important;
    align-self: end !important;
    margin-bottom: 2px !important;
}
.label-ticket-paper.theme-compact .label-warnings-tray {
    grid-column: 2 / 3 !important;
    grid-row: 3 / 4 !important;
    align-self: end !important;
}
.label-ticket-paper.theme-compact .label-divider {
    display: none !important;
}

/* ==========================================================================
   COMPACT PRESCRIPTION FORM & SMALLER INPUTS
   ========================================================================== */

/* Make form cards and inputs smaller in new prescription tab */
#tab-prescription .form-panel-new {
    padding: 15px 20px;
    margin-bottom: 15px;
}

#tab-prescription .form-section {
    padding: 10px 14px;
    margin-bottom: 10px;
}

#tab-prescription .form-row {
    margin-bottom: 8px;
    gap: 10px;
}

#tab-prescription .form-group {
    gap: 4px;
}

#tab-prescription label {
    font-size: 11px;
}

#tab-prescription .form-control, 
#tab-prescription input[type="text"], 
#tab-prescription input[type="tel"], 
#tab-prescription input[type="date"], 
#tab-prescription input[type="month"], 
#tab-prescription select {
    padding: 6px 10px;
    font-size: 12px;
    height: 32px !important;
}

#tab-prescription textarea {
    padding: 6px 10px;
    font-size: 12px;
    height: auto;
    min-height: 48px;
}

/* Medicine slot cards styling - compact grid */
#tab-prescription .medicine-slots-wrapper {
    gap: 12px;
    margin-top: 10px;
}

#tab-prescription .medicine-slot-card {
    border-radius: var(--radius-sm, 6px);
}

#tab-prescription .medicine-slot-card .slot-header {
    padding: 8px 12px;
}

#tab-prescription .medicine-slot-card .slot-body {
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
}

/* Left Column elements (Scan, Name, Expiry, Warnings) */
#tab-prescription .medicine-slot-card .slot-body > .barcode-scan-widget {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
    padding: 8px;
    border-radius: 6px;
}

#tab-prescription .medicine-slot-card .slot-body > .barcode-scan-widget .scanner-header {
    margin-bottom: 4px;
}

#tab-prescription .medicine-slot-card .slot-body > .barcode-scan-widget .scanner-input-container {
    height: 30px;
}

#tab-prescription .medicine-slot-card .slot-body > .barcode-scan-widget .gs1-barcode-scanner {
    padding: 4px 8px;
    font-size: 11px;
}

#tab-prescription .medicine-slot-card .slot-body > .barcode-scan-widget .parsed-badges-grid {
    margin-top: 4px;
    gap: 4px;
}

#tab-prescription .medicine-slot-card .slot-body > .barcode-scan-widget .badge-item {
    font-size: 10px;
    padding: 2px 6px;
}

#tab-prescription .medicine-slot-card .slot-body > .form-group.relative {
    grid-column: 1;
    grid-row: 2;
}

#tab-prescription .medicine-slot-card .slot-body > .form-row {
    grid-column: 1;
    grid-row: 3;
    margin-bottom: 0;
}

#tab-prescription .medicine-slot-card .slot-body > .warnings-label-wrapper {
    grid-column: 1;
    grid-row: 4;
    margin-top: 0;
}

#tab-prescription .medicine-slot-card .slot-body > .warnings-label-wrapper label {
    font-size: 11px;
    margin-bottom: 4px;
}

#tab-prescription .medicine-slot-card .warnings-grid {
    gap: 4px;
}

#tab-prescription .medicine-slot-card .warning-checkbox {
    font-size: 10.5px;
}

/* Right Column elements (Dosage, Pictograms, Instructions) */
#tab-prescription .medicine-slot-card .slot-body > .dosage-builder {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#tab-prescription .medicine-slot-card .slot-body > .dosage-builder .form-row {
    margin-bottom: 0;
}

#tab-prescription .medicine-slot-card .slot-body > .pictograms-selector {
    grid-column: 2;
    grid-row: 3;
    margin-top: 0;
}

#tab-prescription .medicine-slot-card .slot-body > .pictograms-selector label {
    font-size: 11px;
    margin-bottom: 4px;
}

#tab-prescription .medicine-slot-card .picto-grid {
    gap: 4px;
}

#tab-prescription .medicine-slot-card .picto-btn {
    padding: 4px 6px;
    font-size: 10px;
    border-radius: 4px;
}

#tab-prescription .medicine-slot-card .picto-icon {
    font-size: 13px;
}

#tab-prescription .medicine-slot-card .slot-body > .form-group:not(.relative) {
    grid-column: 2;
    grid-row: 4;
    margin-top: 0 !important;
}

/* Print Instructions Custom Font Size and Family */
.label-ticket-paper .usage-text-main, 
.print-label-page .usage-text-main {
    font-size: calc(var(--usage-text-size) * var(--instructions-font-multiplier, 1.0)) !important;
    font-family: var(--instructions-font-family, var(--font-app)) !important;
}
