/**
 * Documents Library Styles
 * Advanced library layout with sidebar and grid/list views
 * Version: 2.0.0
 */

/* ==========================================================================
   Library Wrapper
   ========================================================================== */

.documents-library-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f7fa;
    min-height: 100vh;
}

/* ==========================================================================
   Filter Bar
   ========================================================================== */

.filter-bar {
    background: #ffffff;
    border-radius: 16px;
    padding: 25px 30px;
    margin-bottom: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.filter-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.filter-left {
    flex: 1;
}

.library-title {
    font-size: 28px;
    font-weight: 800;
    color: #2d3748;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.library-title svg {
    color: #667eea;
}

.library-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #718096;
}

.library-stats .stat {
    color: #4a5568;
}

.library-stats strong {
    color: #667eea;
    font-weight: 700;
}

.stat-sep {
    color: #cbd5e0;
}

.filter-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Search Box */
.search-box {
    position: relative;
    width: 350px;
}

.search-box svg {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #a0aec0;
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 5px;
    background: #f7fafc;
    padding: 4px;
    border-radius: 10px;
}

.view-btn {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: #718096;
    transition: all 0.2s ease;
}

.view-btn:hover {
    background: #edf2f7;
    color: #4a5568;
}

.view-btn.active {
    background: #667eea;
    color: #ffffff;
}

/* Advanced Filters */
.advanced-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    color: #4a5568;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 160px;
}

.filter-select:hover {
    border-color: #cbd5e0;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.reset-btn {
    padding: 10px 20px;
    background: #f56565;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background: #e53e3e;
    transform: translateY(-2px);
}

/* ==========================================================================
   Library Content (Sidebar + Main)
   ========================================================================== */

.library-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 25px;
    align-items: start;
}

/* ==========================================================================
   Categories Sidebar
   ========================================================================== */

.categories-sidebar {
    background: #ffffff;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 20px;
}

.sidebar-header {
    padding: 20px 25px;
    border-bottom: 2px solid #f7fafc;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

.categories-list {
    padding: 10px;
    max-height: 500px;
    overflow-y: auto;
}

.category-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    margin-bottom: 5px;
}

.category-item:hover {
    background: #f7fafc;
}

.category-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

.category-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.category-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
}

.category-count {
    background: rgba(0, 0, 0, 0.1);
    color: inherit;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

.category-item.active .category-count {
    background: rgba(255, 255, 255, 0.2);
}

/* Sidebar Stats */
.sidebar-stats {
    padding: 20px 25px;
    border-top: 2px solid #f7fafc;
}

.sidebar-stats h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 700;
    color: #2d3748;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-stats .stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    font-size: 13px;
    color: #4a5568;
}

.sidebar-stats .stat-item svg {
    color: #667eea;
    flex-shrink: 0;
}

/* ==========================================================================
   Documents Main Area
   ========================================================================== */

.documents-main {
    background: #ffffff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.results-header {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f7fafc;
}

.results-count {
    font-size: 15px;
    color: #4a5568;
    margin: 0 0 10px 0;
}

.results-count span {
    font-weight: 700;
    color: #667eea;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 13px;
}

.filter-badge {
    background: #edf2f7;
    color: #4a5568;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
}

/* ==========================================================================
   Documents Grid
   ========================================================================== */

.documents-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

.documents-grid.view-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.documents-grid.view-list {
    grid-template-columns: 1fr;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
    font-size: 16px;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
    font-size: 18px;
}

/* ==========================================================================
   Compact Document Card
   ========================================================================== */

.doc-card-compact {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
}

.doc-card-compact:hover {
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
    transform: translateY(-4px);
}

.doc-card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Thumbnail */
.doc-thumbnail-compact {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.doc-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doc-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
}

.lang-flag {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.doc-type-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Content */
.doc-content-compact {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-title-compact {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
}

.doc-title-compact a {
    color: #2d3748;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.doc-title-compact a:hover {
    color: #667eea;
}

.doc-author-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #718096;
}

.doc-author-compact svg {
    color: #a0aec0;
    flex-shrink: 0;
}

.doc-author-compact a {
    color: #718096;
    text-decoration: none;
    transition: color 0.2s ease;
}

.doc-author-compact a:hover {
    color: #667eea;
}

.doc-meta-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: #718096;
}

.doc-meta-compact .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.doc-meta-compact svg {
    color: #a0aec0;
    flex-shrink: 0;
}

.doc-stats-compact {
    display: flex;
    gap: 15px;
    padding-top: 8px;
    margin-top: auto;
    border-top: 1px solid #f7fafc;
}

.doc-stats-compact .stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #718096;
    font-weight: 600;
}

.doc-stats-compact svg {
    color: #a0aec0;
    flex-shrink: 0;
}

/* Actions */
.doc-actions-compact {
    display: flex;
    border-top: 2px solid #f7fafc;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border: none;
    background: transparent;
    color: #718096;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.action-btn:hover {
    background: #f7fafc;
    color: #667eea;
}

.action-btn + .action-btn {
    border-left: 2px solid #f7fafc;
}

/* List View Adjustments */
.documents-grid.view-list .doc-card-compact {
    border-radius: 12px;
}

.documents-grid.view-list .doc-card-inner {
    flex-direction: row;
}

.documents-grid.view-list .doc-thumbnail-compact {
    width: 150px;
    aspect-ratio: 3/4;
    flex-shrink: 0;
}

.documents-grid.view-list .doc-content-compact {
    flex: 1;
    padding: 20px;
}

.documents-grid.view-list .doc-title-compact {
    font-size: 18px;
}

.documents-grid.view-list .doc-actions-compact {
    flex-direction: column;
    width: 80px;
    border-top: none;
    border-left: 2px solid #f7fafc;
}

