/* Kiwix Page Styles */

.kiwix-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 2rem;
    flex-wrap: wrap;
}

.kiwix-header h1 {
    color: #2c5f2d;
    margin: 0 0 0.5rem 0;
}

.kiwix-header p {
    color: #666;
    margin: 0;
}

/* Server Status */
.server-status {
    text-align: right;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    margin-bottom: 1rem;
}

.status-indicator.online {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-indicator.offline {
    background: #ffebee;
    color: #c62828;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.online .status-dot {
    background: #4caf50;
}

.status-indicator.offline .status-dot {
    background: #f44336;
}

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

.server-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Info Card */
.info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.info-card h3 {
    margin: 0 0 0.5rem 0;
}

.info-card p {
    margin: 0;
    opacity: 0.95;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
}

.tab {
    background: transparent;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab:hover {
    color: #2c5f2d;
    background: #f5f5f5;
}

.tab.active {
    color: #2c5f2d;
    border-bottom-color: #2c5f2d;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-description {
    color: #666;
    margin-bottom: 1.5rem;
}

/* Catalog Grid */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.25rem;
}

.catalog-count {
    grid-column: 1 / -1;
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0.5rem;
}

.catalog-item {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #fff);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid var(--border-color, #e0e0e0);
    transition: transform 0.2s, box-shadow 0.2s;
}

.catalog-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.catalog-item h3 {
    margin: 0;
    color: var(--text-primary, #2c5f2d);
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
}

.catalog-header .category {
    flex-shrink: 0;
    background: #e8f5e9;
    color: #2c5f2d;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.catalog-description {
    margin: 0 0 1rem 0;
    color: var(--text-secondary, #555);
    font-size: 0.9rem;
    line-height: 1.5;
    flex: 1;
}

.catalog-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, #eee);
}

.catalog-stats .stat {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
}

.catalog-stats .stat strong {
    color: var(--text-primary, #333);
}

.catalog-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 0.75rem;
}

.catalog-footer .date {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
}

.catalog-footer button {
    padding: 0.5rem 1.25rem;
    font-weight: 500;
}

/* Category color variants */
.category-wikipedia { background: #e3f2fd !important; color: #1565c0 !important; }
.category-wikibooks { background: #fff3e0 !important; color: #e65100 !important; }
.category-stack_exchange { background: #f3e5f5 !important; color: #7b1fa2 !important; }
.category-ted { background: #ffebee !important; color: #c62828 !important; }
.category-gutenberg { background: #e0f2f1 !important; color: #00695c !important; }
.category-devdocs { background: #e8eaf6 !important; color: #3949ab !important; }
.category-zimit { background: #fce4ec !important; color: #c2185b !important; }
.category-other { background: #f5f5f5 !important; color: #616161 !important; }
.category-phet { background: #fff8e1 !important; color: #f57f17 !important; }
.category-openstreetmap { background: #e8f5e9 !important; color: #2e7d32 !important; }

@media (max-width: 768px) {
    .catalog-grid {
        grid-template-columns: 1fr;
    }

    .catalog-header {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Library List */
.library-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.library-item {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.library-item-info h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.library-item-meta {
    display: flex;
    gap: 1.5rem;
    color: #666;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.library-item-actions {
    display: flex;
    gap: 0.5rem;
}

/* Downloads List */
.downloads-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.download-item {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.download-item h3 {
    margin: 0 0 0.5rem 0;
    color: #333;
}

.download-progress {
    margin: 1rem 0;
}

.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2c5f2d, #4caf50);
    transition: width 0.3s;
}

.download-stats {
    display: flex;
    justify-content: space-between;
    color: #666;
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 1.1rem;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .kiwix-header {
        flex-direction: column;
    }

    .server-status {
        text-align: left;
        width: 100%;
    }

    .server-actions {
        justify-content: flex-start;
    }

    .catalog-grid {
        grid-template-columns: 1fr;
    }

    .library-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .library-item-actions {
        width: 100%;
        flex-direction: column;
    }

    .library-item-actions button {
        width: 100%;
    }
}

/* Search Bar */
.search-bar {
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-bar input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-bar input:focus {
    outline: none;
    border-color: #2c5f2d;
}

#catalog-count {
    color: #666;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Legacy catalog-meta (kept for backwards compat) */

/* Download Progress */
.download-item {
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
}

.download-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.download-header h4 {
    margin: 0;
    color: #333;
}

.download-status {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-downloading {
    background: #e3f2fd;
    color: #1976d2;
}

.status-processing {
    background: #fff3e0;
    color: #e65100;
}

.status-completed {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-error {
    background: #ffebee;
    color: #c62828;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2c5f2d, #4caf50);
    transition: width 0.5s ease;
    border-radius: 15px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-weight: 600;
    font-size: 0.9rem;
}

.download-info {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: #666;
}

.downloads-list {
    max-height: 600px;
    overflow-y: auto;
}

/* Stats Card Text Sizing Fix */
#server-info-card .stat-info h3 {
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

#server-info-card .stat-info h3 a {
    color: var(--primary-color, #2c5f2d);
    text-decoration: none;
    transition: color 0.2s ease;
}

#server-info-card .stat-info h3 a:hover {
    color: #4caf50;
    text-decoration: underline;
}

#server-info-card .stat-card {
    min-width: 0;
}

/* Catalog Grid Max Height */
.catalog-grid {
    max-height: none;
    overflow-y: visible;
}

.load-more-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 1.5rem auto;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    border: 2px solid var(--primary-color, #3b82f6);
    color: var(--primary-color, #3b82f6);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-more-btn:hover {
    background: var(--primary-color, #3b82f6);
    color: white;
}

/* Dark theme adjustments */
[data-theme="dark"] .catalog-count {
    background: #1e293b;
    color: #94a3b8;
}
