/* ==========================================================================
   Vetmivo Phase 5: Laboratory & Diagnostic Module Styles
   ========================================================================== */

/* 1. Laboratory Dashboard Metric & Alert Cards */
.lab-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.lab-metric-card {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lab-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.lab-metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lab-metric-icon.blue { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.lab-metric-icon.amber { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.lab-metric-icon.purple { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }
.lab-metric-icon.red { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.lab-metric-icon.green { background: rgba(16, 185, 129, 0.12); color: #059669; }

.lab-metric-info {
    display: flex;
    flex-direction: column;
}

.lab-metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    line-height: 1.2;
}

.lab-metric-label {
    font-size: 13px;
    color: var(--text-muted, #64748b);
    font-weight: 500;
}

/* 2. Clinical Result Flags */
.flag-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.flag-normal {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.flag-low {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.flag-high {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.flag-critical {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #f87171;
    animation: pulse-critical 2s infinite ease-in-out;
}

.flag-abnormal {
    background: #fdf2f8;
    color: #9d174d;
    border: 1px solid #fbcfe8;
}

@keyframes pulse-critical {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* 3. Clinical Result Workspace & Grid */
.lab-result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.lab-result-table th {
    background: var(--bg-surface, #f8fafc);
    color: var(--text-muted, #64748b);
    font-weight: 600;
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lab-result-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    vertical-align: middle;
}

.lab-result-table tr:hover {
    background: #f8fafc;
}

.lab-result-table tr.row-abnormal {
    background: rgba(254, 242, 242, 0.4);
}

.lab-result-table tr.row-critical {
    background: rgba(254, 226, 226, 0.6);
}

.lab-value-input {
    width: 110px;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
    background: #ffffff;
    transition: all 0.15s ease;
}

.lab-value-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    outline: none;
}

/* 4. Test & Panel Selector Cards in New Order Builder */
.panel-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.panel-card-select {
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    background: #ffffff;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    user-select: none;
}

.panel-card-select:hover {
    border-color: #93c5fd;
    background: #f8fafc;
}

.panel-card-select.selected {
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.04);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* 5. Slide-Over Analyte Trend Drawer */
.trend-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

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

.trend-drawer {
    position: fixed;
    top: 0;
    right: -520px;
    width: 520px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.trend-drawer.active {
    right: 0;
}

.trend-drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.trend-drawer-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.trend-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.trend-stat-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.trend-stat-val {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.trend-stat-lbl {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

/* 6. A4 Printable Laboratory Report Styles */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 12pt;
    }

    .app-sidebar,
    .app-topbar,
    .btn,
    .no-print {
        display: none !important;
    }

    .app-main, .app-content {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    .lab-print-page {
        padding: 20mm;
        width: 100%;
        box-sizing: border-box;
    }

    .lab-print-header {
        border-bottom: 2px solid #000000;
        padding-bottom: 15px;
        margin-bottom: 20px;
    }

    .lab-result-table th, .lab-result-table td {
        border-color: #cccccc !important;
        padding: 6px 8px !important;
    }
}