.documents-grid.view-list .action-btn + .action-btn {
    border-left: none;
    border-top: 2px solid #f7fafc;
}

/* ==========================================================================
   Load More Button
   ========================================================================== */

.load-more-wrapper {
    text-align: center;
    padding: 20px 0;
}

.load-more-btn {
    padding: 14px 40px;
    background: #667eea;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* ==========================================================================
   Responsive Design - محسّن للأجهزة المختلفة
   ========================================================================== */

/* Large Tablets - 1200px */
@media (max-width: 1200px) {
    .library-content {
        grid-template-columns: 240px 1fr;
        gap: 18px;
    }
    
    .search-box {
        width: 260px;
    }
    
    .documents-grid.view-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Tablets - 992px */
@media (max-width: 992px) {
    .documents-library-wrapper {
        padding: 12px;
    }
    
    .library-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .categories-sidebar {
        position: static;
        margin-bottom: 20px;
        max-height: none;
    }
    
    .categories-list {
        max-height: 250px;
        overflow-y: auto;
    }
    
    .filter-container {
        flex-wrap: wrap;
    }
    
    .filter-right {
        width: 100%;
        margin-top: 12px;
    }
    
    .search-box {
        width: 100%;
        max-width: none;
    }
    
    .documents-grid.view-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* Tablets Portrait - 768px */
@media (max-width: 768px) {
    .documents-library-wrapper {
        padding: 10px;
    }
    
    .filter-bar,
    .documents-main {
        padding: 18px 14px;
    }
    
    .filter-container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .filter-left {
        width: 100%;
    }
    
    .filter-right {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        margin-top: 0;
    }
    
    .search-box {
        width: 100%;
    }
    
    .view-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .view-toggle-btn {
        flex: 1;
        justify-content: center;
    }
    
    .advanced-filters {
        flex-direction: column;
        gap: 10px;
    }
    
    .filter-select {
        width: 100%;
    }
    
    .library-title {
        font-size: 20px;
    }
    
    .library-stats {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .stat-item {
        font-size: 12px;
    }
    
    .documents-grid.view-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }
    
    /* تحويل عرض القائمة للعمودي */
    .documents-grid.view-list .doc-card-inner {
        flex-direction: column;
    }
    
    .documents-grid.view-list .doc-thumbnail-compact {
        width: 100%;
        height: 180px;
        border-radius: 8px 8px 0 0;
    }
    
    .documents-grid.view-list .doc-content-compact {
        padding: 14px;
    }
    
    .documents-grid.view-list .doc-actions-compact {
        flex-direction: row;
        width: 100%;
        border-left: none;
        border-top: 2px solid #f7fafc;
    }
    
    .documents-grid.view-list .action-btn {
        flex: 1;
        justify-content: center;
        padding: 10px;
    }
    
    .documents-grid.view-list .action-btn + .action-btn {
        border-top: none;
        border-left: 2px solid #f7fafc;
    }
    
    .categories-sidebar {
        border-radius: 10px;
        padding: 16px;
    }
    
    .sidebar-title {
        font-size: 16px;
    }
}

/* Mobile Landscape - 640px */
@media (max-width: 640px) {
    .library-title {
        font-size: 18px;
    }
    
    .library-stats {
        font-size: 11px;
    }
    
    .doc-title {
        font-size: 13px;
    }
    
    .doc-meta {
        font-size: 11px;
    }
    
    .documents-grid.view-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
}

/* Mobile Portrait - 480px */
@media (max-width: 480px) {
    .documents-library-wrapper {
        padding: 8px;
    }
    
    .filter-bar,
    .documents-main {
        padding: 16px 12px;
        border-radius: 10px;
    }
    
    .library-title {
        font-size: 18px;
    }
    
    .library-title svg {
        width: 24px;
        height: 24px;
    }
    
    .library-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        font-size: 11px;
    }
    
    .stat-sep {
        display: none;
    }
    
    .stat-item {
        width: 100%;
    }
    
    .search-box {
        padding: 8px 12px 8px 36px;
        font-size: 13px;
    }
    
    .search-icon {
        font-size: 16px;
    }
    
    .filter-select {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .view-toggle-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .view-toggle-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .documents-grid.view-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .doc-card {
        padding: 12px;
    }
    
    .doc-thumbnail {
        height: 200px;
    }
    
    .doc-title {
        font-size: 14px;
    }
    
    .doc-author {
        font-size: 11px;
    }
    
    .doc-meta {
        font-size: 10px;
        gap: 8px;
    }
    
    .doc-actions {
        gap: 8px;
        padding-top: 10px;
    }
    
    .doc-btn {
        padding: 7px 12px;
        font-size: 11px;
    }
    
    .categories-sidebar {
        padding: 14px;
    }
    
    .sidebar-title {
        font-size: 14px;
    }
    
    .category-item {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .category-icon {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .category-count {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .documents-grid.view-list .doc-thumbnail-compact {
        height: 160px;
    }
    
    .documents-grid.view-list .doc-content-compact {
        padding: 12px;
    }
    
    .documents-grid.view-list .doc-title {
        font-size: 13px;
    }
}

/* Extra Small Devices - 360px */
@media (max-width: 360px) {
    .documents-library-wrapper {
        padding: 6px;
    }
    
    .filter-bar,
    .documents-main {
        padding: 12px 10px;
    }
    
    .library-title {
        font-size: 16px;
    }
    
    .doc-card {
        padding: 10px;
    }
    
    .doc-thumbnail {
        height: 180px;
    }
    
    .doc-title {
        font-size: 13px;
    }
    
    .doc-btn {
        padding: 6px 10px;
        font-size: 10px;
    }
    
    .category-item {
        padding: 8px 10px;
        font-size: 11px;
    }
}

