/**
 * Offline Mode Styles
 */

/* Connection indicator in navbar */
.connection-indicator {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 12px;
    margin-left: 10px;
    vertical-align: middle;
    animation: pulse-indicator 2s infinite;
}

.connection-indicator.online {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.4);
}

.connection-indicator.offline {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: white;
    box-shadow: 0 2px 8px rgba(192, 57, 43, 0.4);
}

@keyframes pulse-indicator {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

/* Legacy offline badge (fallback) */
.offline-badge {
    position: fixed;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(192, 57, 43, 0.4);
    animation: pulse-indicator 2s infinite;
    font-size: 14px;
}

@keyframes pulse-offline {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Body class when offline */
body.is-offline {
    border-top: 3px solid #f39c12;
}

body.is-offline::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        45deg,
        #f39c12,
        #f39c12 10px,
        #e67e22 10px,
        #e67e22 20px
    );
    z-index: 10000;
}

/* Sync progress indicator */
.sync-progress {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sync-progress .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Sync prompt */
.sync-prompt {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.sync-prompt-content {
    background: white;
    padding: 30px 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.sync-prompt-content h4 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.sync-prompt-content p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.sync-prompt-content button {
    margin: 0 5px;
    padding: 10px 25px;
}

/* Offline notifications */
.offline-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 9998;
    animation: slideUp 0.3s ease, fadeOut 0.3s ease 3.7s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.offline-notification.info {
    background: #3498db;
}

.offline-notification.success {
    background: #27ae60;
}

.offline-notification.warning {
    background: #f39c12;
}

.offline-notification.error {
    background: #e74c3c;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 20px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/* Offline bill success modal */
.offline-bill-success {
    text-align: center;
    padding: 20px;
}

.offline-bill-success h4 {
    color: #f39c12;
    margin-bottom: 15px;
}

.offline-bill-success p {
    margin: 10px 0;
}

.offline-bill-success strong {
    color: #2c3e50;
    font-size: 1.2em;
}

.offline-bill-success small {
    display: block;
    margin-top: 15px;
    color: #e74c3c;
}

/* Pending bills badge */
#pending-bills-badge {
    background: #f39c12;
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    animation: pulse 1.5s infinite;
}

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

/* Offline modal styling */
.offline-modal .modal-content {
    border: 2px solid #f39c12;
}

.offline-modal .modal-header {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

/* Stale data warning */
.stale-data-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stale-data-warning::before {
    content: '⚠️';
    font-size: 1.2em;
}

/* Sync button */
#sync-btn {
    position: relative;
}

#sync-btn.syncing {
    pointer-events: none;
    opacity: 0.7;
}

#sync-btn.syncing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* RTL adjustments for Arabic */
[dir="rtl"] .offline-badge,
html[lang="ar"] .offline-badge {
    right: auto;
    left: 10px;
}

[dir="rtl"] #pending-bills-badge,
html[lang="ar"] #pending-bills-badge {
    margin-left: 0;
    margin-right: 10px;
}

/* Print styles - hide offline indicators */
@media print {
    .offline-badge,
    .sync-progress,
    .sync-prompt,
    .offline-notification,
    #sync-btn,
    #pending-bills-badge {
        display: none !important;
    }
}
