/* --- Global Styles & Variables --- */
:root {
    --bg-color: #121212;
    --primary-surface-color: #1e1e1e;
    --secondary-surface-color: #2a2a2a;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #a0a0a0;
    --accent-color: #4a90e2;
    --accent-color-hover: #5aa1f2;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

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

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

#app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* --- Header & Search --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

#header-title {
    font-size: 2rem;
    font-weight: 700;
}

#search-container {
    flex-grow: 1;
    max-width: 400px;
}

#search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--secondary-surface-color);
    color: var(--primary-text-color);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

/* --- View Headers & Controls --- */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.view-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-right: auto; /* Pushes controls to the right */
}

#back-button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--primary-text-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease;
    flex-shrink: 0;
}

#back-button:hover {
    background-color: var(--secondary-surface-color);
    color: var(--accent-color-hover);
}

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

.sort-controls label {
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}

#sort-select {
    background-color: var(--secondary-surface-color);
    color: var(--primary-text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 0.9rem;
    outline: none;
}

.page-description {
    text-align: center;
    color: var(--secondary-text-color);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto 3rem auto;
    line-height: 1.7;
}

/* --- Grid & Card Layout --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.folder-item,
.file-item {
    background-color: var(--primary-surface-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Ensures preview image corners are clipped */
}

.folder-item:hover,
.file-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow-color);
    border-color: var(--accent-color);
}

/* --- Folder Item Specifics --- */
.folder-item {
    padding: 1.5rem;
    align-items: center;
    text-align: center;
    cursor: pointer;
}

.folder-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    fill: var(--accent-color);
}

.folder-item-name {
    font-size: 1.1rem;
    font-weight: 600;
}

/* --- File Item Specifics --- */
.file-item-preview {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background-color: var(--secondary-surface-color);
}

.file-item-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allows footer to stick to bottom */
}

.file-item-caption {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    min-height: 3.2em; /* Aligns content below by reserving space for ~2 lines */
}

.file-item-content a {
    display: inline-block;
    text-decoration: none;
    background-color: var(--accent-color);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    margin-bottom: 1.25rem;
    transition: background-color 0.3s ease;
    align-self: flex-start; /* Ensure button doesn't stretch */
}

.file-item-content a:hover {
    background-color: var(--accent-color-hover);
}

.file-item-tags {
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background-color: var(--secondary-surface-color);
    color: var(--secondary-text-color);
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.tag:hover {
    background-color: var(--accent-color);
    color: white;
}

.file-item-meta {
    margin-top: auto; /* Pushes meta info to the bottom */
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copy-link-btn {
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    line-height: 0; /* Prevents container from stretching */
}

.copy-link-btn:hover {
    background-color: var(--secondary-surface-color);
}

.copy-link-btn svg {
    width: 16px;
    height: 16px;
    fill: var(--secondary-text-color);
    vertical-align: middle;
}

.portfolio-link {
    text-align: center;
    margin-top: 3rem;
    color: var(--secondary-text-color);
    font-size: 1rem;
}

.portfolio-link a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.portfolio-link a:hover {
    text-decoration: underline;
}

/* --- Utility & Footer --- */
#scroll-to-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 45px;
    height: 45px;
    background-color: var(--secondary-surface-color);
    border: 1px solid var(--border-color);
    color: var(--primary-text-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    text-decoration: none;
    cursor: pointer;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}

#scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scroll-to-top:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.hidden {
    display: none !important;
}

#no-results-message {
    text-align: center;
    margin-top: 2rem;
    color: var(--secondary-text-color);
    font-size: 1.1rem;
}

footer {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.footer-nav {
    order: 1;
}

#footer-home-button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--primary-text-color);
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#footer-home-button:hover {
    background-color: var(--accent-color);
    color: white;
}

.social-links {
    order: 2;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.social-links a {
    color: var(--secondary-text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--accent-color-hover);
}

.copyright {
    order: 3;
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}


/* --- Responsive Design --- */
@media (max-width: 480px) {
    #app-container {
        padding: 1.5rem 1rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    #header-title {
        font-size: 1.8rem;
    }

    #search-container {
        width: 100%;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .view-header h2 {
        margin-right: 0;
    }

    #controls-container {
        width: 100%;
        display: flex;
        justify-content: flex-start;
    }
    
    .grid-container {
        gap: 1rem;
    }

    .page-description {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .portfolio-link {
        margin-top: 2rem;
        font-size: 0.9rem;
    }

    footer {
        margin-top: 3rem;
    }

    #scroll-to-top {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        right: 15px;
        bottom: 15px;
    }
}