/* Library View Styles
 * Extracted from library.html for modularity
 */

/* ==========================================================================
   Base & Layout
   ========================================================================== */

body {
    overflow: auto;
    padding: 0;
}

/* ==========================================================================
   Header
   ========================================================================== */

.manage-header {
    padding: 24px;
    border-bottom: 1px solid #000000;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.manage-header-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.manage-header h1 {
    font-size: 24px;
    font-weight: 300;
    margin: 0;
}

.manage-header .back-link {
    font-size: 12px;
    color: #666;
    text-decoration: none;
}

.manage-header .back-link:hover {
    color: #000000;
}

.select-mode-button {
    padding: 8px 16px;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.select-mode-button:hover {
    background: #f5f5f5;
}

.select-mode-button.active {
    background: #000000;
    color: #ffffff;
}

/* ==========================================================================
   Image Grid
   ========================================================================== */

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2px;
    padding: 2px;
}

@media (max-width: 768px) {
    .images-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.image-item {
    aspect-ratio: 1;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
    border: 3px solid transparent;
    transition: border-color 0.2s;
}

.select-mode-active .image-item {
    cursor: pointer;
}

.image-item.selected {
    border-color: #0066ff;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
    opacity: 0;
    transition: opacity 0.3s;
}

.image-item img.loaded {
    opacity: 1;
}

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

/* ==========================================================================
   Selection Box (drag selection)
   ========================================================================== */

.selection-box {
    position: fixed;
    border: 2px solid #0066ff;
    background: rgba(0, 102, 255, 0.1);
    pointer-events: none;
    z-index: 1000;
    display: none;
}

.selection-box.active {
    display: block;
}

/* ==========================================================================
   Feed View (full-screen image viewer)
   ========================================================================== */

.feed-view {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

.feed-view.active {
    display: block;
}

.feed-item {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    position: relative;
}

.feed-item-container {
    border: 1px solid #000000;
    background: #ffffff;
    display: inline-block;
}

.feed-item img {
    max-width: 100%;
    max-height: calc(100vh - 80px);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    position: relative;
}

.feed-item-image-wrapper {
    position: relative;
    display: block;
    max-width: 100%;
}

.feed-item-footer {
    height: 32px;
    background: #ffffff;
    border-top: 1px solid #000000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-family: monospace;
    font-size: 14px;
}

.feed-item-footer-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    color: #000000;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: monospace;
}

.feed-item-footer-button:hover {
    opacity: 0.6;
}

.feed-item-footer-button span {
    font-size: 12px;
}

/* ==========================================================================
   Feed Controls
   ========================================================================== */

.feed-controls {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    pointer-events: none;
}

.feed-controls .close-button {
    pointer-events: all;
    width: 40px;
    height: 40px;
    border: 1px solid #ffffff;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

/* ==========================================================================
   Actions Menu (feed item dropdown)
   ========================================================================== */

.feed-item-actions {
    position: relative;
    margin-left: auto;
}

.feed-item-actions-toggle {
    background: transparent;
    border: none;
    color: #000000;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}

.feed-item-actions-toggle:hover {
    opacity: 0.6;
}

.feed-item-actions-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: fit-content;
    white-space: nowrap;
    z-index: 100;
}

.feed-item-actions-menu.open {
    display: block;
}

.feed-item-actions-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-family: monospace;
    font-size: 12px;
}

.feed-item-actions-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Export submenu (nested dropdown) */
.feed-item-export-container {
    position: relative;
}

.feed-item-actions-menu button.has-submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.feed-item-actions-menu button.has-submenu::after {
    content: '›';
    margin-left: 8px;
    font-size: 14px;
}

.feed-item-submenu {
    display: none;
    position: absolute;
    right: 100%;
    top: 0;
    margin-right: 1px;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 60px;
}

.feed-item-submenu.open {
    display: block;
}

.feed-item-submenu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: center;
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-family: monospace;
    font-size: 12px;
}

.feed-item-submenu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Close Button (standalone)
   ========================================================================== */

.close-button {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    border: 1px solid #ffffff;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: background 0.2s;
}

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

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
    padding: 64px 24px;
    text-align: center;
    color: #666;
}

.empty-state h2 {
    font-size: 18px;
    font-weight: 300;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 12px;
}

/* ==========================================================================
   Upload Button
   ========================================================================== */

