/* 
 * Video Browser - Complete Stylesheet
 * A comprehensive CSS file for the MP4 video browser application
 */

/* ========== BASIC LAYOUT & RESET ========== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: #f0f2f5;
    color: #333;
    padding-bottom: 2rem;
}

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

/* ========== HEADER & FOOTER ========== */
header {
    background-color: #1976d2;
    color: white;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
}

footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1rem;
    background-color: #e9ecef;
    border-radius: 4px;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.05);
    font-size: 0.9rem;
    color: #6c757d;
}

/* ========== BREADCRUMB NAVIGATION ========== */
.breadcrumbs {
    background-color: #e9ecef;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.breadcrumbs a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumbs a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* ========== CONTROLS (SORT & FILTER) ========== */
.controls-container {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Sort controls */
.sort-controls {
    display: inline-block;
}

.sort-controls label {
    margin-right: 0.5rem;
    font-weight: bold;
}

/* Filter controls */
.filter-controls {
    display: inline-block;
    margin-left: 2rem;
}

.filter-controls label {
    margin-right: 0.5rem;
    font-weight: bold;
}

/* Common styles for select dropdowns */
.sort-controls select,
.filter-controls select {
    padding: 0.375rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    background-color: white;
    font-size: 1rem;
    cursor: pointer;
    min-width: 180px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2rem;
}

.sort-controls select:focus,
.filter-controls select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ========== DIRECTORY & VIDEO GRIDS ========== */
.directory-grid, 
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.directory-item, 
.video-item {
    background-color: white;
    padding: 1rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.directory-item:hover, 
.video-item:hover {
    box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
    transform: translateY(-5px);
}

.directory-item a, 
.video-item a {
    color: #333;
    text-decoration: none;
    display: block;
}

/* ========== DIRECTORY ICONS ========== */
.fa-folder {
    font-size: 3rem;
    color: #ffc107;
    margin-bottom: 0.5rem;
    display: block;
}

/* ========== VIDEO THUMBNAILS ========== */
.thumbnail {
    width: 100%;
    height: auto;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: opacity 0.3s ease, transform 0.3s ease;
    aspect-ratio: 16/9;
    object-fit: cover;
    background-color: #f0f0f0;
}

.video-item:hover .thumbnail {
    opacity: 0.9;
}

/* Filename and info display */
.filename {
    font-weight: bold;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: block;
    max-width: 100%;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: #212529;
    line-height: 1.4;
}

.file-info {
    font-size: 0.8rem;
    color: #6c757d;
    display: block;
    margin-top: 0.25rem;
}

/* ========== LAZY LOADING STYLES ========== */
img.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img.lazy-load.loaded {
    opacity: 1;
}

/* Low-res placeholder styles */
.thumbnail-placeholder {
    background-color: #f0f0f0;
    display: block;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    position: relative;
}

.thumbnail-placeholder::before {
    content: '\f03d'; /* Font Awesome video icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    color: #ccc;
}

/* ========== HEADINGS & INFO DISPLAYS ========== */
h2 {
    margin: 1.5rem 0 1rem 0;
    color: #343a40;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
}

.video-count {
    margin-bottom: 1rem;
    color: #6c757d;
    font-style: italic;
}

.empty-message {
    text-align: center;
    padding: 2rem;
    background-color: #e9ecef;
    border-radius: 4px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    color: #6c757d;
    font-style: italic;
}

/* ========== ERROR MESSAGES ========== */
.error {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.error h2 {
    color: #721c24;
    border-bottom-color: #f5c6cb;
}

.error a {
    color: #721c24;
    text-decoration: underline;
}

/* ========== LOADING INDICATOR ========== */
.loading {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.loading:after {
    content: " ";
    display: block;
    border-radius: 50%;
    width: 0;
    height: 0;
    margin: 8px;
    box-sizing: border-box;
    border: 32px solid #1976d2;
    border-color: #1976d2 transparent #1976d2 transparent;
    animation: loading 1.2s infinite;
}

@keyframes loading {
    0% {
        transform: rotate(0);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
    }
    50% {
        transform: rotate(180deg);
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ========== BACK TO TOP BUTTON ========== */
#back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #1976d2;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 99;
    transition: background-color 0.3s, transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#back-to-top:hover {
    background-color: #1565c0;
    transform: translateY(-3px);
}

#back-to-top i {
    font-size: 1.2rem;
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 992px) {
    .directory-grid, 
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .controls-container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sort-controls,
    .filter-controls {
        display: block;
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    .filter-controls {
        margin-left: 0;
        margin-top: 0.75rem;
    }
    
    .sort-controls select,
    .filter-controls select {
        width: 100%;
    }
    
    .directory-grid, 
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    header {
        padding: 0.75rem;
    }
    
    .directory-grid, 
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }
    
    .directory-item, 
    .video-item {
        padding: 0.75rem;
    }
    
    .filename {
        font-size: 0.85rem;
    }
    
    .file-info {
        font-size: 0.7rem;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    body {
        background-color: white;
    }
    
    .container {
        max-width: 100%;
    }
    
    header, 
    footer, 
    .controls-container, 
    #back-to-top {
        display: none;
    }
    
    .directory-grid, 
    .video-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .directory-item, 
    .video-item {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* ------------------------------------------------------------------ */
/* Added with the Mojolicious rewrite: auth chrome, the sort/filter    */
/* form, and the inline SVG icons that replaced the Font Awesome CDN.  */
/* ------------------------------------------------------------------ */

.icon-sprite {
    display: none;
}

.icon {
    width: 1em;
    height: 1em;
    fill: currentColor;
    vertical-align: -0.125em;
}

/* Matches the old .fa-folder sizing so the directory grid is unchanged. */
.icon-folder {
    width: 3rem;
    height: 3rem;
    color: #ffc107;
    margin-bottom: 0.5rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Sign-out sits on the same line as the title, pushed to the right. The
   h1 already has margin:0 from the base header rule, so no vertical
   adjustment is needed. Without a session there is no form and the h1
   simply sits alone. */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: nowrap;      /* never let the button drop to its own line */
}

/* Let the title shrink rather than push the button down; min-width:0
   is what allows a flex item to shrink below its content width.
   (margin:0 already comes from the base `header h1` rule above.) */
header h1 {
    min-width: 0;
    flex: 0 1 auto;
}

/* The form keeps its natural size and never shrinks or wraps. */
.session-bar {
    margin: 0;
    flex: 0 0 auto;
}

/* Sits on the blue header bar, so it is outlined rather than solid grey --
   #6c757d on #1976d2 has almost no contrast. */
button.signout {
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    padding: 0.35rem 0.9rem;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}

button.signout:hover {
    background-color: rgba(255, 255, 255, 0.28);
}

/* Login card. */
.card {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

.login-card {
    max-width: 380px;
    margin: 2rem auto;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    padding: 0.55rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

.login-card button[type="submit"] {
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.6rem 1.4rem;
    font-size: 1rem;
    cursor: pointer;
}

.login-card button[type="submit"]:hover {
    background-color: #0069d9;
}

.hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #6c757d;
}

/* The sort/filter GET form replaced two <script> blocks. */
.controls-container {
    margin: 0;
}

.controls-container noscript button {
    margin-left: 0.75rem;
    padding: 0.4rem 1rem;
}

/* main.js toggles this on scroll. */
#back-to-top {
    display: none;
}
