/**
 * TurniX PWA - Offline Indicator Styles
 */

/* Offline Indicator Bar */
.turnix-offline-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1050;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.turnix-offline-indicator.turnix-offline-visible {
    transform: translateY(0);
}

/* Content container */
.turnix-offline-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Offline icon */
.turnix-offline-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 193, 7, 0.2);
    border-radius: 50%;
    animation: turnix-pulse 2s infinite;
}

.turnix-offline-icon svg {
    color: #ffc107;
}

/* Text */
.turnix-offline-text {
    font-weight: 600;
    font-size: 14px;
}

/* Pending actions badge */
.turnix-offline-pending {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.turnix-pending-count {
    font-weight: 700;
    color: #ffc107;
}

/* Retry button */
.turnix-offline-retry {
    background: #BA1817;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.turnix-offline-retry:hover:not(:disabled) {
    background: #9a1314;
    transform: translateY(-1px);
}

.turnix-offline-retry:active:not(:disabled) {
    transform: translateY(0);
}

.turnix-offline-retry:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Pulse animation */
@keyframes turnix-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.95);
    }
}

/* Toast animations */
@keyframes turnix-toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes turnix-toast-out {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* Toast notification */
.turnix-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    animation: turnix-toast-in 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.turnix-toast-success {
    background: #28a745;
    color: white;
}

.turnix-toast-warning {
    background: #ffc107;
    color: #333;
}

.turnix-toast-error {
    background: #dc3545;
    color: white;
}

/* Mobile adjustments */
@media (max-width: 767.98px) {
    .turnix-offline-indicator {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .turnix-offline-content {
        width: 100%;
        justify-content: center;
    }

    .turnix-offline-retry {
        width: 100%;
        padding: 12px;
    }

    /* Adjust position when bottom nav is present */
    body.has-bottom-nav .turnix-offline-indicator {
        bottom: 56px;
        padding-bottom: 16px;
    }

    .turnix-toast {
        bottom: 140px;
        left: 16px;
        right: 16px;
        transform: none;
        text-align: center;
    }

    body.has-bottom-nav .turnix-toast {
        bottom: 200px;
    }
}

/* Sync in progress state */
.turnix-offline-indicator.turnix-syncing .turnix-offline-icon svg {
    animation: turnix-spin 1s linear infinite;
}

@keyframes turnix-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .turnix-offline-indicator {
        background: #000;
        border-top: 2px solid #ffc107;
    }

    .turnix-offline-retry {
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .turnix-offline-indicator {
        transition: none;
    }

    .turnix-offline-icon,
    .turnix-offline-retry {
        animation: none;
        transition: none;
    }

    .turnix-toast {
        animation: none;
    }
}

/* Dark mode support (if system prefers) */
@media (prefers-color-scheme: dark) {
    .turnix-toast-warning {
        background: #ffca28;
        color: #1a1a1a;
    }
}

/* Online indicator (brief flash when coming back online) */
.turnix-online-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 12px 16px;
    text-align: center;
    font-weight: 500;
    font-size: 14px;
    z-index: 1050;
    transform: translateY(-100%);
    transition: transform 0.3s ease-out;
}

.turnix-online-indicator.turnix-online-visible {
    transform: translateY(0);
}

/* Hide all PWA indicators when printing */
@media print {
    .turnix-offline-indicator,
    .turnix-online-indicator,
    .turnix-toast {
        display: none !important;
    }
}
