/**
 * Offline Reading Styles
 * CSS for offline functionality and synchronization UI
 */

/* Connection Status Indicator */
.connection-status {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.connection-status.online {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.connection-status.offline {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    animation: pulse 2s infinite;
}

.connection-status.syncing {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

/* Offline Alert Banner */
.offline-alert {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 12px 20px;
    text-align: center;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 999;
    display: none;
}

.offline-alert.show {
    display: block;
}

.offline-alert .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    float: right;
    margin-top: -2px;
}

/* Offline Content Section */
.offline-section {
    background: #f8fafc;
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    border: 1px solid #e2e8f0;
}

.offline-section h2 {
    color: #1e293b;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.offline-section h2::before {
    content: "📱";
    font-size: 1.2em;
}

/* Storage Usage Stats */
.storage-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.storage-stats .stat {
    background: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.storage-stats .stat .label {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.storage-stats .stat .value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

/* Sync Status */
.sync-status {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sync-status .pending {
    color: #f59e0b;
    font-weight: 600;
}

.sync-status .synced {
    color: #22c55e;
    font-weight: 600;
}

.sync-status .syncing {
    color: #3b82f6;
    font-weight: 600;
}

.sync-status::before {
    content: "🔄";
    font-size: 1.1em;
}

.sync-status.synced::before {
    content: "✅";
}

.sync-status.pending::before {
    content: "⏳";
}

/* Offline Content List */
.offline-content-list {
    display: grid;
    gap: 16px;
    margin: 20px 0;
}

.offline-content-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.offline-content-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.offline-content-item .content-info h3 {
    color: #1e293b;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.offline-content-item .author {
    color: #64748b;
    font-style: italic;
    margin-bottom: 12px;
}

.offline-content-item .meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.offline-content-item .meta span {
    background: #f1f5f9;
    color: #475569;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.offline-content-item .meta .format {
    background: #dbeafe;
    color: #1d4ed8;
}

.offline-content-item .meta .progress {
    background: #dcfce7;
    color: #16a34a;
}

.offline-content-item .timestamps {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

.offline-content-item .timestamps small {
    color: #94a3b8;
    font-size: 0.75rem;
}

.offline-content-item .content-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

/* Sync Controls */
.sync-controls {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.sync-controls h3 {
    color: #1e293b;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sync-controls h3::before {
    content: "🔄";
}

.sync-controls .control-group {
    display: flex;
    gap: 12px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.sync-controls .auto-sync-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
}

.sync-controls .auto-sync-toggle input[type="checkbox"] {
    transform: scale(1.2);
}

/* Progress Indicator */
.sync-progress {
    background: #e0f2fe;
    color: #0369a1;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    display: none;
    position: relative;
    overflow: hidden;
}

.sync-progress::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: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Message Banner */
.message-banner {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    z-index: 1001;
    padding: 16px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    animation: slideIn 0.3s ease-out;
}

.message-banner.success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.message-banner.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.message-banner.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.message-banner.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Download Progress */
.download-progress {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    border-left: 4px solid #3b82f6;
}

.download-progress .progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.download-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.empty-state p {
    margin: 8px 0;
    font-size: 1.1rem;
}

.empty-state p:first-child {
    font-size: 1.3rem;
    font-weight: 600;
    color: #475569;
}

/* Offline-only and Online-only elements */
.offline-only {
    display: none;
}

.online-only {
    display: block;
}

body.offline .offline-only {
    display: block;
}

body.offline .online-only {
    display: none;
}

/* Button States */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #94a3b8 !important;
}

.btn.downloading {
    position: relative;
    overflow: hidden;
}

.btn.downloading::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: loading 1.5s infinite;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .connection-status {
        position: static;
        margin: 10px;
        text-align: center;
    }
    
    .storage-stats {
        grid-template-columns: 1fr;
    }
    
    .sync-controls .control-group {
        flex-direction: column;
    }
    
    .offline-content-item .content-actions {
        flex-direction: column;
    }
    
    .message-banner {
        position: static;
        margin: 10px;
        max-width: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .offline-section {
        background: #1e293b;
        border-color: #334155;
    }
    
    .offline-section h2 {
        color: #f1f5f9;
    }
    
    .storage-stats .stat {
        background: #334155;
        color: #f1f5f9;
    }
    
    .storage-stats .stat .value {
        color: #f1f5f9;
    }
    
    .offline-content-item {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
    }
    
    .offline-content-item .content-info h3 {
        color: #f1f5f9;
    }
    
    .sync-controls {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
    }
    
    .sync-controls h3 {
        color: #f1f5f9;
    }
}

/* Accessibility Enhancements */
.connection-status:focus,
.offline-content-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.sync-controls button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .connection-status.online {
        background: #008000;
        border: 2px solid #ffffff;
    }
    
    .connection-status.offline {
        background: #ff0000;
        border: 2px solid #ffffff;
    }
    
    .offline-content-item {
        border: 2px solid #000000;
    }
    
    .btn {
        border: 2px solid #000000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .connection-status.offline {
        animation: none;
    }
    
    .sync-progress::before {
        animation: none;
    }
    
    .btn.downloading::before {
        animation: none;
    }
    
    .download-progress .progress-fill {
        animation: none;
    }
}
