/**
 * Offline Mode Styles for CNM
 */

/* Offline Banner */
#offlineBanner {
    display: none;
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 8px 15px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(220, 53, 69, 0.3);
}

#offlineBanner i {
    margin-right: 8px;
    animation: pulse 2s infinite;
}

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

/* Adjust body padding when offline banner is visible */
body.is-offline {
    padding-top: 40px;
}

body.is-offline .main-header {
    top: 40px;
}

body.is-offline .main-sidebar {
    top: 40px;
}

/* Pending Cards Badge */
.pending-badge {
    display: none;
    background: #ffc107;
    color: #000;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 5px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* Pending Cards Section */
#pendingCardsSection {
    display: none;
    margin-bottom: 20px;
}

.pending-card {
    border-left: 4px solid #ffc107;
    background: #fff8e1;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.pending-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pending-card .card-body {
    padding: 12px 15px;
}

.pending-card .sync-status {
    font-size: 12px;
}

.pending-card .sync-status.pending {
    color: #ffc107;
}

.pending-card .sync-status.syncing {
    color: #17a2b8;
}

.pending-card .sync-status.synced {
    color: #28a745;
}

.pending-card .sync-status.error {
    color: #dc3545;
}

.pending-card-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    background: #f0f0f0;
}

/* Sync Progress Modal */
#syncProgressModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

#syncProgressModal .modal-content {
    background: white;
    border-radius: 10px;
    padding: 30px;
    max-width: 400px;
    margin: auto;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#syncProgressModal .sync-icon {
    font-size: 48px;
    color: #28a745;
    margin-bottom: 20px;
    animation: spin 2s linear infinite;
}

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

#syncProgressModal .progress {
    height: 10px;
    border-radius: 5px;
    margin: 15px 0;
}

#syncProgressModal .progress-bar {
    background: linear-gradient(135deg, #28a745, #20c997);
    transition: width 0.3s ease;
}

#syncProgressModal #syncProgressText {
    color: #666;
    font-size: 14px;
}

/* Sync Button */
.btn-sync {
    background: linear-gradient(135deg, #28a745, #20c997);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-sync:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    color: white;
}

.btn-sync:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-sync i {
    margin-right: 5px;
}

/* Offline indicator for scan page */
.offline-mode-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: none;
}

body.is-offline .offline-mode-notice {
    display: block;
}

.offline-mode-notice i {
    color: #ffc107;
    margin-right: 8px;
}

.offline-mode-notice .notice-text {
    color: #856404;
}

/* Hide OCR-dependent features when offline */
body.is-offline .ocr-required {
    opacity: 0.5;
    pointer-events: none;
}

body.is-offline .ocr-required::after {
    content: '(Requires internet)';
    font-size: 11px;
    color: #999;
    margin-left: 5px;
}

/* Pending count in sidebar */
.nav-sidebar .pending-count-badge {
    background: #ffc107;
    color: #000;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    float: right;
    margin-top: 3px;
}

/* Navbar Sync Badge */
.pending-sync-badge {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #000;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    animation: pulse-sync 2s infinite;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pending-sync-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
}

.pending-sync-badge i {
    animation: spin-slow 3s linear infinite;
}

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

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

/* PWA Update Banner */
.pwa-update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
    padding: 12px 15px;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(23, 162, 184, 0.3);
    animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.update-banner-content {
    display: flex;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    gap: 12px;
}

.update-banner-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.update-banner-icon i {
    font-size: 18px;
    color: white;
    animation: spin 2s linear infinite;
}

.update-banner-text {
    flex-grow: 1;
    line-height: 1.3;
}

.update-banner-text strong {
    display: block;
    font-size: 14px;
}

.update-banner-text small {
    color: rgba(255,255,255,0.8);
    font-size: 12px;
}

.update-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.update-banner-actions .btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
}

@media (max-width: 768px) {
    .pwa-update-banner {
        padding: 10px 12px;
    }

    .update-banner-content {
        flex-wrap: wrap;
    }

    .update-banner-icon {
        width: 35px;
        height: 35px;
    }

    .update-banner-text strong {
        font-size: 13px;
    }

    .update-banner-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }
}

