/* ========================================
   Sync Status Component Styling
   Enhanced sync and connection status indicators
   ======================================== */

.sync-status-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
}

/* Base sync status styling */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-decoration: none;
    user-select: none;
}

.connection-status:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Sync status display */
.sync-status-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

/* Icon styling within status */
.connection-status .material-symbols-outlined {
    font-size: 12px !important;
    line-height: 1;
}

.sync-icon {
    font-size: 1.2rem;
    line-height: 1;
}

/* Text styling */
.sync-text {
    font-weight: 500;
    white-space: nowrap;
}

/* Badge styling */
.pending-badge {
    background-color: #dc3545;
    color: white;
    border-radius: 10px;
    padding: 1px 5px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.1;
    min-width: 16px;
    text-align: center;
    display: inline-block;
}

.sync-badge {
    background: rgba(255, 255, 255, 0.9);
    color: #dc3545;
    border-radius: 50%;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
    line-height: 1;
}

/* Status-specific colors */
.connection-status.synced {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.connection-status.success {
    background: rgba(25, 135, 84, 0.1);
    color: #198754;
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.connection-status.syncing {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

.connection-status.offline {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f1b9c0;
}

.connection-status.api-error {
    background-color: #ffd3cd;
    color: #8a1a00;
    border-color: #ffb3a6;
}

.connection-status.pending {
    background-color: #e2e3ff;
    color: #383d77;
    border-color: #c5c7ff;
}

.connection-status.conflicts {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f1b9c0;
}

.connection-status.unknown {
    background-color: #e9ecef;
    color: #495057;
    border-color: #ced4da;
}

/* Pending count badge */
.connection-status.synced .pending-badge {
    background-color: #28a745;
}

.connection-status.pending .pending-badge {
    background-color: #fd7e14;
}

/* Sync spinner animation */
.sync-spinner {
    animation: sync-spin 1s linear infinite;
}

@keyframes sync-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Manual sync button */
.btn-sync {
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    padding: 2px 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #6c757d;
}

.btn-sync:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    transform: translateY(-1px);
}

.btn-sync:active {
    transform: translateY(0);
}

/* Status-specific manual sync button colors */
.connection-status.api-error ~ .btn-sync {
    border-color: #ff6b47;
    color: #ff6b47;
}

.connection-status.api-error ~ .btn-sync:hover {
    background-color: #fff5f3;
    border-color: #ff8566;
}

.connection-status.pending ~ .btn-sync {
    border-color: #fd7e14;
    color: #fd7e14;
}

.connection-status.pending ~ .btn-sync:hover {
    background-color: #fef9f3;
    border-color: #fd9843;
}

/* Hover effects for different status types */
.connection-status.synced:hover {
    background-color: #c3e6cb;
}

.connection-status.success:hover {
    background: rgba(25, 135, 84, 0.2);
}

.connection-status.syncing:hover {
    background-color: #ffeaa7;
}

.connection-status.offline:hover {
    background-color: #f1b9c0;
}

.connection-status.api-error:hover {
    background-color: #ffb3a6;
}

.connection-status.pending:hover {
    background-color: #c5c7ff;
}

.connection-status.conflicts:hover {
    background-color: #f1b9c0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sync-status-container {
        gap: 2px;
    }
    
    .connection-status {
        font-size: 9px;
        padding: 2px 6px;
        gap: 3px;
    }
    
    .connection-status .material-symbols-outlined {
        font-size: 10px !important;
    }
    
    .pending-badge {
        font-size: 8px;
        padding: 1px 4px;
        min-width: 14px;
    }
    
    .btn-sync {
        padding: 1px 3px;
    }
}

/* Phase 3: Enhanced Sync Status Styles */

.sync-status-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
}

.sync-status-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.sync-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.sync-text {
    font-weight: 500;
    white-space: nowrap;
}

.sync-badge {
    background: rgba(255, 255, 255, 0.9);
    color: #dc3545;
    border-radius: 50%;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
    line-height: 1;
}

