/**
 * Offline Indicator Styling
 * Styles for connection status, sync badge, and offline UI elements
 */

/* ===== Offline Indicator Container ===== */
.offline-indicator {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.offline-indicator.visible {
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    .offline-indicator {
        top: 60px;
        right: 10px;
        left: 10px;
    }
}

/* ===== Indicator Content ===== */
.offline-indicator-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #0d6efd;
}

/* ===== Status Badge ===== */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.status-badge i {
    font-size: 1rem;
}

/* Online status */
.status-badge.online {
    background-color: rgba(25, 135, 84, 0.1);
    color: #198754;
    border: 1px solid #198754;
}

.status-badge.online i::before {
    animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Offline status */
.status-badge.offline {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid #dc3545;
}

.status-badge.offline i::before {
    animation: pulse-offline 2s infinite;
}

@keyframes pulse-offline {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* ===== Sync Badge Container ===== */
.offline-indicator-sync {
    display: flex;
    align-items: center;
}

/* ===== Sync Badge ===== */
.sync-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    border: 1px solid #0d6efd;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

.sync-badge i {
    display: inline-block;
}

.sync-badge.syncing i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ===== Action Buttons ===== */
.offline-indicator-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background-color: transparent;
    color: #6c757d;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background-color: #f1f3f5;
    color: #0d6efd;
}

.btn-icon i {
    font-size: 1rem;
}

/* ===== Details Panel ===== */
.offline-indicator-details {
    margin-top: 1rem;
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    max-height: 600px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .offline-indicator-details {
        max-height: 400px;
    }
}

/* ===== Details Header ===== */
.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    background-color: #f8f9fa;
}

.details-header h5 {
    margin: 0;
    font-size: 1rem;
    color: #212529;
}

.btn-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6c757d;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.btn-close:hover {
    color: #212529;
}

/* ===== Details Body ===== */
.details-body {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .details-body {
        max-height: 300px;
    }
}

/* ===== Operations List ===== */
.operations-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.operation-item {
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    background-color: #fff;
    transition: all 0.2s ease;
}

.operation-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== Operation Status Styles ===== */
.operation-item.status-pending {
    border-left: 3px solid #ffc107;
}

.operation-item.status-syncing {
    border-left: 3px solid #0d6efd;
    background-color: rgba(13, 110, 253, 0.02);
}

.operation-item.status-completed {
    border-left: 3px solid #198754;
    background-color: rgba(25, 135, 84, 0.02);
}

.operation-item.status-failed {
    border-left: 3px solid #dc3545;
    background-color: rgba(220, 53, 69, 0.02);
}

/* ===== Operation Header ===== */
.operation-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.operation-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 0.375rem;
    background-color: #f1f3f5;
    color: #0d6efd;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.operation-info {
    flex: 1;
    min-width: 0;
}

.operation-endpoint {
    font-size: 0.9rem;
    font-weight: 500;
    color: #212529;
    word-break: break-all;
}

.operation-method {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.operation-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: #f1f3f5;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #0d6efd;
    white-space: nowrap;
    text-transform: uppercase;
}

/* ===== Operation Details ===== */
.operation-details {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e9ecef;
    font-size: 0.85rem;
}

.operation-details small {
    display: block;
    margin-top: 0.25rem;
}

.operation-details small:first-child {
    margin-top: 0;
}

/* ===== Details Footer ===== */
.details-footer {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid #e9ecef;
    background-color: #f8f9fa;
    flex-wrap: wrap;
}

.details-footer .btn {
    flex: 1;
    min-width: 160px;
    font-size: 0.9rem;
}

@media (max-width: 576px) {
    .details-footer .btn {
        min-width: 100%;
    }
}

/* ===== Notification Container ===== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .notification-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* ===== Alert Notification ===== */
.alert-notification {
    display: flex;
    align-items: center;
    padding: 1rem !important;
    border-radius: 0.375rem;
    animation: slideIn 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-notification i {
    margin-right: 0.5rem;
}

.alert-notification .btn-close {
    position: absolute;
    right: 0.75rem;
}

/* ===== Offline Mode Styles ===== */
body.offline-mode {
    --bs-body-color: #212529;
}

/* Disable submit buttons when offline */
body.offline-mode .btn-primary:disabled,
body.offline-mode .btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Offline mode banner */
.offline-banner {
    display: none;
    padding: 1rem;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 0.375rem;
    color: #856404;
    margin-bottom: 1rem;
    text-align: center;
}

.offline-banner.visible {
    display: block;
}

.offline-banner i {
    margin-right: 0.5rem;
}

/* ===== Data Sync Indicator ===== */
.data-syncing {
    position: relative;
    opacity: 0.7;
}

.data-syncing::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(0, 0, 0, 0.05),
        rgba(0, 0, 0, 0.05) 10px,
        transparent 10px,
        transparent 20px
    );
    animation: shimmer 1s infinite;
    pointer-events: none;
    border-radius: 0.375rem;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ===== Scrollbar Styling for Details Panel ===== */
.offline-indicator-details::-webkit-scrollbar {
    width: 6px;
}

.offline-indicator-details::-webkit-scrollbar-track {
    background: #f1f3f5;
}

.offline-indicator-details::-webkit-scrollbar-thumb {
    background: #cbd3e1;
    border-radius: 4px;
}

.offline-indicator-details::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Firefox scrollbar */
.offline-indicator-details {
    scrollbar-color: #cbd3e1 #f1f3f5;
    scrollbar-width: thin;
}

/* ===== Print Styles ===== */
@media print {
    .offline-indicator,
    .notification-container,
    .offline-banner {
        display: none !important;
    }
}

/* ===== RTL Support ===== */
[dir="rtl"] .offline-indicator {
    right: auto;
    left: 20px;
}

[dir="rtl"] .offline-indicator-content {
    border-left: none;
    border-right: 4px solid #0d6efd;
}

[dir="rtl"] .offline-indicator-actions {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .notification-container {
    right: auto;
    left: 20px;
}

[dir="rtl"] .operation-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .status-badge i::before,
[dir="rtl"] .sync-badge i::before {
    margin-left: 0.5rem;
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    .offline-indicator,
    .status-badge,
    .sync-badge,
    .operation-item,
    .alert-notification {
        animation: none !important;
        transition: none !important;
    }
}

@media (prefers-color-scheme: dark) {
    .offline-indicator-content {
        background-color: #343a40;
        color: #f8f9fa;
    }

    .details-header {
        background-color: #495057;
        border-bottom-color: #495057;
    }

    .details-header h5 {
        color: #f8f9fa;
    }

    .operation-item {
        background-color: #495057;
        border-color: #495057;
        color: #f8f9fa;
    }

    .operation-endpoint {
        color: #f8f9fa;
    }

    .details-footer {
        background-color: #495057;
        border-top-color: #495057;
    }

    .details-body {
        background-color: #343a40;
    }
}
