@import url('https://fonts.googleapis.com/css2?family=PT+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
    --font1: 'PT Sans', sans-serif;
}

/* General styles */
body {
    font-family: var(--font1);
    background-color: #f4f7f6;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin: 30px auto;
    padding: 30px;
    max-width: 1200px;
    width: 95%;
}

.header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
}

.header .icon {
    font-size: 2.5rem;
    color: #007bff;
    margin-right: 15px;
}

.header h1 {
    font-size: 1.8rem;
    color: #333;
    margin: 0;
}

.subheader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.file-count {
    font-size: 0.95rem;
    color: #555;
}

.view-toggle button {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #888;
    cursor: pointer;
    margin-left: 10px;
    transition: color 0.2s ease;
}

.view-toggle button:hover,
.view-toggle button.active {
    color: #007bff;
}

/* Grid View */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.file-card {
    background-color: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.2s ease;
}

.file-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-3px);
}

.file-card .file-icon {
    font-size: 3.5rem;
    margin-bottom: 15px;
    color: #6c757d; /* Default icon color */
}

.file-card .file-name {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    word-break: break-word;
}

.file-card .file-size {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 15px;
}

.file-card .actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.file-card .actions button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
    margin: 0 5px;
}

.file-card .actions button:hover {
    background-color: #0056b3;
}

.file-card .actions button.open-btn {
    background-color: #28a745; /* Green for open */
}

.file-card .actions button.open-btn:hover {
    background-color: #218838;
}

/* List View */
.list-view {
    display: none; /* Hidden by default, controlled by JS */
    flex-direction: column;
    margin-top: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden; /* Ensures rounded corners apply to children */
}

.list-view-header {
    display: grid;
    grid-template-columns: 2.5fr 1fr 0.8fr 1.2fr 1.2fr; /* Adjust column widths as needed */
    background-color: #f8f9fa;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 0.9rem;
    color: #555;
    text-transform: uppercase;
}

.list-view-header .list-header-item:last-child {
    text-align: right; /* Align download header to the right */
}

.list-view-item {
    display: grid;
    grid-template-columns: 2.5fr 1fr 0.8fr 1.2fr 1.2fr; /* Match header columns */
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    background-color: #ffffff;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.list-view-item:last-child {
    border-bottom: none; /* No border for the last item */
}

.list-view-item:hover {
    background-color: #f1f1f1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.list-item-cell {
    display: flex;
    align-items: center;
    color: #333;
    font-size: 0.95rem;
}

.list-item-cell.file-size,
.list-item-cell.file-type,
.list-item-cell.file-modified {
    color: #777;
    font-size: 0.9rem;
}

.list-item-cell.actions {
    justify-content: flex-end; /* Align buttons to the right */
    gap: 8px;
}

.list-view .file-list-icon {
    font-size: 1.3rem;
    margin-right: 12px;
    vertical-align: middle;
}

.list-view .file-name {
    font-weight: 500;
    color: #333;
    word-break: break-word;
}

.list-view .actions button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 7px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
    white-space: nowrap; /* Prevent button text from wrapping */
}

.list-view .actions button:hover {
    background-color: #0056b3;
}

.list-view .actions button.open-btn {
    background-color: #28a745; /* Green for open */
}

.list-view .actions button.open-btn:hover {
    background-color: #218838;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.pagination span {
    font-size: 0.9rem;
    color: #555;
    margin-right: 15px;
}

.pagination button {
    background: none;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    color: #555;
    font-size: 0.9rem;
    margin-left: 5px;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    background-color: #e9ecef;
    border-color: #adadad;
}

