/**
 * File Explorer Styles
 * Modern, clean file explorer UI with Windows-inspired design
 */

.file-explorer-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary, #1e1e1e);
    color: var(--text-primary, #fff);
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ========== Toolbar ========== */
.fe-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-secondary, #2d2d2d);
    border-bottom: 1px solid var(--border-color, #3c3c3c);
    flex-shrink: 0;
}

.fe-nav-buttons {
    display: flex;
    gap: 4px;
}

.fe-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary, #fff);
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.fe-btn:hover:not(:disabled) {
    background: var(--bg-hover, rgba(255, 255, 255, 0.1));
}

.fe-btn:active:not(:disabled) {
    background: var(--bg-active, rgba(255, 255, 255, 0.15));
}

.fe-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fe-btn svg {
    width: 18px;
    height: 18px;
}

/* ========== Address Bar ========== */
.fe-address-bar {
    flex: 1;
    min-width: 0;
    background: var(--bg-tertiary, #1a1a1a);
    border: 1px solid var(--border-color, #3c3c3c);
    border-radius: 4px;
    padding: 6px 10px;
    overflow: hidden;
}

.fe-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.fe-breadcrumbs::-webkit-scrollbar {
    display: none;
}

.fe-crumb {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    color: var(--text-secondary, #aaa);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.fe-crumb:hover:not(.current) {
    background: var(--bg-hover, rgba(255, 255, 255, 0.1));
    color: var(--text-primary, #fff);
}

.fe-crumb.drop-target {
    background: var(--accent, #0078d7) !important;
    color: white !important;
    border-radius: 4px;
    box-shadow: 0 0 0 2px rgba(0, 120, 215, 0.3);
}

.fe-crumb.current {
    color: var(--text-primary, #fff);
    font-weight: 500;
    cursor: default;
}

.fe-crumb svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.fe-crumb-sep {
    color: var(--text-tertiary, #666);
    font-size: 14px;
    user-select: none;
}

/* ========== View Toggle ========== */
.fe-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary, #1a1a1a);
    border-radius: 4px;
    padding: 2px;
}

.fe-view-toggle .fe-btn {
    width: 28px;
    height: 28px;
}

.fe-view-toggle .fe-btn.active {
    background: var(--accent-color, #4a9eff);
    color: #fff;
}

/* ========== Content Area ========== */
.fe-content {
    flex: 1;
    overflow: auto;
    padding: 8px;
    position: relative;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Selection box for marquee/lasso selection */
.fe-selection-box {
    position: absolute;
    border: 1px solid var(--accent-border, rgba(74, 158, 255, 0.8));
    background-color: var(--icon-hover-bg, rgba(74, 158, 255, 0.2));
    pointer-events: none;
    z-index: 100;
}

.fe-items-container {
    min-height: 100%;
}

/* Grid View */
.fe-items-container.fe-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    align-content: start;
}

.fe-item-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    position: relative;
}

.fe-item-grid:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.fe-item-grid.selected {
    background: var(--icon-selected-bg, rgba(74, 158, 255, 0.3));
}

.fe-item-grid .fe-item-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.fe-item-grid .fe-item-icon svg {
    width: 100%;
    height: 100%;
}

.fe-item-grid .fe-item-name {
    font-size: 12px;
    text-align: center;
    word-break: break-word;
    max-width: 80px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Show full text when selected - overlays other icons */
/* Show full text when selected - overlays other icons */
.fe-item-grid.selected .fe-item-name {
    position: absolute;
    top: 66px;
    /* Align with flow (12px pad + 48px icon + 6px margin) */
    left: 50%;
    transform: translateX(-50%);
    -webkit-line-clamp: unset;
    line-clamp: unset;
    display: block;
    overflow: visible;
    word-break: break-word;

    /* Dark background, not blue */
    background: var(--bg-secondary, #2d2d2d);
    border: 1px solid var(--border-light, #444);
    border-radius: 4px;
    padding: 2px 4px;

    /* Constrain width to stick to grid column, wrapping down */
    width: 90px;
    min-width: unset;
    max-width: unset;

    z-index: 50;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* List View */
.fe-items-container.fe-list-view {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fe-item-list {
    display: grid;
    grid-template-columns: 24px 1fr 80px 100px;
    gap: 12px;
    align-items: center;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.fe-item-list:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.fe-item-list.selected {
    background: var(--icon-selected-bg, rgba(74, 158, 255, 0.3));
}

.fe-item-list .fe-item-icon {
    width: 20px;
    height: 20px;
}

.fe-item-list .fe-item-icon svg {
    width: 100%;
    height: 100%;
}

.fe-item-list .fe-item-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Show full text when selected in list view too */
.fe-item-list.selected .fe-item-name {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.fe-item-list .fe-item-size,
.fe-item-list .fe-item-date {
    font-size: 12px;
    color: var(--text-secondary, #aaa);
    text-align: right;
}

/* Drag & Drop States */
.fe-item.fe-dragging {
    opacity: 0.5;
}

.fe-item.fe-drop-target {
    background: var(--accent-color, #4a9eff) !important;
    opacity: 1;
    border: 2px solid var(--accent-color, #4a9eff);
    box-shadow: 0 0 12px rgba(74, 158, 255, 0.6);
    border-radius: 8px;
}

.fe-items-container.fe-drag-over {
    background: rgba(74, 158, 255, 0.1);
    border: 2px dashed var(--accent-color, #4a9eff);
    border-radius: 8px;
}

/* Rename Input/Textarea */
.fe-rename-input {
    width: 100%;
    min-height: 22px;
    padding: 2px 4px;
    font-size: 12px;
    font-family: inherit;
    background: transparent;
    border: 1px solid var(--accent, #0078d7);
    border-radius: 2px;
    color: var(--text-primary, #e0e0e0);
    outline: none;
    resize: none;
    text-align: center;
    line-height: 1.3;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* ========== Empty State ========== */
.fe-empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary, #666);
}

.fe-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.fe-empty-text {
    font-size: 14px;
}

/* ========== Status Bar ========== */
.fe-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-secondary, #2d2d2d);
    border-top: 1px solid var(--border-color, #3c3c3c);
    font-size: 12px;
    color: var(--text-secondary, #aaa);
    flex-shrink: 0;
}

.fe-selected-count {
    color: var(--accent-color, #4a9eff);
}

/* ========== Context Menu ========== */
.fe-context-menu {
    position: fixed;
    min-width: 180px;
    background: var(--bg-secondary, #2d2d2d);
    border: 1px solid var(--border-color, #3c3c3c);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
    z-index: 10000;
    animation: feMenuFadeIn 0.15s ease;
}

@keyframes feMenuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fe-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-primary, #fff);
    cursor: pointer;
    transition: background 0.15s;
}

.fe-menu-item:hover:not([disabled]) {
    background: var(--bg-hover, rgba(255, 255, 255, 0.1));
}

.fe-menu-item[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.fe-menu-item.fe-menu-danger:hover:not([disabled]) {
    background: rgba(220, 53, 69, 0.2);
    color: #ff6b6b;
}

.fe-menu-item span {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

.fe-menu-separator {
    height: 1px;
    background: var(--border-color, #3c3c3c);
    margin: 4px 0;
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
    .fe-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .fe-address-bar {
        order: 10;
        width: 100%;
    }

    .fe-items-container.fe-grid-view {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    }

    .fe-item-list {
        grid-template-columns: 24px 1fr;
    }

    .fe-item-list .fe-item-size,
    .fe-item-list .fe-item-date {
        display: none;
    }
}

/* ========== Picker Mode Styles ========== */

/* Container adjustments for picker mode */
.file-explorer-container.fe-picker-mode {
    display: flex;
    flex-direction: column;
}

.file-explorer-container.fe-picker-mode .fe-content {
    flex: 1;
    min-height: 0;
}

/* Picker Footer */
.fe-picker-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary, #2d2d2d);
    border-top: 1px solid var(--border-color, #3c3c3c);
    flex-shrink: 0;
}

.fe-picker-filename-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fe-picker-label {
    font-size: 13px;
    color: var(--text-secondary, #aaa);
    flex-shrink: 0;
    min-width: 70px;
}

.fe-picker-filename {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-tertiary, #1a1a1a);
    border: 1px solid var(--border-color, #3c3c3c);
    border-radius: 4px;
    color: var(--text-primary, #fff);
    outline: none;
    transition: border-color 0.15s;
}

.fe-picker-filename:focus {
    border-color: var(--accent-color, #4a9eff);
}

.fe-picker-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.fe-picker-filter {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 1;
    min-width: 0;
}

.fe-picker-filter .fe-picker-label {
    margin-right: 8px;
    flex-shrink: 0;
}

.fe-picker-filter-select {
    flex: 1;
    min-width: 120px;
    max-width: 250px;
    padding: 8px 12px;
    margin-right: 10px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-tertiary, #1a1a1a);
    border: 1px solid var(--border-color, #3c3c3c);
    border-radius: 4px;
    color: var(--text-primary, #fff);
    cursor: pointer;
    outline: none;
}

.fe-picker-filter-select:focus {
    border-color: var(--accent-color, #4a9eff);
}

.fe-picker-browse {
    flex-shrink: 0;
    padding: 8px 14px;
}

.fe-picker-browse svg {
    flex-shrink: 0;
}

.fe-picker-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.fe-picker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid var(--border-color, #3c3c3c);
    border-radius: 4px;
    background: var(--bg-tertiary, #1a1a1a);
    color: var(--text-primary, #fff);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.fe-picker-btn:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.1));
}

.fe-picker-btn.primary {
    background: var(--accent-color, #4a9eff);
    border-color: var(--accent-color, #4a9eff);
    color: #fff;
}

.fe-picker-btn.primary:hover {
    background: var(--accent-hover, #3a8eef);
}

.fe-picker-btn svg {
    width: 16px;
    height: 16px;
}

/* Responsive picker footer */
@media (max-width: 600px) {
    .fe-picker-footer {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .fe-picker-filename-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .fe-picker-label {
        min-width: unset;
    }
    
    .fe-picker-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .fe-picker-filter {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .fe-picker-filter .fe-picker-label {
        margin-right: 0;
    }
    
    .fe-picker-filter-select {
        max-width: none;
        margin-right: 0;
    }
    
    .fe-picker-browse {
        width: 100%;
        justify-content: center;
    }
    
    .fe-picker-buttons {
        width: 100%;
    }
    
    .fe-picker-btn {
        flex: 1;
    }
}