.upload-button {
    aspect-ratio: 1;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
    border: 2px dashed #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.upload-button:hover {
    background: #e5e5e5;
    border-color: #333333;
}

.upload-button:active {
    background: #d5d5d5;
}

.upload-button .plus-icon {
    font-size: 48px;
    font-weight: 300;
    color: #000000;
    user-select: none;
    pointer-events: none;
}

.upload-button input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-button.uploading {
    opacity: 0.7;
    pointer-events: none;
}

.upload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #e5e5e5;
    display: none;
}

.upload-button.uploading .upload-progress {
    display: block;
}

.upload-progress-bar {
    height: 100%;
    background: #000000;
    width: 0%;
    transition: width 0.1s linear;
}

/* ==========================================================================
   Bulk Action Bar
   ========================================================================== */

.bulk-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #000000;
    padding: 16px 24px;
    display: none;
    align-items: center;
    justify-content: space-between;
    z-index: 200;
    gap: 16px;
}

.bulk-action-bar.active {
    display: flex;
}

.bulk-action-info {
    font-family: monospace;
    font-size: 12px;
    color: #000000;
}

.bulk-action-buttons {
    display: flex;
    gap: 8px;
}

.bulk-action-button {
    padding: 8px 16px;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.bulk-action-button:hover {
    background: #000000;
    color: #ffffff;
}

.bulk-action-button.secondary {
    border-color: #666;
    color: #666;
}

.bulk-action-button.secondary:hover {
    background: #666;
    color: #ffffff;
    border-color: #666;
}

/* ==========================================================================
   Metadata Sheet (bottom sheet)
   ========================================================================== */

.metadata-sheet {
    position: fixed;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid #000000;
    border-left: 1px solid #000000;
    border-right: 1px solid #000000;
    z-index: 2000;
    transition: transform 0.3s ease-out, height 0.3s ease-out;
    height: 50vh;
    display: none;
    flex-direction: column;
    /* Position will be set dynamically via JS to match feed item container */
}

.metadata-sheet.active {
    display: flex;
}

.metadata-sheet.minimized {
    height: 40px;
}

.metadata-sheet.half {
    height: 50vh;
}

.metadata-sheet.full {
    height: 90vh;
}

.metadata-sheet-handle {
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.metadata-sheet-handle:active {
    cursor: grabbing;
}

.metadata-sheet-handle-bar {
    width: 40px;
    height: 4px;
    background: #000000;
}

.metadata-sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.metadata-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
    transition: opacity 0.3s ease-out;
}

.metadata-overlay.active {
    display: block;
}

/* ==========================================================================
   Metadata Form
   ========================================================================== */

.metadata-form-field {
    margin-bottom: 20px;
}

.metadata-form-field label {
    display: block;
    font-family: monospace;
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    text-transform: lowercase;
}

.metadata-form-field input,
.metadata-form-field textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #000000;
    background: #ffffff;
    font-family: monospace;
    font-size: 12px;
    box-sizing: border-box;
}

.metadata-form-field textarea {
    min-height: 80px;
    resize: vertical;
}

.metadata-form-field input:focus,
.metadata-form-field textarea:focus {
    outline: 2px solid #000000;
    outline-offset: -2px;
}

.metadata-form-field.readonly {
    opacity: 0.6;
}

.metadata-form-field.readonly input {
    background: #f5f5f5;
    cursor: not-allowed;
}

/* ==========================================================================
   Tag Input
   ========================================================================== */

.tag-input-container {
    border: 1px solid #000000;
    padding: 8px;
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #000000;
    color: #ffffff;
    padding: 4px 8px;
    font-family: monospace;
    font-size: 11px;
}

.tag-pill-remove {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
}

.tag-pill-remove:hover {
    opacity: 0.7;
}

.tag-input-field {
    border: none;
    outline: none;
    font-family: monospace;
    font-size: 12px;
    flex: 1;
    min-width: 100px;
    padding: 4px;
}

.tag-autocomplete {
    position: absolute;
    background: #ffffff;
    border: 1px solid #000000;
    border-top: none;
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.tag-autocomplete.active {
    display: block;
}

.tag-autocomplete-item {
    padding: 8px;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
}

.tag-autocomplete-item:hover {
    background: #f5f5f5;
}

.tag-autocomplete-item:last-child {
    border-bottom: none;
}

.metadata-save-button {
    width: 100%;
    padding: 12px;
    border: 1px solid #000000;
    background: #000000;
    color: #ffffff;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    margin-top: 24px;
    transition: opacity 0.2s;
}

.metadata-save-button:hover {
    opacity: 0.8;
}

/* ==========================================================================
   Mass Tag Modal
   ========================================================================== */

.mass-tag-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border: 1px solid #000000;
    padding: 24px;
    z-index: 3000;
    min-width: 400px;
    max-width: 500px;
    display: none;
}

