/* ===================================
   Category Cards Styles
   =================================== */

.cm-category-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.cm-search-box {
    margin-bottom: 30px;
}

.cm-search-input {
    width: 100%;
    max-width: 500px;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
}

.cm-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.cm-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.cm-category-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.cm-category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border-color: #0073aa;
}

.cm-category-card-inner {
    padding: 25px;
}

.cm-category-title {
    margin: 0 0 15px 0;
    font-size: 22px;
    font-weight: 600;
}

.cm-category-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cm-category-title a:hover {
    color: #0073aa;
}

.cm-category-description {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
}

.cm-category-meta {
    margin: 15px 0;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.cm-post-count {
    font-size: 13px;
    color: #999;
    font-weight: 500;
}

.cm-view-category-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.cm-view-category-btn:hover {
    background: #005a87;
    color: #fff;
}

.cm-no-categories {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 18px;
}

/* ===================================
   Single Category Page Styles
   =================================== */

.cm-single-category-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.cm-category-header {
    margin-bottom: 40px;
    text-align: center;
}

.cm-category-page-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #333;
}

.cm-category-page-description {
    font-size: 16px;
    line-height: 1.8;
    color: #666;
    max-width: 800px;
    margin: 0 auto;
}

.cm-table-search-box {
    margin-bottom: 25px;
}

.cm-table-container {
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    -webkit-overflow-scrolling: touch;
}

.cm-posts-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.cm-posts-table thead {
    background: #f8f9fa;
}

.cm-posts-table th {
    padding: 18px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.cm-posts-table th.cm-sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.cm-posts-table th.cm-sortable:hover {
    background: #e9ecef;
}

.cm-sort-icon {
    margin-left: 8px;
    font-size: 12px;
    color: #999;
}

.cm-posts-table th.cm-sorted-asc .cm-sort-icon::after {
    content: '↑';
    color: #0073aa;
}

.cm-posts-table th.cm-sorted-desc .cm-sort-icon::after {
    content: '↓';
    color: #0073aa;
}

.cm-posts-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

.cm-posts-table tbody tr:hover {
    background: #f8f9fa;
}

.cm-posts-table td {
    padding: 18px 15px;
    font-size: 15px;
}

.cm-post-title a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    font-size: 18px;
    line-height: 1.4;
    transition: color 0.2s ease;
    display: block;
}

.cm-post-title a:hover {
    color: #0073aa;
}

