/* FOLDER CONTENTS - 12 - folder-contents.css */


/* Folder Management Layout */
.preferences-container {
    width: 100%;
    margin: 0;
    padding: 24px;
    gap: 0px;
    display: flex;
    max-height: calc(100vh - 120px);
    overflow: hidden;
}

.preferences-sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.folder-management-layout {
    display: flex;
    gap: 40px;
    width: 100%;
    align-items: flex-start;
}

.folder-contents-pane {
    width: 70%;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 100%;
    overflow: hidden;
}

.folder-management-layout .card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 4px var(--shadow);
}

.folder-management-layout .card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
}

.preferences-sidebar nav {
    display: flex;
    flex-direction: column;
}

.nav-spacer {
    flex: 1;
}

.preferences-sidebar .nav-item:last-child {
    margin-bottom: 0;
    color: #e53e3e;
}

.preferences-sidebar .nav-item:last-child:hover {
    background-color: rgba(229, 62, 62, 0.1);
}

.folder-management-layout .card-body {
    padding: 25px;
}

.folder-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    padding: 15px 20px;
}

.card-header h2 {
    margin: 0;
}

/* View Controls */
.view-controls {
    display: flex;
    gap: 5px;
    margin-right: 1rem;
}


.sort-controls {
    display: flex;
    gap: 10px;
}

.sort-controls select {
    width: auto;
}

/* Folder Contents Base - Add smooth transition for loading states */
#folderContents {
    transition: opacity 0.2s ease-in-out;
}

/* List View */
#folderContents.list-view {
    width: 100%;
}

#folderContents.list-view table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

#folderContents.list-view th,
#folderContents.list-view td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

#folderContents.list-view th {
    font-weight: bold;
    background-color: var(--table-header);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Light mode: ensure folder contents headers match search/auction styling */
:root #folderContents.list-view th {
    background-color: var(--primary);
    color: white;
}

/* Dark mode: use dark header background */
[data-theme="dark"] #folderContents.list-view th {
    background-color: var(--table-header);
    color: white;
}

#folderContents.list-view .checkbox-col {
    width: 40px;
    text-align: center;
    padding: 0 5px;
}

/* Fix: Make select-all checkbox same size as item checkboxes */
#folderContents.list-view .select-all {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

#folderContents.list-view .desc-col {
    width: 55%;
}

#folderContents.list-view .price-col {
    width: 18%;
    text-align: right;
}

#folderContents.list-view .date-col {
    width: 15%;
    padding-right: 8px;
}

#folderContents.list-view .action-col {
    width: 28px;
    text-align: center;
    padding: 12px 4px 12px 4px;
}

#folderContents.list-view tr:hover {
    background: var(--hover-bg);
}

.item-details h4 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text);
    line-height: 1.3;
}

.item-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text);
    padding: 5px 0;
}

.item-meta {
    color: var(--text);
    opacity: 0.9;
    font-size: 1rem;
}

.item-description {
    color: var(--text);
    line-height: 1.5;
    margin-top: 5px;
}

.item-actions {
    margin-top: 15px;
}

/* Grid View */
#folderContents.grid-view {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Add space after last grid item to prevent cutoff */
#folderContents.grid-view::after {
    content: '';
    display: block;
    height: 30px;
    flex-shrink: 0;
}

#folderContents.grid-view .item {
    display: grid !important;
    grid-template-columns: 40px 100px 1fr !important;
    flex-direction: unset !important;
    gap: 8px;
    align-items: start;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px;
    background: var(--card-bg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

#folderContents.grid-view .item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#folderContents.grid-view .checkbox-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
}

#folderContents.grid-view .item-image {
    width: 100px;
    height: 100px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

#folderContents.grid-view .item-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: transparent;
    display: block;
    margin-bottom: 0 !important;
}

#folderContents.grid-view .item-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 4px;
}

#folderContents.grid-view .item-details h4 {
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    margin: 0 !important;
    line-height: 1.4 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

#folderContents.grid-view .item-price {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0;
    margin: 0;
}