.mass-tag-modal.active {
    display: block;
}

.mass-tag-modal-header {
    font-family: monospace;
    font-size: 14px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #000000;
}

.mass-tag-modal-body {
    margin-bottom: 16px;
}

.mass-tag-input-container {
    border: 1px solid #000000;
    padding: 8px;
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 12px;
}

.existing-tags-label {
    font-family: monospace;
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
    text-transform: lowercase;
}

.existing-tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #e0e0e0;
}

.tag-option {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    background: #ffffff;
    border: 1px solid #000000;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-option:hover {
    background: #f5f5f5;
}

.tag-option.selected {
    background: #000000;
    color: #ffffff;
}

.mass-tag-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.mass-tag-button-primary,
.mass-tag-button-secondary {
    padding: 8px 16px;
    border: 1px solid #000000;
    background: #ffffff;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mass-tag-button-primary {
    background: #000000;
    color: #ffffff;
}

.mass-tag-button-primary:hover {
    opacity: 0.8;
}

.mass-tag-button-secondary:hover {
    background: #f5f5f5;
}

/* ==========================================================================
   Library Container (inset wrapper)
   ========================================================================== */

.library-container {
    margin: 24px;
}

@media (max-width: 768px) {
    .library-container {
        margin: 12px;
    }
}

/* ==========================================================================
   Library Toolbar
   ========================================================================== */

.library-toolbar {
    position: sticky;
    top: 73px; /* Below header */
    background: #ffffff;
    border-bottom: 1px solid #000000;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 99;
    flex-wrap: wrap;
    gap: 16px;
}

.toolbar-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar-right {
    display: flex;
    gap: 24px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.toolbar-button {
    padding: 6px 12px;
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.toolbar-button:hover {
    background: #f5f5f5;
}

.toolbar-button.active {
    background: #000000;
    color: #ffffff;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toolbar-label {
    font-family: monospace;
    font-size: 10px;
    color: #666;
    text-transform: lowercase;
}

.toolbar-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #ffffff;
    border: 1px solid #000000;
    padding: 6px 28px 6px 8px;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
    min-width: 140px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23000' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: all 0.15s;
}

.toolbar-select:hover {
    background-color: #f5f5f5;
}

.toolbar-select:focus {
    outline: 2px solid #000000;
    outline-offset: -2px;
}

/* ==========================================================================
   Mass Editor Modal
   ========================================================================== */

.mass-edit-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border: 1px solid #000000;
    z-index: 3000;
    min-width: 450px;
    max-width: 550px;
    display: none;
}

.mass-edit-modal.active {
    display: block;
}

.mass-edit-header {
    font-family: monospace;
    font-size: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid #000000;
}

.mass-edit-count {
    font-weight: bold;
}

.mass-edit-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
}

.mass-edit-tab {
    flex: 1;
    padding: 12px 16px;
    background: #f5f5f5;
    border: none;
    border-right: 1px solid #e0e0e0;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: lowercase;
}

.mass-edit-tab:last-child {
    border-right: none;
}

.mass-edit-tab:hover {
    background: #e5e5e5;
}

.mass-edit-tab.active {
    background: #ffffff;
    border-bottom: 2px solid #000000;
    margin-bottom: -1px;
}

.mass-edit-body {
    padding: 20px;
    min-height: 200px;
}

.mass-edit-field-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mass-edit-text-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #000000;
    background: #ffffff;
    font-family: monospace;
    font-size: 12px;
    box-sizing: border-box;
}

.mass-edit-text-input:focus {
    outline: 2px solid #000000;
    outline-offset: -2px;
}

.mass-edit-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
}

.mass-edit-button-primary,
.mass-edit-button-secondary {
    padding: 8px 16px;
    border: 1px solid #000000;
    background: #ffffff;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mass-edit-button-primary {
    background: #000000;
    color: #ffffff;
}

.mass-edit-button-primary:hover {
    opacity: 0.8;
}

.mass-edit-button-secondary:hover {
    background: #f5f5f5;
}