/* PWA Install Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #2d3238, #1a1d21);
    color: white;
    padding: 12px 15px;
    z-index: 9998;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-banner-content {
    display: flex;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    gap: 12px;
}

.install-banner-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #28a745, #20c997);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.install-banner-icon i {
    font-size: 22px;
    color: white;
}

.install-banner-text {
    flex-grow: 1;
    line-height: 1.3;
}

.install-banner-text strong {
    display: block;
    font-size: 14px;
}

.install-banner-text small {
    color: #adb5bd;
    font-size: 12px;
}

.install-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.install-banner-actions .btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
}

/* Sidebar install link highlight */
#installAppSidebar .nav-link {
    background: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #ffc107;
}

#installAppSidebar .nav-link:hover {
    background: rgba(255, 193, 7, 0.2);
}

/* ========================================
   PWA Install Guide Modal
   ======================================== */

/* Modal header */
.install-guide-header {
    text-align: center;
    padding-bottom: 10px;
}

.install-guide-header .app-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    margin-bottom: 10px;
}

.install-guide-header h5 {
    font-weight: 700;
    margin-bottom: 2px;
}

.install-guide-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 12px 0 4px;
}

.install-guide-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dee2e6;
    transition: all 0.3s ease;
}

.install-guide-dots .dot.active {
    background: #28a745;
    transform: scale(1.3);
}

/* Step slides */
.install-guide-step {
    display: none;
    animation: igFadeIn 0.3s ease;
}

.install-guide-step.active {
    display: block;
}

@keyframes igFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.install-guide-step .step-label {
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.install-guide-step .step-instruction {
    text-align: center;
    font-size: 1rem;
    color: #333;
    margin-top: 14px;
    line-height: 1.5;
}

.install-guide-step .step-instruction strong {
    color: #28a745;
}

/* Phone mockup container */
.phone-mockup {
    background: #f8f9fa;
    border-radius: 16px;
    border: 2px solid #e9ecef;
    padding: 16px;
    max-width: 280px;
    margin: 0 auto;
    position: relative;
}

/* iOS Safari bottom bar mockup */
.safari-bar-mockup {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: #fff;
    border-radius: 12px;
    padding: 10px 8px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.safari-bar-mockup .bar-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 18px;
    color: #999;
}

.safari-bar-mockup .bar-icon.highlight {
    color: #007AFF;
    background: rgba(0, 122, 255, 0.1);
    animation: igPulse 1.5s ease-in-out infinite;
    position: relative;
}

.safari-bar-mockup .bar-icon.highlight::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #28a745;
}

@keyframes igPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(0, 122, 255, 0); }
}

.tap-here-label {
    text-align: center;
    color: #28a745;
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 10px;
}

.tap-here-label i {
    animation: igBounce 1s ease infinite;
}

@keyframes igBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* iOS Share Sheet mockup */
.share-sheet-mockup {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.share-sheet-mockup .sheet-header {
    background: #f2f2f7;
    padding: 10px 14px;
    font-size: 0.75rem;
    color: #888;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
}

.share-sheet-mockup .sheet-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    color: #333;
}

.share-sheet-mockup .sheet-row:last-child {
    border-bottom: none;
}

.share-sheet-mockup .sheet-row i {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    margin-right: 12px;
    font-size: 14px;
    flex-shrink: 0;
}

.share-sheet-mockup .sheet-row.highlight {
    background: #e8f5e9;
    border: 2px solid #28a745;
    border-radius: 10px;
    margin: 4px;
    animation: igPulse2 1.5s ease-in-out infinite;
}

@keyframes igPulse2 {
    0%, 100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.2); }
    50% { box-shadow: 0 0 0 6px rgba(40, 167, 69, 0); }
}

.share-sheet-mockup .sheet-row.highlight i {
    background: #28a745;
    color: #fff;
}

.share-sheet-mockup .sheet-row.muted {
    color: #bbb;
}

.share-sheet-mockup .sheet-row.muted i {
    background: #e9ecef;
    color: #aaa;
}

/* iOS Add confirmation mockup */
.add-confirm-mockup {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.add-confirm-mockup .confirm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #e9ecef;
}