#folderContents.grid-view .item-meta {
    font-size: 0.85rem;
    margin: 0;
}

/* Common Item Styles */
.item h4 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    color: var(--text);
}

.item p {
    margin: 5px 0;
    color: var(--text);
    opacity: 0.8;
    color: var(--text);
}

.item .btn {
    margin-top: auto;
    align-self: flex-start;
    color: var(--text);
}

/* Folder Contents Layout */
#folderContents {
    padding: 20px;
    padding-top: 0; /* No extra padding needed since parent container handles spacing */
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    min-height: 0;
}

#folderContents::-webkit-scrollbar {
    width: 6px;
}

#folderContents::-webkit-scrollbar-track {
    background: transparent;
}

#folderContents::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

/* Ensure folder list header stays static */
.folder-list-pane > .folder-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* Folder contents header should also be static */
.folder-contents-pane > .folder-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
}

.folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 15px 20px;
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Folder sort dropdown - matches search.php styling */
.folder-sort {
    display: flex;
    align-items: center;
    gap: 4px;
}

.folder-sort select {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 150px;
    transition: all 0.2s ease;
}

.folder-sort select:hover {
    border-color: var(--primary);
}

.folder-sort select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.sort-dir-btn {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sort-dir-btn:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.sort-dir-btn.asc {
    transform: rotate(180deg);
}

.sort-dir-btn.asc:hover {
    transform: rotate(180deg) scale(1.1);
}

/* Loading Indicator */
#loadingIndicator {
    padding: 2rem;
}

/* Print Styles */
@media print {
    .modal-dialog {
        max-width: none;
        margin: 0;
    }
    
    .modal-content {
        border: none;
        box-shadow: none;
    }
    
    .view-controls,
    .sort-controls,
    .modal-footer,
    .btn-close {
        display: none !important;
    }
    
    .list-view .item,
    .grid-view .item {
        break-inside: avoid;
    }
}

/* Override preferences-content styles for folders section */
.preferences-content {
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

#folders.section {
    margin: 0;
    padding: 0;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.folder-management-layout {
    width: 100%;
    margin: 0;
    padding: 0;
    flex: 1;
    display: flex;
    overflow: hidden;
}

.two-pane-layout {
    display: flex;
    gap: 10px;
    flex: 1;
    overflow: hidden;
    max-height: 100%;
}

/* Folder List Pane - with scrolling */
.folder-list-pane {
    width: 30%;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 100%;
    overflow: hidden;
}

.folder-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    padding-top: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    min-height: 0;
}

.folder-list::-webkit-scrollbar {
    width: 6px;
}

.folder-list::-webkit-scrollbar-track {
    background: transparent;
}

.folder-list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

/* Folder Item Styles */
.folder-item {
    margin-bottom: 5px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.folder-item .folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.folder-item .folder-header:hover {
    background: var(--hover-bg);
}

.folder-item .folder-header.active {
    background: var(--primary);
    color: white;
}

.folder-item .folder-header.active .folder-name-wrapper {
    color: white;
}

.folder-item .folder-header.active svg {
    stroke: white;
}

/* Folder item count row - contains count and filter */
.folder-item-count-row {
    padding: 12px 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: none; /* Hidden by default */
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.folder-item-count-row.active {
    display: flex;
}

.folder-item-count-display {
    font-size: 14px;
    color: var(--text-secondary);
    flex: 0 0 auto;
}

.folder-item-count-display strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Filter controls on the right side */
.folder-filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.folder-filter-input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    border-radius: 4px;
    font-size: 14px;
    min-width: 250px;
    transition: all 0.2s ease;
}

.folder-filter-input:hover {
    border-color: var(--primary);
}

.folder-filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.folder-filter-input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Clear filter button */
.clear-filter-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.clear-filter-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #e53e3e;
}

.clear-filter-btn svg {
    width: 16px;
    height: 16px;
}

.folder-checkbox {
    flex-shrink: 0;
    cursor: pointer;
    width: 16px;
    height: 16px;
    margin: 0;
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; /* Critical for text truncation */
    cursor: pointer;
}

