/* Animated Loading Indicators for Medication Tracking */

/* Pill-shaped loading indicator */
.pill-loader {
    display: inline-block;
    width: 60px;
    height: 30px;
    border-radius: 15px;
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    position: relative;
    overflow: hidden;
}

.pill-loader::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: pill-shine 1.5s infinite;
}

@keyframes pill-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Heartbeat loading for vital signs */
.heartbeat-loader {
    display: inline-block;
    width: 40px;
    height: 40px;
    position: relative;
}

.heartbeat-loader::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: #ff6b35;
    border-radius: 50%;
    animation: heartbeat 1.2s infinite ease-in-out;
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Medication bottle loading */
.bottle-loader {
    display: inline-block;
    width: 24px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px 4px 8px 8px;
    position: relative;
    animation: bottle-shake 0.8s infinite ease-in-out;
}

.bottle-loader::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 8px;
    background: #4a5568;
    border-radius: 4px 4px 0 0;
}

.bottle-loader::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    animation: pill-count 1.5s infinite;
}

@keyframes bottle-shake {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

@keyframes pill-count {
    0%, 100% { height: 8px; opacity: 0.3; }
    50% { height: 12px; opacity: 0.6; }
}

/* Compliance meter loading */
.compliance-loader {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #ff6b35;
    border-radius: 50%;
    animation: compliance-spin 1s linear infinite;
    position: relative;
}

.compliance-loader::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    animation: compliance-pulse 1.5s infinite ease-in-out;
}

@keyframes compliance-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes compliance-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(0.8); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* Device status loading */
.device-loader {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.device-loader .dot {
    width: 8px;
    height: 8px;
    background: #ff6b35;
    border-radius: 50%;
    animation: device-blink 1.4s infinite ease-in-out both;
}

.device-loader .dot:nth-child(1) { animation-delay: -0.32s; }
.device-loader .dot:nth-child(2) { animation-delay: -0.16s; }
.device-loader .dot:nth-child(3) { animation-delay: 0s; }

@keyframes device-blink {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Patient data loading skeleton */
.skeleton-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text.large { height: 24px; }
.skeleton-text.small { height: 12px; }
.skeleton-text.wide { width: 80%; }
.skeleton-text.medium { width: 60%; }
.skeleton-text.narrow { width: 40%; }

/* Alert loading indicator */
.alert-loader {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid transparent;
    border-top: 3px solid #dc3545;
    border-radius: 50%;
    animation: alert-spin 1s linear infinite;
    position: relative;
}

.alert-loader::before {
    content: '!';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    font-size: 12px;
    color: #dc3545;
    animation: alert-pulse 0.8s infinite;
}

@keyframes alert-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes alert-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Loading overlay for sections */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* QR Code generation loading */
.qr-loader {
    display: inline-block;
    width: 40px;
    height: 40px;
    position: relative;
}

.qr-loader::before,
.qr-loader::after {
    content: '';
    position: absolute;
    border: 2px solid #ff6b35;
    border-radius: 4px;
}

.qr-loader::before {
    width: 100%;
    height: 100%;
    animation: qr-outer 2s linear infinite;
}

.qr-loader::after {
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    transform: translate(-50%, -50%);
    animation: qr-inner 2s linear infinite reverse;
}

@keyframes qr-outer {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes qr-inner {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(-360deg); }
}

/* Report generation loading */
.report-loader {
    display: inline-block;
    width: 32px;
    height: 40px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.report-loader::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    animation: report-fill 2s ease-in-out infinite;
}

.report-loader::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 6px;
    right: 6px;
    height: 2px;
    background: #dee2e6;
    box-shadow: 0 6px 0 #dee2e6, 0 12px 0 #dee2e6;
}

@keyframes report-fill {
    0% { height: 0%; }
    50% { height: 100%; }
    100% { height: 0%; }
}

/* Utility classes */
.loading-text {
    color: #6c757d;
    font-size: 0.9rem;
    margin-left: 8px;
}

.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .loading-container {
        padding: 1rem;
    }
    
    .loading-text {
        font-size: 0.8rem;
    }
}