/**
 * Offline UI Styles for MediSpharm PWA
 * Enhanced visual feedback for offline functionality
 */

/* Offline Indicators */
.offline-indicator {
    display: none;
    background: linear-gradient(45deg, #ffc107, #fd7e14);
    color: white;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

.offline-mode .offline-indicator {
    display: inline-block;
}

/* Offline Badge */
#offline-badge {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 9999;
    background: linear-gradient(45deg, #ff6b6b, #ffa726);
    color: white;
    padding: 8px 15px;
    border-radius: 25px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideInLeft 0.5s ease-out;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* Floating Action Button for Offline Visit Creation */
.fab-create-visit {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: linear-gradient(45deg, #4CAF50, #45a049) !important;
    border: none !important;
    color: white !important;
    font-size: 24px !important;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4) !important;
    z-index: 1050 !important;
    transition: all 0.3s ease !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
}

.fab-create-visit:hover {
    background: linear-gradient(45deg, #45a049, #4CAF50) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 6px 25px rgba(76, 175, 80, 0.6) !important;
}

.offline-mode .fab-create-visit {
    display: flex !important;
    animation: bounceIn 0.5s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Offline Form Overlays */
.offline-form-overlay {
    background: rgba(255, 193, 7, 0.1);
    border: 2px dashed #ffc107;
    border-radius: 8px;
    position: relative;
    padding: 20px;
}

.offline-form-overlay::before {
    content: "OFFLINE MODE";
    position: absolute;
    top: -12px;
    left: 20px;
    background: #ffc107;
    color: #212529;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* Visit Action Menu */
.visit-action-menu {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    overflow: hidden;
    animation: fadeInScale 0.2s ease-out;
}

.visit-action-menu .menu-item:hover {
    background: #f8f9fa;
}

.visit-action-menu .menu-item:active {
    background: #e9ecef;
}

@keyframes fadeInScale {
    from { 
        opacity: 0;
        transform: scale(0.9);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

/* Offline Visit Cards */
.visit-card.offline-created {
    border-left: 4px solid #17a2b8;
    background: linear-gradient(to right, rgba(23, 162, 184, 0.05), transparent);
}

.visit-card.offline-updated {
    border-left: 4px solid #ffc107;
    background: linear-gradient(to right, rgba(255, 193, 7, 0.05), transparent);
}

.visit-card.pending-sync {
    position: relative;
    opacity: 0.9;
}

.visit-card.pending-sync::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 20px 20px 0;
    border-color: transparent #ff6b6b transparent transparent;
}

.visit-card.pending-sync::before {
    content: '!';
    position: absolute;
    top: 2px;
    right: 4px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}

/* Sync Indicators */
#sync-indicator {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 9999;
    background: linear-gradient(45deg, #17a2b8, #20c997);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(23, 162, 184, 0.3);
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.sync-progress {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.sync-progress-bar {
    height: 100%;
    background: white;
    border-radius: 2px;
    animation: progressFlow 2s infinite;
}

@keyframes progressFlow {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Offline Calendar Enhancements */
.fc-toolbar.offline-mode {
    border: 2px solid #ffc107;
    border-radius: 8px;
    background: rgba(255, 193, 7, 0.1);
    padding: 10px;
}

.fc-event.offline-event {
    background: linear-gradient(45deg, #17a2b8, #20c997) !important;
    border: none !important;
    position: relative;
}

.fc-event.offline-event::after {
    content: '📱';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
}

.fc-event.pending-sync {
    background: linear-gradient(45deg, #ffc107, #fd7e14) !important;
    animation: pulse 2s infinite;
}

/* Offline Toolbar */
.offline-toolbar {
    background: linear-gradient(to right, #f8f9fa, #e9ecef);
    border-bottom: 2px solid #dee2e6;
    padding: 12px 16px;
}

.offline-toolbar .btn {
    margin-right: 8px;
    font-size: 13px;
    padding: 6px 12px;
}

.offline-status {
    margin-left: auto;
    font-weight: 500;
}

/* Notification Enhancements */
.alert.offline-notification {
    border-left: 5px solid #17a2b8;
    background: linear-gradient(to right, rgba(23, 162, 184, 0.1), rgba(23, 162, 184, 0.05));
}

.alert.offline-notification .fas {
    color: #17a2b8;
}

/* Modal Enhancements for Offline */
.modal.offline-modal .modal-header {
    background: linear-gradient(45deg, #17a2b8, #20c997);
    color: white;
    border-bottom: none;
}

.modal.offline-modal .modal-header .btn-close {
    filter: invert(1);
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .fab-create-visit {
        bottom: 80px !important; /* Above mobile navigation if present */
    }
    
    #offline-badge {
        left: 50%;
        transform: translateX(-50%);
        top: 5px;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    #sync-indicator {
        right: 10px;
        left: 10px;
        text-align: center;
    }
    
    .visit-action-menu {
        min-width: 160px;
        font-size: 14px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .visit-action-menu {
        background: #2d3748;
        border-color: #4a5568;
        color: white;
    }
    
    .visit-action-menu .menu-item:hover {
        background: #4a5568;
    }
    
    .offline-form-overlay {
        border-color: #ffd700;
        background: rgba(255, 215, 0, 0.1);
    }
    
    .offline-toolbar {
        background: linear-gradient(to right, #2d3748, #4a5568);
        color: white;
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #17a2b8;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

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

/* Success States */
.success-indicator {
    color: #28a745;
    animation: checkmark 0.5s ease-in-out;
}

@keyframes checkmark {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}