/* Library Page Specific Styles */
:root {
    --card-bg: #1e293b;
    --card-hover: #2d3748;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --secondary-color: #818cf8;
    --gradient: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Story Cards */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.story-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--card-shadow);
}

.story-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.story-card-img {
    height: 180px;
    overflow: hidden;
}

.story-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.story-card:hover .story-card-img img {
    transform: scale(1.05);
}

.story-card-content {
    padding: 1.5rem;
}

.story-category {
    font-size: 0.75rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.story-card h3 {
    font-size: 1.25rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.story-excerpt {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 0.75rem;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: var(--gradient);
    transition: width 0.3s ease;
}

/* Library Controls */
.library-controls {
    padding: 1.5rem 0;
    background-color: var(--light);
    border-bottom: 1px solid var(--text-muted);
}

.search-filter-container {
    display: flex;
    gap: 1rem;
    align-items: stretch; /* Align items by height */
    flex-wrap: wrap; /* Allow wrapping on small screens */
    margin-bottom: 1rem;
}

.search-box {
    flex: 1 1 300px;
    position: relative;
    display: flex; /* Use flex to align icon and input */
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.search-box input {
    width: 100%;
    height: 44px; /* Explicit height */
    box-sizing: border-box; /* Include padding and border in height */
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--text-muted);
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.2);
}

.filter-dropdown,
.sort-dropdown {
    position: relative;
    flex: 1 1 180px; /* Allow growing and shrinking with a base width */
    min-width: 180px;
}

.filter-dropdown select,
.sort-dropdown select {
    width: 100%;
    height: 44px; /* Explicit height */
    box-sizing: border-box; /* Include padding and border in height */
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    appearance: none;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-dropdown i,
.sort-dropdown i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-light);
    font-size: 0.8rem;
}

.filter-dropdown select:focus,
.sort-dropdown select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.2);
}

.view-options {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.view-option {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.view-option:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.view-option.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Library Content */
.library-content {
    padding: 2rem 0 4rem;
}

.library-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.bottom-stats {
    margin-top: 2rem;
    justify-content: center;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--text-muted);
    border-radius: 6px;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.pagination-btn:not(:disabled):hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
}

/* Bottom Pagination */
.bottom-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--text-muted);
}

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem auto;
    flex-wrap: wrap;
    padding: 0;
    background: none;
    max-width: 100%;
    gap: 0.5rem;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    min-width: 36px;
    padding: 0 1rem;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pagination-btn.prev-btn {
    margin-right: 0.5rem;
    padding-left: 0.75rem;
    padding-right: 1rem;
}

.pagination-btn.next-btn {
    margin-left: 0.5rem;
    padding-left: 1rem;
    padding-right: 0.75rem;
}

.pagination-btn i {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    position: relative;
    top: 1px;
}

.pagination-btn.prev-btn i {
    margin-right: 0.5rem;
}

.pagination-btn.next-btn i {
    margin-left: 0.5rem;
}

/* Custom styles for Prev/Next text-only buttons */
.pagination-btn.prev-btn,
.pagination-btn.next-btn {
    background: none;
    border: none;
    color: var(--secondary-color);
    padding: 0.5rem 0.25rem;
}

.pagination-btn.prev-btn:hover:not(:disabled),
.pagination-btn.next-btn:hover:not(:disabled) {
    background: none;
    color: var(--text-light);
    text-decoration: underline;
}

.pagination-btn.prev-btn:disabled,
.pagination-btn.next-btn:disabled {
    background: none;
    border: none;
    color: var(--text-muted);
    opacity: 0.7;
}

.pagination-btn:hover:not(:disabled) {
    color: var(--primary-dark);
    text-decoration: underline;
}

.pagination-btn:hover:not(:disabled) i {
    transform: translateX(-2px);
}

.pagination-btn.next-btn:hover:not(:disabled) i {
    transform: translateX(2px);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: var(--text-light);
}

.page-numbers {
    display: flex;
    gap: 0.5rem;
    margin: 0 0.5rem;
    padding: 0;
}

.page-number {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0 0.5rem;
}

.page-number:hover:not(.active) {
    background-color: #f1f5f9;
    border-color: #e2e8f0;
    color: var(--primary);
}

.page-number.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    cursor: default;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    color: var(--text-light);
    user-select: none;
    font-size: 0.9rem;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.page-info span {
    font-weight: 600;
    color: var(--text);
}

/* Floating action button for mobile */
.floating-pagination {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 1rem;
    background: white;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.floating-pagination .pagination-btn {
    padding: 0.6rem 1rem;
    border-radius: 50px;
}

@media (max-width: 768px) {
    .pagination-container {
        display: none; /* Hide regular pagination on mobile */
    }
    
    .floating-pagination {
        display: flex;
    }
    
    .page-info {
        display: none;
    }
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    font-size: 1.1rem;
}

.btn-load-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-load-more:hover {
    background-color: #f8f9fa;
    border-color: var(--primary);
    color: var(--primary);
}

/* Progress Widget in Sidebar */
.sidebar-widget .progress-container {
    margin-top: 1rem;
}

.sidebar-widget .progress-bar {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.sidebar-widget .progress {
    height: 100%;
    background: var(--gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.sidebar-widget .progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 0.5rem;
}

.progress-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Responsive adjustment for smaller screens */
@media (max-width: 992px) {
    .progress-stats {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 576px) {
    .progress-stats {
        grid-template-columns: 1fr;
    }
}

/* Horizontal Ad Container */
.horizontal-ad-container {
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ad-placeholder-horizontal {
    width: 100%;
    max-width: 728px;
    height: 90px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    border: 1px dashed #ccc;
    color: #888;
    font-size: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    min-width: 0; /* Allows the item to shrink below its content's minimum size */
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.stat-item i {
    width: 32px;
    height: 32px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-right: 0.75rem;
}

.stat-text {
    min-width: 0; /* Allows the text container to shrink */
}

.stat-value {
    display: block;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    /* Standard property */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.6em; /* line-height (1.3) * 2 lines */
    line-clamp: 2;
}

.story-meta {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #edf2f7;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    /* Stack controls only on very small screens */
    .search-filter-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box,
    .filter-dropdown,
    .sort-dropdown {
        width: 100%;
        max-width: 100%;
        flex-basis: auto; /* Reset basis for stacking */
    }
    
    .view-options {
        margin-top: 1rem;
    }
    
    .library-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .pagination {
        margin-top: 1rem;
    }
    
    .progress-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .list-view story-card {
        flex-direction: column !important;
    }
    
    .list-view story-card .story-image {
        width: 100% !important;
        height: 180px !important;
        margin-right: 0 !important;
        margin-bottom: 1rem !important;
    }
    
    .pagination {
        width: 100%;
        justify-content: center;
    }
    
    .page-number {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .pagination-btn {
        width: 30px;
        height: 30px;
    }
}
