/* Fixed class selector typo (.file-grid) */
.file-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 12px; 
    padding: 16px; 
    align-items: start; 
    transition: background-color 0.2s ease, border-color 0.2s ease; 
    border: 2px dashed transparent; 
    margin: 4px; 
    border-radius: 8px; 
    isolation: isolate; 
} 

.file-card { 
    background: #ffffff; 
    border: 1px solid #e2e8f0; 
    border-radius: 8px; 
    padding: 8px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: space-between; /* Pushes card-size to the bottom evenly */
    position: relative; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    min-width: 0; 
    width: 100%; 
    height: 100%; /* Stretch evenly across grid row */
    box-sizing: border-box;
    cursor: grab; 
}

.thumbnail-box { 
    width: 100%; 
    aspect-ratio: 16 / 9; 
    background: #f1f5f9; 
    border-radius: 6px; 
    overflow: hidden; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    margin-bottom: 6px; 
    position: relative; 
} 

/* Ensures links & icons lock to the fixed box dimensions */
.thumbnail-box .thumbnail-link {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.thumbnail-box img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    object-position: center; 
    display: block; 
    pointer-events: none; 
} 

.thumbnail-box .generic-icon { 
    font-size: 2rem; 
    line-height: 1; 
} 

.card-details { 
    width: 100%; 
    min-width: 0; 
    display: flex;
    flex-direction: column;
    align-items: center;
} 

.card-name-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
    gap: 4px;
    /* Lock the height to exactly 2 lines of text so 1-line cards don't collapse */
    min-height: 2.5em; 
}

.file-card .card-name { 
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 0.82rem; 
    font-weight: 600; 
    color: #0f172a; 
    text-decoration: none; 
    overflow: hidden; 
    word-break: break-word;
    text-align: left;
    flex: 1;
    min-width: 0;
    line-height: 1.25em; /* Explicit line-height for precise 2-line height calculation */
}

.card-size { 
    font-size: 0.72rem; 
    color: #64748b; 
    margin-top: 2px; 
    text-align: center;
    width: 100%;
} 

.file-card .action-col { 
    position: relative; 
    z-index: 10; 
    flex-shrink: 0;
    margin-top: -2px;
} 

.btn-three-dots { 
    background: transparent; 
    border: none; 
    color: #475569; 
    font-size: 1rem; 
    padding: 1px 3px; 
    border-radius: 4px; 
    cursor: pointer; 
    line-height: 1;
} 

.btn-three-dots:hover { 
    background: #f1f5f9; 
    color: #0f172a; 
}

.dropdown-menu { 
    display: none; 
    position: absolute; 
    right: 0; 
    top: 100%; 
    margin-top: 4px; 
    background: #ffffff; 
    border: 1px solid #cbd5e1; 
    border-radius: 6px; 
    box-shadow: 0 6px 18px rgba(0,0,0,0.18); 
    z-index: 1000; 
    min-width: 140px; 
} 
.dropdown-menu.active { display: block; } 
.dropdown-item { 
    display: block; 
    width: 100%; 
    padding: 8px 12px; 
    font-size: 0.8rem; 
    background: none; 
    border: none; 
    color: #334155; 
    cursor: pointer; 
    text-align: left; 
    text-decoration: none; 
    box-sizing: border-box; 
} 
.dropdown-item:hover { background: #f1f5f9; } 
.dropdown-item.delete-item { color: #dc2626; } 
.dropdown-item.delete-item:hover { background: #fee2e2; } 

@media (max-width: 480px) { 
    .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; } 
    .file-card { padding: 8px; } 
    .file-card .card-name { font-size: 0.8rem; } 
    .btn-three-dots { min-width: 42px; min-height: 42px; font-size: 1.6rem; display: flex; align-items: center; justify-content: center; padding: 0; } 
    .file-card .dropdown-menu { min-width: 170px; right: 0; top: 46px; box-shadow: 0 6px 16px rgba(0,0,0,0.2); } 
    .dropdown-item { padding: 12px 16px; font-size: 1.2rem; } 
}