.folder-info svg {
    flex-shrink: 0;
    stroke: currentColor;
}

.folder-name-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}

.folder-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.folder-count {
    flex-shrink: 0;
    color: var(--text-muted);
    font-weight: normal;
    white-space: nowrap;
}

.folder-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}


.icon-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
}

.folder-item:hover .icon-btn,
.folder-header.active .icon-btn {
    opacity: 1;
}

/* Always show buttons for archived folders */
.folder-item.archived-folder .icon-btn {
    opacity: 1;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn.edit-btn:hover {
    background: rgba(59, 130, 246, 0.1);
}

.icon-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Image Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.image-modal.active {
    display: flex;
}

.image-modal-content {
    max-height: 90vh;
    max-width: 90vw;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.nav-button {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    transition: background-color 0.2s ease;
}

.nav-button:hover {
    background: rgba(0, 0, 0, 0.8);
}

.prev-button {
    left: 30px;
}

.next-button {
    right: 30px;
}

.close-button {
    position: fixed;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    transition: background-color 0.2s ease;
}

.close-button:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Thumbnail hover effect */
.item-image {
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.item-image img {
    transition: transform 0.3s ease;
}

.item-image:hover img {
    transform: scale(1.1);
}

/* Loading state */
.image-modal-content.loading {
    opacity: 0.5;
}

/* Empty state */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 1.1em;
    text-align: center;
    background: var(--card-bg);
    border-radius: 8px;
    margin: 20px;
    border: 1px dashed var(--border);
}

/* Error state */
.alert {
    padding: 20px;
    border-radius: 8px;
    margin: 20px;
}

.alert-danger {
    background: rgba(229, 62, 62, 0.1);
    border: 1px solid rgba(229, 62, 62, 0.3);
    color: var(--text);
}

.alert strong {
    display: block;
    margin-bottom: 8px;
    color: #e53e3e;
}

.alert p {
    margin: 0 0 12px 0;
    opacity: 0.9;
}

.btn-danger {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-danger:hover {
    background: #c53030;
}

.mt-2 {
    margin-top: 8px;
}

/* Delete Button Styling */
.delete-item-btn {
    background: transparent;
    border: none;
    color: #e53e3e;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.delete-item-btn:hover {
    background: rgba(229, 62, 62, 0.1);
    transform: scale(1.1);
}

.delete-item-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.delete-item-btn svg {
    width: 16px;
    height: 16px;
}

/* Grid view item actions - hidden, using checkboxes for selection/deletion */
#folderContents.grid-view .item {
    position: relative;
}

#folderContents.grid-view .item-actions {
    display: none;
}

/* Bulk delete button styling - positioned far right for safety */
.bulk-delete-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    margin-left: auto; /* Push to far right */
}

.bulk-delete-btn:hover {
    background: #c53030;
    transform: translateY(-1px);
}

.bulk-delete-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.bulk-delete-btn svg {
    width: 16px;
    height: 16px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #folderContents.list-view .desc-col {
        width: 52%;
    }
    
    #folderContents.list-view .price-col {
        width: 18%;
    }
    
    #folderContents.list-view .date-col {
        width: 15%;
        padding-right: 4px;
    }
    
    #folderContents.list-view .action-col {
        width: 28px;
        padding: 12px 2px 12px 2px;
    }
    
    .delete-item-btn {
        width: 24px;
        height: 24px;
        padding: 2px;
    }
    
    .delete-item-btn svg {
        width: 12px;
        height: 12px;
    }
    
    #folderContents.grid-view .item-actions {
        top: 4px;
        right: 4px;
        padding: 2px;
    }
    
    .bulk-delete-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Grid Select All Button Styling */
.grid-select-all-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
}

.grid-select-all-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary);
}

/* Light mode styling */
:root .grid-select-all-btn {
    background: var(--card-bg);
    color: var(--text);
    border-color: var(--border);
}

:root .grid-select-all-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary);
}

/* Dark mode styling */
[data-theme="dark"] .grid-select-all-btn {
    background: var(--card-bg);
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .grid-select-all-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary);
}