/* ============================================================
   Wasfa Enhancements v1.0
   تحسينات بصرية + animations + print
   ============================================================ */

/* ============================================================
   1. Smooth Page Transitions
   ============================================================ */
* {
    -webkit-tap-highlight-color: transparent;
}

a, button, .wasfa-btn, .filter-pill, .type-option {
    -webkit-tap-highlight-color: rgba(28, 176, 246, 0.1);
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Focus styles are consolidated into the single global :focus-visible rule in
   the Accessibility section below (one 3px outline, no radius mutation). */

/* ============================================================
   2. Enhanced Skeleton Loaders
   ============================================================ */
.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--inner-radius);
    padding: 20px;
    margin-bottom: 12px;
}

.skeleton-line {
    background: linear-gradient(
        90deg,
        var(--bg-info) 0%,
        var(--border-default) 50%,
        var(--bg-info) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 6px;
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-line.lg { height: 22px; }
.skeleton-line.sm { height: 10px; }
.skeleton-line.circle {
    border-radius: 50%;
    width: 48px;
    height: 48px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   3. Hover Effects for Cards
   ============================================================ */
.wasfa-card {
    will-change: transform;
}

.med-pill {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.med-pill:hover {
    transform: translateY(-2px);
    border-color: var(--wasfa-blue);
}

.stat-card {
    cursor: default;
    will-change: transform;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(-5deg);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stat-card .stat-icon {
    transition: transform 0.3s ease;
}

/* ============================================================
   4. Pulse Notification Badge
   ============================================================ */
.notification-badge {
    position: relative;
    display: inline-flex;
}

.notification-badge[data-count]:not([data-count="0"])::after {
    content: attr(data-count);
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--wasfa-red);
    color: white;
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================================
   5. Smooth Sidebar Slide Animations
   ============================================================ */
.sidebar-nav a {
    position: relative;
    overflow: hidden;
}

.sidebar-nav a::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--wasfa-blue);
    transform: scaleY(0);
    transition: transform 0.2s ease;
    border-radius: 4px 0 0 4px;
}

.sidebar-nav a.active::before {
    transform: scaleY(1);
}

/* ============================================================
   6. Loading Bar (top of page)
   ============================================================ */
.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--wasfa-blue), var(--wasfa-purple));
    z-index: 99999;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.loading-bar.active {
    animation: loading-bar-progress 2s ease-in-out infinite;
}

@keyframes loading-bar-progress {
    0% { transform: scaleX(0); transform-origin: left; }
    50% { transform: scaleX(1); transform-origin: left; }
    50.01% { transform-origin: right; }
    100% { transform: scaleX(0); transform-origin: right; }
}

/* ============================================================
   7. Card Reveal Animation
   ============================================================ */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    animation: card-reveal 0.5s ease-out forwards;
}

.reveal:nth-child(1) { animation-delay: 0.05s; }
.reveal:nth-child(2) { animation-delay: 0.1s; }
.reveal:nth-child(3) { animation-delay: 0.15s; }
.reveal:nth-child(4) { animation-delay: 0.2s; }
.reveal:nth-child(5) { animation-delay: 0.25s; }
.reveal:nth-child(6) { animation-delay: 0.3s; }

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

/* ============================================================
   8. Form Floating Labels
   ============================================================ */
.floating-label {
    position: relative;
    margin-bottom: 16px;
}

.floating-label input,
.floating-label textarea,
.floating-label select {
    width: 100%;
    padding: 18px 14px 6px;
}

.floating-label label {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    pointer-events: none;
    background: transparent;
    padding: 0 4px;
}

.floating-label input:focus + label,
.floating-label input:not(:placeholder-shown) + label,
.floating-label textarea:focus + label,
.floating-label textarea:not(:placeholder-shown) + label {
    top: 4px;
    transform: translateY(0);
    font-size: 11px;
    color: var(--wasfa-blue);
    font-weight: var(--font-weight-bold);
}

/* ============================================================
   9. Tooltip
   ============================================================ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--text-dark);
    color: var(--bg-card);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ============================================================
   10. Empty State Illustrations
   ============================================================ */
.empty-state {
    animation: card-reveal 0.5s ease-out;
}

.empty-state-icon {
    background: var(--bg-info) !important;
    border: 3px dashed var(--border-default);
    animation: float-icon 3s ease-in-out infinite;
}

@keyframes float-icon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ============================================================
   11. Print
   ============================================================
   print.css (media="print") is the SINGLE owner of all print styling —
   page setup, chrome hiding, the B&W palette and the .print-prescription
   template structure all live there. Keeping a second @media print block
   here made the two fight (double @page margins, half-blue/half-black
   prescriptions). Only the screen-side rule remains: */