.pagination button.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Specific icon colors */
.icon-pdf { color: #dc3545; } /* Red */
.icon-word { color: #007bff; } /* Blue */
.icon-video { color: #ffc107; } /* Yellow/Orange */
.icon-audio { color: #6f42c1; } /* Purple */
.icon-csv { color: #28a745; } /* Green */
.icon-default { color: #6c757d; } /* Grey */
.icon-link { color: #4B70F5; } /* Tint blue */

/* PDF Viewer Modal */
.pdf-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.pdf-modal.show {
    opacity: 1;
    visibility: visible;
}

.pdf-modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.pdf-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}

.pdf-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.pdf-modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #555;
    cursor: pointer;
    transition: color 0.2s ease;
}

.pdf-modal-close:hover {
    color: #000;
}

.pdf-modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pdf-modal-body .pdf-page {
    margin-bottom: 25px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.pdf-modal-body .pdf-page canvas {
    display: block;
}

.pdf-modal-body .placeholder {
    color: #999;
    font-size: 16px;
    padding: 40px;
    text-align: center;
    margin: auto;
}

footer {
    position: relative;
    text-align: center;
    padding: 15px 0;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #021526; /* Dark background */
    color: #e0e0e0; /* Light text for readability */
}

body.dark-mode .container {
    background-color: #1a2a3a; /* Darker container background */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .header {
    border-bottom-color: #334455;
}

body.dark-mode .header .icon {
    color: #6bb3ff; /* Lighter blue for dark mode */
}

body.dark-mode .header h1 {
    color: #e0e0e0;
}

body.dark-mode .subheader {
    border-bottom-color: #334455;
}

body.dark-mode .file-count {
    color: #b0b0b0;
}

body.dark-mode .view-toggle button {
    color: #b0b0b0;
}

body.dark-mode .view-toggle button:hover,
body.dark-mode .view-toggle button.active {
    color: #6bb3ff;
}

body.dark-mode #dark-mode-toggle {
    color: #e0e0e0; /* Ensure moon/sun icon is visible */
}

body.dark-mode .file-card {
    background-color: #2a3b4c;
    border-color: #334455;
}

body.dark-mode .file-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}


body.dark-mode .file-card .file-name {
    color: #e0e0e0;
}

body.dark-mode .file-card .file-size {
    color: #b0b0b0;
}

body.dark-mode .list-view {
    border-color: #334455;
}

body.dark-mode .list-view-header {
    background-color: #2a3b4c;
    color: #e0e0e0;
    border-bottom-color: #334455;
}

body.dark-mode .list-view-item {
    background-color: #1a2a3a;
    border-bottom-color: #334455;
}

body.dark-mode .list-view-item:hover {
    background-color: #3a4b5c;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.dark-mode .list-item-cell {
    color: #e0e0e0;
}

body.dark-mode .list-item-cell.file-size,
body.dark-mode .list-item-cell.file-type,
body.dark-mode .list-item-cell.file-modified {
    color: #b0b0b0;
}


body.dark-mode .list-view .file-name {
    color: #e0e0e0;
}

body.dark-mode .list-view .file-size,
body.dark-mode .list-view .file-type,
body.dark-mode .list-view .file-modified {
    color: #b0b0b0;
}

body.dark-mode .pagination {
    border-top-color: #334455;
}

body.dark-mode .pagination span {
    color: #b0b0b0;
}

body.dark-mode .pagination button {
    background-color: #2a3b4c;
    border-color: #334455;
    color: #e0e0e0;
}

body.dark-mode .pagination button:hover:not(:disabled) {
    background-color: #3a4b5c;
    border-color: #445566;
}

body.dark-mode .pagination button.active {
    background-color: #007bff; /* Keep primary color for active */
    border-color: #007bff;
    color: white;
}

body.dark-mode .pdf-modal-content {
    background: #1a2a3a;
}

body.dark-mode .pdf-modal-header {
    background-color: #2a3b4c;
    border-bottom-color: #334455;
}

body.dark-mode .pdf-modal-header h2 {
    color: #e0e0e0;
}

body.dark-mode .pdf-modal-close {
    color: #b0b0b0;
}

body.dark-mode .pdf-modal-close:hover {
    color: #e0e0e0;
}

body.dark-mode .pdf-modal-body .placeholder {
    color: #777;
}

/* Responsive adjustments for List View */
@media (max-width: 992px) {
    .list-view-header,
    .list-view-item {
        grid-template-columns: 2fr 1fr 0.8fr 1fr 1.2fr; /* Adjust columns for medium screens */
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 20px auto;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .subheader {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .list-view-header,
    .list-view-item {
        grid-template-columns: 2fr 1fr 1fr; /* File, Size, Download */
        gap: 10px;
    }

    .list-view-header .list-header-item:nth-child(3), /* Type */
    .list-view-item .list-item-cell.file-type,
    .list-view-header .list-header-item:nth-child(4), /* Last Modified */
    .list-view-item .list-item-cell.file-modified {
        display: none; /* Hide Type and Last Modified on smaller screens */
    }

    .list-item-cell.actions {
        justify-content: center;
        flex-wrap: wrap;
    }

    .list-view .actions button {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .header .back-to-dashboard-icon {
        margin-right: 0;
    }

    .header .icon {
        font-size: 2rem;
    }

    .header h1 {
        font-size: 1.2rem;
    }

    .list-view-header,
    .list-view-item {
        grid-template-columns: 1.5fr 1fr; /* File, Download */
    }

    .list-view-header .list-header-item:nth-child(2), /* Size */
    .list-view-item .list-item-cell.file-size {
        display: none; /* Hide Size on very small screens */
    }

    .list-item-cell.actions {
        flex-direction: column;
        align-items: flex-end;
        gap: 5px;
    }

    .list-view .actions button {
        width: 100%;
        text-align: center;
    }

    .pagination {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .pagination span {
        margin-right: 0;
    }
}