/* Status-specific styling */
.sync-status-success {
    background: rgba(25, 135, 84, 0.1);
    color: #198754;
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.sync-status-syncing {
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    border: 1px solid rgba(13, 110, 253, 0.2);
    animation: sync-pulse 2s infinite;
}

.sync-status-pending {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.2);
}

.sync-status-offline {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.2);
}

.sync-status-error {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.sync-status-warning {
    background: rgba(255, 138, 0, 0.1);
    color: #ff8a00;
    border: 1px solid rgba(255, 138, 0, 0.2);
}

.sync-status-unknown {
    background: rgba(108, 117, 125, 0.05);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.1);
}

/* Progress bar */
.sync-progress-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.sync-progress-bar {
    width: 100%;
    height: 0.25rem;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0.125rem;
    overflow: hidden;
}

.sync-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #6610f2);
    transition: width 0.3s ease;
    border-radius: 0.125rem;
    animation: progress-shimmer 1.5s infinite;
}

.sync-progress-text {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
}

/* Error details */
.sync-error-details {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.sync-error-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    width: 100%;
    justify-content: space-between;
}

.sync-error-list {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(220, 53, 69, 0.05);
    border-radius: 0.25rem;
    border: 1px solid rgba(220, 53, 69, 0.1);
}

.sync-error-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Animations */
@keyframes sync-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes progress-shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

.sync-progress-fill {
    background: linear-gradient(
        90deg, 
        #0d6efd 0%, 
        #6610f2 50%, 
        #0d6efd 100%
    );
    background-size: 200% 100%;
}

