/**
 * Enhanced Stretcher Management Animations & Responsive CSS
 * =======================================================
 * Beautiful animations, micro-interactions, and responsive design
 */

/* ===================================================================
   🎨 Advanced CSS Custom Properties & Variables
   =================================================================== */

:root {
    /* Enhanced Color Palette */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    /* Success Colors */
    --success-50: #ecfdf5;
    --success-100: #d1fae5;
    --success-200: #a7f3d0;
    --success-300: #6ee7b7;
    --success-400: #34d399;
    --success-500: #10b981;
    --success-600: #059669;
    --success-700: #047857;
    --success-800: #065f46;
    --success-900: #064e3b;

    /* Warning Colors */
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-200: #fde68a;
    --warning-300: #fcd34d;
    --warning-400: #fbbf24;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --warning-700: #b45309;
    --warning-800: #92400e;
    --warning-900: #78350f;

    /* Danger Colors */
    --danger-50: #fef2f2;
    --danger-100: #fee2e2;
    --danger-200: #fecaca;
    --danger-300: #fca5a5;
    --danger-400: #f87171;
    --danger-500: #ef4444;
    --danger-600: #dc2626;
    --danger-700: #b91c1c;
    --danger-800: #991b1b;
    --danger-900: #7f1d1d;

    /* Advanced Animations */
    --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-back: cubic-bezier(0.68, -0.6, 0.32, 1.6);
    --ease-anticipate: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-overshoot: cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Z-index Scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;

    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 6rem;
    --space-5xl: 8rem;
}

/* ===================================================================
   🚀 Advanced Keyframe Animations
   =================================================================== */

@keyframes glow {
    0%, 100% {
        box-shadow: 
            0 0 5px currentColor,
            0 0 10px currentColor,
            0 0 15px currentColor;
    }
    50% {
        box-shadow: 
            0 0 10px currentColor,
            0 0 20px currentColor,
            0 0 30px currentColor;
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes scale-in {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slide-up {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes heartbeat {
    0%, 28%, 70% {
        transform: scale(1);
    }
    14%, 42% {
        transform: scale(1.3);
    }
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes wobble {
    0% { transform: translateX(0%); }
    15% { transform: translateX(-25%) rotate(-5deg); }
    30% { transform: translateX(20%) rotate(3deg); }
    45% { transform: translateX(-15%) rotate(-3deg); }
    60% { transform: translateX(10%) rotate(2deg); }
    75% { transform: translateX(-5%) rotate(-1deg); }
    100% { transform: translateX(0%); }
}

/* ===================================================================
   🎪 Enhanced UI Component Animations
   =================================================================== */

/* Enhanced Button Animations */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--ease-anticipate);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:active {
    transform: scale(0.98);
}

/* Enhanced Card Animations */
.card,
.stretcher-card {
    transition: all 0.4s var(--ease-back);
}

.card:hover,
.stretcher-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

.card::after,
.stretcher-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: left 0.5s;
}

.card:hover::after,
.stretcher-card:hover::after {
    left: 100%;
}

/* Enhanced Status Badge Animations */
.status-badge {
    position: relative;
    transition: all 0.3s var(--ease-elastic);
}

.status-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    border-radius: inherit;
    filter: blur(4px);
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s;
}

.status-badge:hover::before {
    opacity: 0.7;
}

.status-badge:hover {
    transform: scale(1.05);
}

/* Priority Indicator Animations */
.priority-indicator.urgent {
    animation: 
        heartbeat 2s ease-in-out infinite,
        glow 2s ease-in-out infinite alternate;
}

/* Enhanced Loading Animations */
.loading-shimmer {
    background: linear-gradient(
        110deg,
        #e2e8f0 8%,
        #f1f5f9 18%,
        #e2e8f0 33%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
}

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
    border-radius: 4px;
}

/* Enhanced Notification Animations */
.enhanced-toast-popup {
    border-radius: var(--radius-xl) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.urgent-request-modal {
    border-radius: var(--radius-2xl) !important;
    overflow: hidden !important;
}

.urgent-request-modal .urgent-request-content {
    position: relative;
}

.urgency-indicator {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
}

.pulse-ring {
    position: absolute;
    border: 3px solid var(--danger-500);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: ripple 2s linear infinite;
}

.pulse-ring.delay-1 {
    animation-delay: 0.7s;
}

.pulse-ring.delay-2 {
    animation-delay: 1.4s;
}

/* ===================================================================
   🎯 Enhanced Stretcher Card Styles
   =================================================================== */

.stretcher-card-wrapper {
    position: relative;
}

.stretcher-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all 0.4s var(--ease-back);
    position: relative;
}

/* Priority-based styling */
.stretcher-card.priority-critical {
    border-left: 6px solid var(--danger-500);
    box-shadow: 
        0 4px 6px rgba(239, 68, 68, 0.1),
        0 0 20px rgba(239, 68, 68, 0.05);
}

.stretcher-card.priority-critical::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(239, 68, 68, 0.02) 0%,
        transparent 50%
    );
    pointer-events: none;
}

