/**
 * Print Optimization Stylesheet - PharmAssist
 * Optimizes all pages for printing
 * 
 * @media print rules for clean, professional printouts
 */

@media print {
    /* Reset for print */
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Page setup */
    @page {
        margin: 0.75in;
        size: auto;
    }
    
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
        margin: 0;
        padding: 0;
    }
    
    /* Hide non-printable elements */
    .user-info-bar,
    .dark-mode-btn,
    .logout-btn,
    .back-btn,
    .notification-btn-wrapper,
    .global-search-container,
    .breadcrumb-container,
    nav,
    .navigation,
    .nav-bar,
    header,
    footer,
    .sidebar,
    .menu,
    .toolbar,
    button,
    .btn,
    input[type="button"],
    input[type="submit"],
    input[type="reset"],
    .widget-header-actions,
    .widget-collapse-btn,
    .widget-size-btn,
    .widget-size-dropdown,
    .easter-egg-container,
    .pull-to-refresh,
    .fab,
    .floating-action-button,
    .glass-fab,
    .scroll-to-top,
    audio,
    video,
    iframe,
    .advertisement,
    .ad,
    .social-share,
    .comments {
        display: none !important;
    }
    
    /* Hide interactive elements */
    .copyable::after,
    .tooltip,
    .dropdown,
    .modal-overlay,
    .toast,
    .notification,
    .alert.dismissible {
        display: none !important;
    }
    
    /* Container adjustments */
    .container,
    .app-container,
    .content,
    .main-content {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Remove backgrounds and gradients */
    body,
    div,
    section,
    article,
    aside,
    .panel,
    .card,
    .widget,
    .dashboard-item {
        background: white !important;
        background-image: none !important;
    }
    
    /* Text optimization */
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
        page-break-after: avoid;
        orphans: 3;
        widows: 3;
    }
    
    h1 {
        font-size: 24pt;
        margin-bottom: 12pt;
    }
    
    h2 {
        font-size: 18pt;
        margin-bottom: 10pt;
    }
    
    h3 {
        font-size: 14pt;
        margin-bottom: 8pt;
    }
    
    p, li {
        orphans: 3;
        widows: 3;
    }
    
    /* Links */
    a {
        color: black !important;
        text-decoration: underline;
    }
    
    /* Show URLs for links */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: #666;
    }
    
    /* Don't show URLs for internal links */
    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: "";
    }
    
    /* Tables */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: avoid;
        border: 1px solid #000 !important;
    }
    
    thead {
        display: table-header-group;
    }
    
    tbody {
        display: table-row-group;
    }
    
    th, td {
        border: 1px solid #000 !important;
        padding: 8pt !important;
        text-align: left;
        background: white !important;
        color: black !important;
    }
    
    th {
        font-weight: bold;
        background: #f0f0f0 !important;
    }
    
    tr {
        page-break-inside: avoid;
    }
    
    /* Page breaks */
    .page-break,
    .page-break-before {
        page-break-before: always;
    }
    
    .page-break-after {
        page-break-after: always;
    }
    
    .no-page-break,
    .keep-together {
        page-break-inside: avoid;
    }
    
    /* Images */
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
    
    /* Expand collapsed sections */
    .widget-content,
    .collapsible-content,
    .accordion-content,
    details {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    /* Print header - Add page title and date */
    body::before {
        content: "PharmAssist - " attr(data-page-title);
        display: block;
        font-size: 18pt;
        font-weight: bold;
        margin-bottom: 12pt;
        padding-bottom: 8pt;
        border-bottom: 2px solid #000;
    }
    
    body::after {
        content: "Printed: " attr(data-print-date);
        display: block;
        font-size: 9pt;
        margin-top: 16pt;
        padding-top: 8pt;
        border-top: 1px solid #999;
        color: #666;
    }
    
    /* Clinical references - Special handling */
    .clinical-reference,
    .drug-info,
    .dosing-table,
    .calculator-result {
        border: 2px solid #000 !important;
        padding: 12pt !important;
        margin: 12pt 0 !important;
        page-break-inside: avoid;
    }
    
    .clinical-reference h3,
    .drug-info h3 {
        margin-top: 0;
        border-bottom: 1px solid #000;
        padding-bottom: 4pt;
    }
    
    /* Calculator results */
    .calculator-result {
        background: #f9f9f9 !important;
    }
    
    .calculator-result label {
        font-weight: bold;
    }
    
    .calculator-result .result-value {
        font-size: 14pt;
        font-weight: bold;
        margin: 8pt 0;
    }
    
    /* Labels and signs - Preserve special formatting */
    .label-preview,
    .sign-preview,
    .pharmacy-label {
        border: 2px dashed #000 !important;
        padding: 16pt !important;
        margin: 16pt 0 !important;
        font-family: 'Courier New', monospace !important;
    }
    
    /* Preserve label text size */
    .label-preview {
        font-size: 11pt !important;
    }
    
    /* Dashboard widgets */
    .dashboard-grid {
        display: block !important;
    }
    
    .dashboard-item {
        width: 100% !important;
        margin-bottom: 16pt !important;
        border: 1px solid #ccc !important;
        padding: 12pt !important;
        page-break-inside: avoid;
    }
    
    .widget-header {
        border-bottom: 1px solid #000;
        margin-bottom: 8pt;
        padding-bottom: 4pt;
    }
    
    /* Drug lists and alternatives */
    .drug-list,
    .alternatives-list,
    .comparison-table {
        margin: 12pt 0;
    }
    
    .drug-card {
        border: 1px solid #000 !important;
        padding: 8pt !important;
        margin-bottom: 8pt !important;
        page-break-inside: avoid;
    }
    
    /* Therapeutic alternatives */
    .alternative-item {
        padding-left: 16pt;
        margin-bottom: 8pt;
    }
    
    .alternative-item::before {
        content: "→ ";
        font-weight: bold;
    }
    
    /* Clinical calculators - Multiple per page */
    .calculator-section {
        border: 1px solid #ccc !important;
        padding: 12pt !important;
        margin-bottom: 16pt !important;
        page-break-inside: avoid;
    }
    
    .calculator-title {
        font-size: 14pt;
        font-weight: bold;
        margin-bottom: 8pt;
        border-bottom: 1px solid #000;
        padding-bottom: 4pt;
    }
    
    /* Forms - Show values */
    input,
    textarea,
    select {
        border: none !important;
        border-bottom: 1px solid #000 !important;
        background: white !important;
        color: black !important;
        padding: 2pt 4pt !important;
    }
    
    input[type="checkbox"],
    input[type="radio"] {
        border: 1px solid #000 !important;
    }
    
    /* Print disclaimers and notes */
    .print-only {
        display: block !important;
    }
    
    .no-print {
        display: none !important;
    }
    
    .disclaimer,
    .print-note,
    .clinical-note {
        font-size: 9pt;
        font-style: italic;
        color: #666;
        border-left: 3px solid #ccc;
        padding-left: 8pt;
        margin: 8pt 0;
    }
    
    /* Page numbers */
    .page-number::after {
        content: counter(page);
    }
    
    /* Charts and graphs - Convert to tables if possible */
    .chart,
    .graph {
        page-break-inside: avoid;
        border: 1px solid #000;
        padding: 8pt;
    }
    
    /* Highlighting important info */
    .highlight-print,
    .important-print {
        border: 2px solid #000 !important;
        background: #fffacd !important;
        padding: 8pt !important;
        margin: 8pt 0 !important;
        font-weight: bold;
    }
    
    /* Breadcrumb - simplified for print */
    .breadcrumb {
        display: none !important;
    }
    
    /* Animations off */
    * {
        animation: none !important;
        transition: none !important;
    }
    
    /* Ensure black text */
    body,
    body * {
        color: black !important;
    }
    
    /* Exception for already styled elements */
    .preserve-color {
        color: inherit !important;
    }
}

/* Print-specific utilities - Can be used in HTML */
.print-only {
    display: none;
}

@media print {
    .print-only {
        display: block !important;
    }
    
    .screen-only {
        display: none !important;
    }
}