.add-confirm-mockup .confirm-header .cancel-text {
    color: #007AFF;
    font-size: 0.9rem;
}

.add-confirm-mockup .confirm-header .add-btn {
    background: #007AFF;
    color: #fff;
    border: none;
    padding: 5px 16px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    animation: igPulse3 1.5s ease-in-out infinite;
}

@keyframes igPulse3 {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(0, 122, 255, 0); }
}

.add-confirm-mockup .confirm-body {
    padding: 20px 14px;
    text-align: center;
}

.add-confirm-mockup .confirm-body .confirm-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #28a745, #20c997);
}

.add-confirm-mockup .confirm-body .confirm-icon i {
    font-size: 24px;
    color: #fff;
}

.add-confirm-mockup .confirm-body .confirm-name {
    font-size: 0.9rem;
    color: #333;
    font-weight: 500;
}

.add-confirm-mockup .confirm-body .confirm-url {
    font-size: 0.75rem;
    color: #999;
}

/* Chrome/Android mockup */
.chrome-bar-mockup {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    margin-bottom: 8px;
}

.chrome-bar-mockup .url-bar {
    flex: 1;
    background: #f1f3f4;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.75rem;
    color: #5f6368;
    margin-right: 10px;
}

.chrome-bar-mockup .menu-dots {
    font-size: 20px;
    color: #5f6368;
    cursor: pointer;
    animation: igPulse 1.5s ease-in-out infinite;
    position: relative;
}

.chrome-menu-mockup {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    overflow: hidden;
    max-width: 200px;
    margin-left: auto;
}

.chrome-menu-mockup .menu-item {
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
}

.chrome-menu-mockup .menu-item:last-child {
    border-bottom: none;
}

.chrome-menu-mockup .menu-item i {
    width: 20px;
    margin-right: 10px;
    color: #666;
    text-align: center;
    font-size: 14px;
}

.chrome-menu-mockup .menu-item.highlight {
    background: #e8f5e9;
    color: #1b5e20;
    font-weight: 600;
    animation: igPulse2 1.5s ease-in-out infinite;
}

.chrome-menu-mockup .menu-item.highlight i {
    color: #28a745;
}

.chrome-menu-mockup .menu-item.muted {
    color: #ccc;
}

/* Chrome install dialog mockup */
.chrome-install-dialog {
    background: #fff;
    border-radius: 14px;
    padding: 24px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    text-align: center;
}

.chrome-install-dialog .dialog-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #28a745, #20c997);
}

.chrome-install-dialog .dialog-icon i {
    font-size: 28px;
    color: #fff;
}

.chrome-install-dialog .dialog-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.chrome-install-dialog .dialog-url {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 16px;
}

.chrome-install-dialog .dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.chrome-install-dialog .dialog-buttons .btn-cancel {
    padding: 8px 20px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    color: #666;
    font-size: 0.85rem;
}

.chrome-install-dialog .dialog-buttons .btn-install {
    padding: 8px 24px;
    border: none;
    border-radius: 20px;
    background: #28a745;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    animation: igPulse2 1.5s ease-in-out infinite;
}

/* Navigation buttons */
.install-guide-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.install-guide-nav .btn {
    min-width: 100px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #offlineBanner {
        font-size: 12px;
        padding: 6px 10px;
    }

    body.is-offline {
        padding-top: 32px;
    }

    body.is-offline .main-header,
    body.is-offline .main-sidebar {
        top: 32px;
    }

    #syncProgressModal .modal-content {
        margin: 20px;
        padding: 20px;
    }

    .pending-card-image {
        width: 40px;
        height: 40px;
    }

    /* Install banner mobile */
    .install-banner {
        padding: 10px 12px;
    }

    .install-banner-content {
        flex-wrap: wrap;
    }

    .install-banner-icon {
        width: 40px;
        height: 40px;
    }

    .install-banner-icon i {
        font-size: 18px;
    }

    .install-banner-text {
        flex: 1;
        min-width: 0;
    }

    .install-banner-text strong {
        font-size: 13px;
    }

    .install-banner-text small {
        font-size: 11px;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .install-banner-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }
}