.stretcher-card.urgent-request {
    animation: glow 3s ease-in-out infinite alternate;
}

.stretcher-card.urgent-request::after {
    content: '🚨';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem;
    z-index: 10;
    animation: bounce 2s infinite;
}

/* Enhanced Patient Info Grid */
.patient-info-grid {
    display: grid;
    gap: var(--space-md);
}

.info-item {
    background: var(--primary-50);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border-left: 4px solid var(--primary-500);
    transition: all 0.3s var(--ease-anticipate);
}

.info-item:hover {
    background: var(--primary-100);
    transform: translateX(4px);
    border-left-width: 6px;
}

.info-item.emergency {
    background: var(--danger-50);
    border-left-color: var(--danger-500);
}

.info-item.emergency:hover {
    background: var(--danger-100);
}

.info-item.note {
    background: var(--warning-50);
    border-left-color: var(--warning-500);
}

.info-item.note:hover {
    background: var(--warning-100);
}

/* ===================================================================
   🎨 Enhanced Statistics Section
   =================================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-xl);
    margin-bottom: var(--space-3xl);
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    position: relative;
    overflow: hidden;
    transition: all 0.4s var(--ease-back);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
}

.stat-card.main-stat::before {
    height: 6px;
    background: var(--gradient-primary);
}

.stat-card.success-stat::before {
    background: var(--gradient-success);
}

.stat-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: var(--shadow-xl);
}

.stat-card:hover .stat-icon {
    animation: float 2s ease-in-out infinite;
}

.stat-number {
    font-size: 3.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-sm);
}

.success-stat .stat-number {
    background: var(--gradient-success);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===================================================================
   🔧 Enhanced Form Controls
   =================================================================== */

.form-control,
.form-select {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    font-size: 0.95rem;
    transition: all 0.3s var(--ease-anticipate);
    background: var(--card-bg);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-500);
    box-shadow: 
        0 0 0 3px rgba(59, 130, 246, 0.1),
        var(--shadow-md);
    transform: translateY(-2px);
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: 0.375rem;
    transition: all 0.3s var(--ease-back);
}

.form-check-input:checked {
    background-color: var(--primary-500);
    border-color: var(--primary-500);
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* ===================================================================
   📱 Enhanced Responsive Design
   =================================================================== */

/* Large Devices (Desktops) */
@media (min-width: 1200px) {
    .stretcher-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .hero-title {
        font-size: 4rem;
    }
}

/* Medium Devices (Tablets) */
@media (max-width: 1199.98px) and (min-width: 768px) {
    .stretcher-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-lg);
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .stat-number {
        font-size: 3rem;
    }
}

/* Small Devices (Landscape Phones) */
@media (max-width: 767.98px) and (min-width: 576px) {
    .stretcher-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .stat-card {
        padding: var(--space-lg);
    }
    
    .stretcher-card-body {
        padding: var(--space-lg);
    }
    
    .filter-controls {
        flex-direction: column;
        gap: var(--space-md);
    }
}