/* Responsive design */
@media (max-width: 768px) {
    .sync-status-display {
        padding: 0.5rem;
        gap: 0.75rem;
    }
    
    .sync-text {
        font-size: 0.875rem;
    }
    
    .sync-icon {
        font-size: 1.4rem;
    }
    
    .sync-badge {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Integration with existing status indicators */
.connection-status.sync-enhanced {
    position: relative;
    padding-left: 2rem;
}

.connection-status.sync-enhanced .sync-status-container {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* Hover effects */
.sync-status-display:hover {
    opacity: 0.8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Focus styles for accessibility */
.sync-status-display:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .sync-status-container {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .connection-status {
        border-width: 2px;
        font-weight: 700;
    }
    
    .connection-status.synced {
        background-color: #ffffff;
        color: #000000;
        border-color: #008000;
    }
    
    .connection-status.offline {
        background-color: #ffffff;
        color: #000000;
        border-color: #ff0000;
    }
    
    .connection-status.api-error {
        background-color: #ffffff;
        color: #000000;
        border-color: #ff8000;
    }
}

/* ========================================
   ?? PHASE 4: Enhanced Sync Status Indicators
   Professional badges with animations and gradients
   ======================================== */

/* ========================================
   Network Status Badges
   ======================================== */
.network-status-indicator {
    display: inline-flex;
}

.badge-network-online {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(67, 233, 123, 0.3);
}

.badge-network-offline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(135deg, #757F9A 0%, #D7DDE8 100%);
    color: #333;
    box-shadow: 0 2px 8px rgba(117, 127, 154, 0.3);
}

/* Sync Status Container */
.sync-status-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Base Badge Styling */
.badge[class*="badge-sync-"] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.badge[class*="badge-sync-"] i {
    font-size: 14px;
    line-height: 1;
}

.badge-text {
    font-weight: 600;
    white-space: nowrap;
}

.badge-count, 
.badge-retry {
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
}

/* ========================================
   Pending Status - Yellow/Orange Gradient
   ======================================== */
.badge-sync-pending {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(253, 160, 133, 0.3);
}

.badge-sync-pending:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(253, 160, 133, 0.4);
}

.badge-sync-pending::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

/* ========================================
   Syncing Status - Blue Gradient
   ======================================== */
.badge-sync-syncing {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.badge-sync-syncing .rotating {
    animation: rotate 1s linear infinite;
}

.badge-sync-syncing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    animation: pulse-glow 1.5s ease-out infinite;
}

/* ========================================
   Failed Status - Red/Pink Gradient
   ======================================== */
.badge-sync-failed {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
}

.badge-sync-failed:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.5);
}

/* ========================================
   Complete/Synced Status - Green Gradient
   ======================================== */
.badge-sync-complete,
.badge-sync-synced {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(67, 233, 123, 0.3);
}

.badge-sync-complete:hover,
.badge-sync-synced:hover {
    transform: scale(1.02);
}

.badge-sync-complete .bi-check-circle-fill,
.badge-sync-synced .bi-check-circle-fill {
    animation: check-bounce 0.6s ease-out;
}

/* ========================================
   Unknown/Default Status - Gray Gradient
   ======================================== */
.badge-sync-unknown {
    background: linear-gradient(135deg, #a8a8a8 0%, #7f7f7f 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(168, 168, 168, 0.3);
}

/* ========================================
   Queued Status - Purple Gradient
   ======================================== */
.badge-sync-queued {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.badge-sync-queued::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: shimmer 3s infinite;
}

/* ========================================
   Offline Status - Dark Gray
   ======================================== */
.badge-sync-offline {
    background: linear-gradient(135deg, #757F9A 0%, #D7DDE8 100%);
    color: #333;
    box-shadow: 0 2px 8px rgba(117, 127, 154, 0.3);
}

/* ========================================
   Animations
   ======================================== */

/* Pulse Animation - For pending items */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.pulse-animation {
    animation: pulse 2s ease-in-out infinite;
}

/* Rotate Animation - For syncing spinner */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.rotating {
    display: inline-block;
}

/* Shake Animation - For failed items */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.shake-animation {
    animation: shake 0.5s ease-in-out;
}

/* Shimmer Animation - For pending/queued */
@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Pulse Glow Animation - For syncing */
@keyframes pulse-glow {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Check Bounce Animation - For completed */
@keyframes check-bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.3);
    }
    60% {
        transform: scale(0.9);
    }
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* ========================================
   Time Ago Text
   ======================================== */
.sync-status-container small {
    font-size: 11px;
    color: #6c757d;
    white-space: nowrap;
}

.sync-status-container .text-muted {
    opacity: 0.8;
}

/* ========================================
   Sync Summary Card (for dashboard views)
   ======================================== */
.sync-summary-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.sync-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.sync-stat:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.sync-stat-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.sync-stat-icon.synced {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.sync-stat-icon.pending {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    color: white;
}

.sync-stat-icon.failed {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.sync-stat-content {
    flex: 1;
}

.sync-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.sync-stat-label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .badge[class*="badge-sync-"] {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .badge-text {
        display: none;
    }
    
    .badge-count, 
    .badge-retry {
        padding: 1px 4px;
        font-size: 10px;
    }
    
    .sync-summary-card {
        grid-template-columns: 1fr;
    }
    
    .sync-stat {
        padding: 10px;
    }
    
    .sync-stat-icon {
        font-size: 24px;
        width: 40px;
        height: 40px;
    }
    
    .sync-stat-value {
        font-size: 20px;
    }
}

/* ========================================
   Dark Mode Support
   ======================================== */
@media (prefers-color-scheme: dark) {
    .sync-summary-card {
        background: #2d3748;
    }
    
    .sync-stat {
        background: #1a202c;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    .sync-stat:hover {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    }
    
    .sync-stat-label {
        color: #a0aec0;
    }
    
    .sync-status-container small {
        color: #a0aec0;
    }
}

/* ========================================
   Print - Hide Animations
   ======================================== */
@media print {
    .badge[class*="badge-sync-"]::before,
    .badge[class*="badge-sync-"]::after {
        display: none !important;
    }
    
    .badge[class*="badge-sync-"] {
        animation: none !important;
    }
    
    .sync-summary-card {
        break-inside: avoid;
    }
}

/* ========================================
   Accessibility
   ======================================== */
.badge[class*="badge-sync-"] {
    cursor: help;
}

.badge[class*="badge-sync-"]:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .badge[class*="badge-sync-"] {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .badge[class*="badge-sync-"],
    .badge[class*="badge-sync-"]::before,
    .badge[class*="badge-sync-"]::after,
    .rotating,
    .sync-stat {
        animation: none !important;
        transition: none !important;
    }
}