/* ============================= */
/* GLOBAL RESET & VARIABLES      */
/* ============================= */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-hover: #15803d;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

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

.top-nav {
    text-align: left;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 0px;
}

.brand-link {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.brand-link:hover {
    color: #ffffff;
}

/* ============================= */
/* HEADER & FOOTER               */
/* ============================= */
.site-header {
    background: #1e293b;
    color: white;
    padding: 10px 10px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.nav-hidden {
    transform: translateY(-100%);
}

.site-header h1 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.site-header p {
    color: #cbd5e1;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 0.8rem;
}

.badge-light {
    background: rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

.site-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 40px;
}

/* ============================= */
/* CONTROLS (SEARCH & FILTERS)   */
/* ============================= */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.controls input, .controls select {
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.controls input {
    width: 100%;
    min-width: 250px;
}

.controls input:focus, .controls select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-wrapper {
    display: flex;
    gap: 10px;
}

/* ============================= */
/* TABLE DESKTOP VIEW            */
/* ============================= */
.table-container {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

#downloadTable {
    width: 100%;
    border-collapse: collapse;
}

#downloadTable th, #downloadTable td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

#downloadTable th {
    background: #f1f5f9;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#downloadTable tbody tr {
    transition: background 0.2s;
    animation: fadeSlide 0.4s ease forwards;
    opacity: 0;
}

#downloadTable tbody tr:hover {
    background: #f8fafc;
}

.file-title { font-weight: 600; color: var(--text-main); }
.file-desc { font-size: 0.85rem; color: var(--text-muted); display: block; margin-top: 4px; }
.file-meta { font-size: 0.85rem; color: var(--text-muted); }
.new-badge {
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: bold;
}
.cat-badge {
    background: #e0e7ff;
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

.text-center { text-align: center !important; }

.td-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.title-row {
    display: flex;
    align-items: center;
}

/* Download Button */
.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px; 
    padding: 8px 16px;
    width: auto;
    height: auto;
    background: var(--success);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.download-btn:hover {
    background: var(--success-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(22, 163, 74, 0.2);
}

.download-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ============================= */
/* PAGINATION                    */
/* ============================= */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination button:hover, .pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===========================
   LOADING SPINNER
=========================== */
.loader-container {
    text-align: center;
    padding: 50px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================= */
/* MOBILE VIEW (COMPACT CARDS)   */
/* ============================= */
@media (max-width: 768px) {
    .controls { flex-direction: column; align-items: stretch; }
    .filter-wrapper { display: flex; flex-direction: column; }
    .table-container { background: transparent; box-shadow: none; padding: 0; }
    
    #downloadTable thead { display: none; }
    
    #downloadTable, #downloadTable tbody, #downloadTable tr, #downloadTable td {
        display: block;
        width: 100%;
    }

    #downloadTable tr {
        background: var(--card-bg);
        margin-bottom: 12px;
        border-radius: 10px;
        padding: 16px;
        border: 1px solid var(--border);
        box-shadow: 0 2px 4px rgba(0,0,0,0.02);
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    #downloadTable td { border: none; padding: 0; }
    
    .td-no { display: none !important; } 
    .td-title { width: 100%; margin-bottom: 8px; }
    
    /* Hide the Category (3) and Size (5) columns on mobile to keep it clean */
    #downloadTable td:nth-child(3),
    #downloadTable td:nth-child(5) { 
        display: none; 
    } 

    /* Target the Date cell */
    #downloadTable td:nth-child(4) {
        border-top: 1px dashed var(--border);
        padding-top: 16px !important;
        margin-top: 8px;
        width: 50%;
        text-align: left;
    }

    /* Target the Action Button cell */
    #downloadTable td:nth-child(6) {
        border-top: 1px dashed var(--border);
        padding-top: 16px !important;
        margin-top: 8px;
        width: 50%;
        text-align: right;
    }
}