/* Extra Small Devices (Portrait Phones) */
@media (max-width: 575.98px) {
    :root {
        --space-xs: 0.125rem;
        --space-sm: 0.25rem;
        --space-md: 0.5rem;
        --space-lg: 0.75rem;
        --space-xl: 1rem;
        --space-2xl: 1.5rem;
    }
    
    .hero-section {
        padding: var(--space-2xl) 0 var(--space-xl);
    }
    
    .hero-title {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .realtime-badge {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .stat-card {
        padding: var(--space-lg);
        text-align: center;
    }
    
    .stat-number {
        font-size: 2.5rem;
    }
    
    .stretcher-card-header,
    .stretcher-card-body,
    .stretcher-card-footer {
        padding: var(--space-lg);
    }
    
    .patient-name {
        font-size: 1.1rem;
    }
    
    .info-item {
        padding: var(--space-sm);
        font-size: 0.85rem;
    }
    
    .btn-action {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .status-badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .connection-status-bar {
        padding: var(--space-sm) 0;
    }
    
    .filter-card {
        margin: var(--space-md);
    }
    
    .empty-state {
        padding: var(--space-2xl) var(--space-md);
    }
    
    .empty-state-icon {
        font-size: 3rem;
    }
    
    .empty-state-title {
        font-size: 1.5rem;
    }
}

/* ===================================================================
   🌙 Dark Mode Support
   =================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --card-bg: #1f2937;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-muted: #9ca3af;
        --border-color: #374151;
        --light-bg: #111827;
    }
    
    .stretcher-card,
    .stat-card,
    .filter-card {
        background: var(--card-bg);
        border-color: var(--border-color);
    }
    
    .info-item {
        background: rgba(55, 65, 81, 0.5);
    }
    
    .info-item:hover {
        background: rgba(255, 255, 255, 0.8);
    }
}

/* ===================================================================
   ♿ Enhanced Accessibility
   =================================================================== */

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .stretcher-card,
    .stat-card {
        border-width: 2px;
        border-color: currentColor;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .status-badge {
        border: 1px solid currentColor;
    }
}

/* Reduced Motion */
@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;
    }
    
    .stretcher-card:hover,
    .stat-card:hover,
    .btn:hover {
        transform: none;
    }
}

/* Focus Indicators */
.btn:focus,
.form-control:focus,
.form-check-input:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===================================================================
   🎪 Utility Classes
   =================================================================== */

/* Animation Utilities */
.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite alternate;
}

.animate-shimmer {
    animation: shimmer 2s linear infinite;
}

.animate-heartbeat {
    animation: heartbeat 2s ease-in-out infinite;
}

/* Transition Utilities */
.transition-all {
    transition: all 0.3s var(--ease-anticipate);
}

.transition-colors {
    transition: color 0.3s, background-color 0.3s, border-color 0.3s;
}

.transition-transform {
    transition: transform 0.3s var(--ease-back);
}

/* Transform Utilities */
.hover-lift:hover {
    transform: translateY(-4px);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* Glass Effect */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Gradient Text */
.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===================================================================
   📊 Print Styles
   =================================================================== */

@media print {
    * {
        color: black !important;
        background: white !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    .btn,
    .connection-status-bar,
    .filter-section,
    .enhanced-notification {
        display: none !important;
    }
    
    .stretcher-card {
        border: 2px solid black !important;
        break-inside: avoid;
        margin-bottom: 1rem;
        page-break-inside: avoid;
    }
    
    .stretcher-card::before,
    .stretcher-card::after {
        display: none;
    }
    
    .hero-section {
        background: white !important;
        color: black !important;
    }
    
    .patient-name {
        font-weight: bold;
    }
    
    .info-label {
        font-weight: bold;
    }
    
    .urgent-text {
        color: black !important;
        font-weight: bold;
    }
    
    .urgent-text::after {
        content: ' (URGENT)';
    }
}

/* ===================================================================
   🎯 Performance Optimizations
   =================================================================== */

/* GPU Acceleration for Animations */
.stretcher-card,
.stat-card,
.btn {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Optimized Shadows */
.shadow-optimized {
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.12),
        0 1px 2px rgba(0, 0, 0, 0.24);
}

/* Image Optimization */
img {
    max-width: 100%;
    height: auto;
    image-rendering: optimizeQuality;
}

/* Font Display Optimization */
@font-face {
    font-family: 'Kanit';
    font-display: swap;
}