/* Hide print template normally */
.print-prescription {
    display: none;
}

/* ============================================================
   12. Better Mobile Bottom Bar (Optional)
   ============================================================ */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 3px solid var(--border-default);
    padding: 8px;
    z-index: 90;
    justify-content: space-around;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

@media (max-width: 600px) {
    .mobile-bottom-bar.enabled {
        display: flex;
    }
    
    .mobile-bottom-bar.enabled ~ .main-content,
    .mobile-bottom-bar.enabled ~ .app-shell .main-content {
        padding-bottom: 80px;
    }
}

.mobile-bottom-bar a {
    flex: 1;
    text-align: center;
    padding: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border-radius: 8px;
    transition: all 0.2s;
}

.mobile-bottom-bar a.active {
    color: var(--wasfa-blue);
}

.mobile-bottom-bar a .icon {
    font-size: 22px;
}

/* ============================================================
   13. PWA Install Banner
   ============================================================ */
.pwa-install-banner {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    background: var(--wasfa-blue);
    /* Dark ink: white on brand blue is 2.44:1 (fails WCAG AA). */
    color: #131F24;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(28, 176, 246, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    max-width: 500px;
    margin: 0 auto;
    animation: slide-in-up 0.4s ease-out;
}

.pwa-install-banner .pwa-icon {
    font-size: 28px;
}

.pwa-install-banner .pwa-content {
    flex: 1;
}

.pwa-install-banner .pwa-title {
    font-weight: var(--font-weight-bold);
    font-size: 15px;
    margin: 0;
}

.pwa-install-banner .pwa-desc {
    font-size: 12px;
    opacity: 0.9;
    margin: 2px 0 0;
}

.pwa-install-banner button {
    background: white;
    color: var(--wasfa-blue-fg);
    border: none;
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    font-size: 13px;
}

.pwa-install-banner .pwa-close {
    background: rgba(255,255,255,0.35);
    color: #131F24;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   14. Drug Interaction Card (Critical UI)
   ============================================================ */
.interaction-card {
    border: 1px solid;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.interaction-card::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
}

.interaction-card.severity-critical {
    border-color: var(--wasfa-red);
    box-shadow: 0 4px 0 var(--wasfa-red-shadow);
}

.interaction-card.severity-critical::before {
    background: var(--wasfa-red);
}

.interaction-card.severity-warning {
    border-color: var(--wasfa-orange);
    box-shadow: 0 4px 0 var(--wasfa-orange-shadow);
}

.interaction-card.severity-warning::before {
    background: var(--wasfa-orange);
}

.interaction-card .interaction-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-weight: var(--font-weight-bold);
    font-size: 15px;
}

/* ============================================================
   15. Reduced Motion Support
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   Offline banner (Prompt 20)
   ============================================================
   Mounted by Utils.mountOfflineBanner() and toggled .show by
   online/offline events. It is fixed at the very top and overlays the sticky
   top-nav; because it is pure status text (role=status, no interactive
   children) it sets pointer-events:none so taps pass straight through to the
   menu-toggle / nav links beneath it. */
.offline-banner {
    position: fixed;
    top: 0;
    inset-inline: 0;          /* RTL-correct: stretches start→end */
    z-index: 9999;
    pointer-events: none;     /* status text only — never intercept taps */
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--wasfa-orange, #FF9600);
    /* Dark ink: white on brand orange is 2.18:1 (fails WCAG AA). */
    color: #131F24;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-size: 14px;
}
.offline-banner.show { display: flex; }

/* ============================================================
   Accessibility — focus indicator (Prompt 20)
   ============================================================ */
/* Browsers may strip default focus on the Wasfa 3D buttons because of the
   solid box-shadow. Force a high-contrast outline that survives RTL and
   dark mode. */
:focus-visible {
    outline: 3px solid var(--wasfa-blue, #1CB0F6);
    outline-offset: 2px;
    /* No border-radius here: the outline follows the element's own radius, so
       overriding it would snap circular/pill controls to a rounded square only
       while focused — a distracting geometry change for keyboard users. */
}
.wasfa-btn:focus-visible,
.wasfa-btn-blue:focus-visible,
.wasfa-btn-green:focus-visible,
.wasfa-btn-orange:focus-visible,
.wasfa-btn-red:focus-visible,
.wasfa-btn-purple:focus-visible,
.wasfa-btn-gray:focus-visible {
    outline-offset: 4px;
}
/* Screen-reader-only utility class used by aria-label-free buttons that
   carry visible icons. */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

