/**
 * Dr. Hiwa Clinic & Laboratory Design System CSS
 * Matching Approved Figma Specifications
 */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --canvas: #F3F6F8;
    --surface: #FFFFFF;
    --navy: #102B40;
    --navy-light: #1A3B54;
    --teal: #087F83;
    --teal-hover: #066568;
    --teal-subtle: #E6F3F3;
    --border: #DCE4EA;
    --border-subtle: #E8EEF3;
    --text: #193347;
    --text-muted: #5C6F7E;
    --success: #24724F;
    --success-bg: #EAF4EE;
    --pending: #95620C;
    --pending-bg: #FEF6E7;
    --critical: #B3333E;
    --critical-bg: #FBEBED;
    --focus-ring: #136EB5;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --shadow-sm: 0 1px 2px 0 rgba(16, 43, 64, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(16, 43, 64, 0.07), 0 2px 4px -2px rgba(16, 43, 64, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(16, 43, 64, 0.08), 0 4px 6px -4px rgba(16, 43, 64, 0.04);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--canvas);
    color: var(--text);
    line-height: 1.55;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* LTR Islands for Phone numbers, test codes, and identifiers */
.ltr-island, [dir="ltr"] {
    direction: ltr !important;
    text-align: left !important;
    display: inline-block;
}

/* Layout System */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--navy);
    color: #FFFFFF;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease;
    z-index: 40;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.page-body {
    padding: 24px;
    flex: 1;
}

/* Navigation items */
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #A0B3C2;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    margin: 2px 12px;
    transition: all 0.15s ease;
}

.nav-link:hover {
    color: #FFFFFF;
    background-color: var(--navy-light);
}

.nav-link.active {
    color: #FFFFFF;
    background-color: var(--teal);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(8, 127, 131, 0.4);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary:hover {
    background-color: var(--teal-hover);
    box-shadow: 0 2px 6px rgba(8, 127, 131, 0.25);
}

.btn-secondary {
    background-color: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background-color: #F8FAFC;
    border-color: #CBD5E1;
}

.btn-danger {
    background-color: var(--critical);
    color: #FFFFFF;
}

.btn-danger:hover {
    background-color: #991B1B;
}

.btn-success {
    background-color: var(--success);
    color: #FFFFFF;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-body {
    padding: 20px;
}

/* Inputs & Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(8, 127, 131, 0.15);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

.badge-success {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(36, 114, 79, 0.2);
}

.badge-pending {
    background-color: var(--pending-bg);
    color: var(--pending);
    border: 1px solid rgba(149, 98, 12, 0.2);
}

.badge-critical {
    background-color: var(--critical-bg);
    color: var(--critical);
    border: 1px solid rgba(179, 51, 62, 0.2);
}

.badge-teal {
    background-color: var(--teal-subtle);
    color: var(--teal);
    border: 1px solid rgba(8, 127, 131, 0.2);
}

.badge-navy {
    background-color: #EBF1F5;
    color: var(--navy);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

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

.table th {
    background-color: #F8FAFC;
    color: var(--text-muted);
    font-weight: 700;
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

[dir="ltr"] .table th {
    text-align: left;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.table tr:hover td {
    background-color: #F8FAFC;
}

/* Stats Metric Cards */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    font-family: inherit;
}

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

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(36, 114, 79, 0.2);
}

.alert-error {
    background-color: var(--critical-bg);
    color: var(--critical);
    border: 1px solid rgba(179, 51, 62, 0.2);
}

.alert-warning {
    background-color: var(--pending-bg);
    color: var(--pending);
    border: 1px solid rgba(149, 98, 12, 0.2);
}

.alert-info {
    background-color: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
}

/* Responsive grid helpers */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

@media (max-width: 1024px) {
    .grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; }
    .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
    .page-body { padding: 16px; }
}

/* Print styles for Laboratory Reports */
@media print {
    .no-print, .sidebar, .topbar { display: none !important; }
    body, .main-content, .page-body { background: white !important; padding: 0 !important; }
    .card { border: none !important; box-shadow: none !important; }
}

/* Offline & Network Status Indicator Pill */
.network-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    border: 1px solid transparent;
}

.network-pill.online {
    background-color: var(--success-bg);
    color: var(--success);
    border-color: rgba(36, 114, 79, 0.25);
}

.network-pill.offline {
    background-color: #FEF2F2;
    color: #DC2626;
    border-color: rgba(220, 38, 38, 0.25);
}

.network-pill.pending {
    background-color: #FEF3C7;
    color: #B45309;
    border-color: rgba(180, 83, 9, 0.25);
}

.network-pill.syncing {
    background-color: #EFF6FF;
    color: #1D4ED8;
    border-color: rgba(29, 78, 216, 0.25);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.pulse-dot.online {
    background-color: var(--success);
    box-shadow: 0 0 0 0 rgba(36, 114, 79, 0.6);
    animation: pulse-green 2s infinite;
}

.pulse-dot.offline {
    background-color: #DC2626;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
    animation: pulse-red 1.5s infinite;
}

.pulse-dot.pending {
    background-color: #D97706;
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.6);
    animation: pulse-amber 1.8s infinite;
}

.pulse-dot.syncing {
    background-color: #2563EB;
    animation: spin-pulse 1s linear infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(36, 114, 79, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(36, 114, 79, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(36, 114, 79, 0); }
}

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

@keyframes pulse-amber {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(217, 119, 6, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}

@keyframes spin-pulse {
    0% { transform: scale(0.85); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.85); opacity: 0.7; }
}

.queue-badge {
    background-color: #DC2626;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    margin-right: 2px;
    line-height: 1.4;
}

.network-pill.pending .queue-badge {
    background-color: #D97706;
}

.btn-sync-now {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    transition: transform 0.2s ease;
}

.btn-sync-now:hover {
    transform: rotate(180deg);
}

/* ==========================================================================
   Real-Time Notifications & Bell Chime Animations
   ========================================================================== */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-15px) scale(0.95);
    }
}

@keyframes toastCountdown {
    from { width: 100%; }
    to { width: 0%; }
}

@keyframes rowFlashGlow {
    0% {
        background-color: rgba(8, 127, 131, 0.25);
    }
    100% {
        background-color: transparent;
    }
}

.realtime-highlight-row {
    animation: rowFlashGlow 2.5s ease-out forwards;
}

#btn-sound-toggle.sound-muted {
    opacity: 0.75;
}

#btn-sound-toggle:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

@media (max-width: 640px) {
    .hide-mobile {
        display: none !important;
    }
}