.cm-post-year {
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.cm-download-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cm-download-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cm-btn-sinhala {
    background: #000;
    color: #fff;
}

.cm-btn-sinhala:hover {
    background: #333;
    color: #fff;
}

.cm-btn-english {
    background: #000;
    color: #fff;
}

.cm-btn-english:hover {
    background: #333;
    color: #fff;
}

.cm-no-downloads {
    color: #999;
    font-size: 13px;
    font-style: italic;
}

.cm-no-posts {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 18px;
}

/* ===================================
   Responsive Styles
   =================================== */

@media (max-width: 768px) {
    .cm-categories-grid {
        grid-template-columns: 1fr;
    }
    
    .cm-category-page-title {
        font-size: 28px;
    }
    
    /* Mobile-optimized table */
    .cm-table-container {
        border-radius: 8px;
        margin: 0 -10px;
    }
    
    .cm-posts-table {
        min-width: 100%;
        font-size: 14px;
    }
    
    .cm-posts-table th,
    .cm-posts-table td {
        padding: 12px 8px;
    }
    
    .cm-posts-table th {
        font-size: 11px;
        letter-spacing: 0.3px;
    }
    
    /* Make post titles wrap better on mobile */
    .cm-post-title a {
        font-size: 16px;
        line-height: 1.3;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Stack download buttons vertically on very small screens */
    .cm-download-buttons {
        flex-direction: column;
        gap: 6px;
    }
    
    .cm-download-btn {
        width: 100%;
        text-align: center;
        font-size: 12px;
        padding: 6px 12px;
    }
    
    /* Reduce padding on mobile */
    .cm-single-category-page,
    .cm-single-post-container {
        padding: 20px 10px;
    }
    
    /* Optimize year column */
    .cm-post-year {
        font-size: 14px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .cm-category-page-title {
        font-size: 24px;
    }
    
    .cm-post-title a {
        font-size: 15px;
    }
    
    .cm-posts-table th,
    .cm-posts-table td {
        padding: 10px 6px;
    }
    
    /* Hide year column label on very small screens, keep data */
    .cm-posts-table th:nth-child(2) {
        font-size: 10px;
    }
}

/* Tablet optimization */
@media (min-width: 769px) and (max-width: 1024px) {
    .cm-categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cm-post-title a {
        font-size: 17px;
    }
}

/* Hide rows that don't match search */
.cm-category-card.cm-hidden,
.cm-posts-table tbody tr.cm-hidden {
    display: none;
}

/* ===================================
   Single Post Page Styles
   =================================== */

.cm-single-post-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
}

.cm-single-post-container {
    max-width: 900px !important;
    margin: 0 auto !important;
    padding: 40px 20px !important;
    background: #fff;
}

.cm-post-header {
    margin-bottom: 30px !important;
    padding-bottom: 20px !important;
    border-bottom: 2px solid #e0e0e0 !important;
}

.cm-post-title {
    font-size: 36px !important;
    font-weight: 700 !important;
    margin: 0 0 20px 0 !important;
    color: #333 !important;
    line-height: 1.3 !important;
}

.cm-post-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    font-size: 14px !important;
    color: #666 !important;
}

.cm-post-meta span {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
}

.cm-post-meta strong {
    color: #333 !important;
}

.cm-post-meta a {
    color: #0073aa !important;
    text-decoration: none !important;
    transition: color 0.2s ease !important;
}

.cm-post-meta a:hover {
    color: #005a87 !important;
    text-decoration: underline !important;
}

.cm-post-content {
    font-size: 16px !important;
    line-height: 1.8 !important;
    color: #333 !important;
    margin-bottom: 40px !important;
}

.cm-post-content p {
    margin-bottom: 1.5em !important;
}

.cm-post-content h2,
.cm-post-content h3,
.cm-post-content h4 {
    margin-top: 1.5em !important;
    margin-bottom: 0.75em !important;
    color: #333 !important;
}

.cm-post-content img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 8px !important;
}

.cm-post-content ul,
.cm-post-content ol {
    margin-bottom: 1.5em !important;
    padding-left: 2em !important;
}

.cm-post-downloads-section {
    background: #f8f9fa !important;
    border-radius: 12px !important;
    padding: 30px !important;
    margin: 40px 0 !important;
    border: 2px solid #e0e0e0 !important;
}

.cm-downloads-heading {
    font-size: 22px !important;
    font-weight: 600 !important;
    margin: 0 0 20px 0 !important;
    color: #333 !important;
}

.cm-post-download-buttons {
    display: flex !important;
    gap: 15px !important;
    flex-wrap: wrap !important;
}

.cm-post-download-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 15px 30px !important;
    background: #000 !important;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    border: none !important;
}

.cm-post-download-btn:hover {
    background: #333 !important;
    color: #fff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

.cm-download-icon {
    flex-shrink: 0 !important;
}

/* ===================================
   Single Post Responsive Styles
   =================================== */

@media (max-width: 768px) {
    .cm-post-title {
        font-size: 28px !important;
    }
    
    .cm-post-meta {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .cm-post-download-buttons {
        flex-direction: column !important;
    }
    
    .cm-post-download-btn {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* ===================================
   Related Posts Section
   =================================== */

.cm-related-posts-section {
    margin-top: 60px !important;
    padding-top: 40px !important;
    border-top: 3px solid #e0e0e0 !important;
}

.cm-related-posts-heading {
    font-size: 28px !important;
    font-weight: 700 !important;
    margin: 0 0 30px 0 !important;
    color: #333 !important;
    text-align: center !important;
}
