/**
 * File Director - Köhnə iOS / MacBook (OS X) dizaynı
 * Brushed metal, glossy, skeuomorphic
 */

/* === CSS Variables === */
:root {
    --metal-light: #e8e8e8;
    --metal-dark: #c0c0c0;
    --metal-gradient: linear-gradient(180deg, #f5f5f5 0%, #d8d8d8 50%, #c8c8c8 100%);
    --sidebar-bg: linear-gradient(180deg, #e8e8e8 0%, #d0d0d0 100%);
    --toolbar-bg: linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 5%, #c8c8c8 50%, #b8b8b8 100%);
    --toolbar-border: #a0a0a0;
    --selection-blue: #3b82d4;
    --selection-blue-dark: #2a6bb8;
    --nav-bar-ios: linear-gradient(180deg, #6b9cbd 0%, #4a7ba7 50%, #3d6b94 100%);
    --font-mac: "Lucida Grande", "Helvetica Neue", Arial, sans-serif;
    --shadow-inset: inset 0 2px 4px rgba(0,0,0,0.1);
    --shadow-outer: 0 2px 8px rgba(0,0,0,0.2);
    --radius: 8px;
    --radius-small: 5px;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; height: 100%; }
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-mac);
    background: #989898;
    background-image: 
        linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    color: #333;
    overflow-x: hidden;
}

/* === Ana pəncərə (Mac window) === */
.app-window {
    max-width: 960px;
    margin: 24px auto;
    background: var(--metal-gradient);
    border-radius: 10px;
    box-shadow: var(--shadow-outer), inset 0 1px 0 rgba(255,255,255,0.6);
    border: 1px solid #999;
    overflow: hidden;
}

/* Pəncərə başlığı (traffic lights) */
.window-titlebar {
    height: 22px;
    background: linear-gradient(180deg, #e0e0e0 0%, #c8c8c8 100%);
    border-bottom: 1px solid #a0a0a0;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
}
.window-titlebar .traffic {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.5);
}
.window-titlebar .traffic.close    { background: #ff5f57; }
.window-titlebar .traffic.minimize { background: #febc2e; }
.window-titlebar .traffic.maximize { background: #28c840; }
.window-titlebar .title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: #333;
    font-weight: 600;
}

/* === Toolbar (Köhnə Finder) === */
.toolbar {
    padding: 8px 12px;
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--toolbar-border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.toolbar-btn {
    padding: 6px 14px;
    font-family: var(--font-mac);
    font-size: 12px;
    border: 1px solid #999;
    border-radius: var(--radius-small);
    background: linear-gradient(180deg, #fff 0%, #e8e8e8 50%, #d0d0d0 100%);
    color: #333;
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255,255,255,0.8), inset 0 1px 0 rgba(255,255,255,0.5);
    text-decoration: none;
}
.toolbar-btn:hover {
    background: linear-gradient(180deg, #fff 0%, #f0f0f0 50%, #e0e0e0 100%);
}
.toolbar-btn:active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}
.toolbar-btn i {
    margin-right: 6px;
}
.toolbar-btn i:last-child {
    margin-right: 0;
}
.toolbar-btn.primary {
    background: linear-gradient(180deg, #5a9fd4 0%, #4a8fc4 50%, #3a7fb4 100%);
    color: #fff;
    border-color: #2a6fa4;
}
.toolbar-btn.primary:hover {
    background: linear-gradient(180deg, #6aafd4 0%, #5a9fc4 50%, #4a8fb4 100%);
}
.toolbar-divider {
    width: 1px;
    height: 24px;
    background: linear-gradient(180deg, transparent, #999, transparent);
    margin: 0 4px;
}
.toolbar-search {
    margin-left: auto;
    padding: 5px 10px 5px 28px;
    border: 1px solid #999;
    border-radius: 14px;
    background: #fff;
    font-size: 12px;
    min-width: 120px;
}

/* Axtarış trigger + panel */
.search-trigger-wrap {
    position: relative;
}
.search-trigger-wrap .toolbar-btn i.fa-magnifying-glass {
    margin-right: 6px;
}
.search-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 280px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid #999;
    border-radius: var(--radius);
    box-shadow: var(--shadow-outer);
    z-index: 100;
    padding: 14px;
    display: none;
}
.search-panel.open {
    display: block;
}
.search-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.search-panel-label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-panel-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #999;
    border-radius: var(--radius-small);
    font-size: 13px;
    box-sizing: border-box;
}
.search-panel-hint {
    font-size: 11px;
    color: #666;
    margin: 0;
}
.search-panel-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
body.theme-dark .search-panel { background: #404040; border-color: #555; }
body.theme-dark .search-panel-label { color: #e0e0e0; }
body.theme-dark .search-panel-input { background: #353535; border-color: #555; color: #e0e0e0; }
body.theme-dark .search-panel-hint { color: #aaa; }

/* === Layout: Sidebar + Content === */
.main-layout {
    display: flex;
    min-height: 420px;
}

/* Sidebar (Köhnə Finder sol panel) */
.sidebar {
    width: 200px;
    background: var(--sidebar-bg);
    border-right: 1px solid #b0b0b0;
    padding: 12px 0;
    flex-shrink: 0;
}
.sidebar-section {
    margin-bottom: 16px;
}
.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 16px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    cursor: pointer;
    color: #333;
    text-decoration: none;
    font-size: 13px;
}
.sidebar-item:hover {
    background: rgba(0,0,0,0.06);
}
.sidebar-item.active {
    background: var(--selection-blue);
    color: #fff;
}
.sidebar-item.sidebar-drop-active {
    background: rgba(59, 130, 212, 0.3);
    outline: 2px dashed var(--selection-blue);
}
.sidebar-item .icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.sidebar-item .icon i {
    font-size: inherit;
}

/* === Fayl listəsi (content) === */
.content {
    flex: 1;
    background: #fff;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.content-header {
    padding: 8px 16px;
    background: linear-gradient(180deg, #f8f8f8 0%, #eee 100%);
    border-bottom: 1px solid #ddd;
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.content-header-select-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.content-header-select-all input {
    cursor: pointer;
}
.selected-counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--selection-blue);
    font-weight: 500;
}
.selected-counter i {
    font-size: 14px;
}
.breadcrumb-segment {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
}
.breadcrumb-segment:hover {
    background: rgba(0,0,0,0.08);
    color: var(--selection-blue);
}
#file-count {
    margin-left: auto;
}

/* Axtarış nəticəsi zolağı */
.search-results-bar {
    padding: 10px 16px;
    background: linear-gradient(180deg, #e8f4fd 0%, #d6ebfa 100%);
    border-bottom: 1px solid #b0d4f0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.search-results-summary {
    font-weight: 600;
    color: #1a5a8c;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.search-results-summary i {
    font-size: 14px;
}
.search-results-detail {
    color: #2d6a9a;
    font-size: 12px;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
}
.search-results-clear {
    margin-left: auto;
    padding: 4px 10px;
    font-size: 11px;
}
.search-results-none {
    font-style: italic;
    color: #c00;
}
body.theme-dark .search-results-none { color: #f88; }
body.theme-dark .search-results-bar {
    background: linear-gradient(180deg, #2a4a5c 0%, #1e3a48 100%);
    border-bottom-color: #3a5a6c;
}
body.theme-dark .search-results-summary { color: #7ec8f0; }
body.theme-dark .search-results-detail { color: #9ec8e8; }

.content-body {
    flex: 1;
    overflow: auto;
    padding: 8px;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 8px;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}
.pagination-info {
    font-size: 13px;
    color: #666;
}
.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
body.theme-dark .pagination-bar { border-color: #555; }
body.theme-dark .pagination-info { color: #aaa; }

/* Cədvəl görünüşü */
.file-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.file-table th {
    text-align: left;
    padding: 6px 12px;
    background: linear-gradient(180deg, #f0f0f0 0%, #e5e5e5 100%);
    border-bottom: 1px solid #ccc;
    font-weight: 600;
    color: #444;
}
.file-table th.sortable {
    cursor: pointer;
}
.file-table th.sortable:hover {
    color: #000;
}
.file-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #eee;
}
.file-select-col {
    width: 36px;
    text-align: center;
    padding: 6px 8px !important;
}
.file-table .file-select-cell {
    text-align: center;
    padding: 6px 8px !important;
    vertical-align: middle;
}
.file-checkbox-wrap,
.file-card-checkbox-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0;
}
.file-checkbox-wrap input,
.file-card-checkbox-wrap input {
    cursor: pointer;
    width: 16px;
    height: 16px;
}
.file-card-checkbox-wrap {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 6;
}
.file-card .file-card-checkbox-wrap input {
    width: 18px;
    height: 18px;
}
.file-table tbody tr {
    cursor: pointer;
}
.file-table tbody tr:hover {
    background: #e8f2fc;
}
.file-table tbody tr.selected {
    background: #cce0f7;
    border-left: 3px solid var(--selection-blue);
}
.file-table tbody tr.selected:hover {
    background: #b8d4f0;
}
.file-table .file-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    vertical-align: middle;
}
.file-table .file-icon i {
    font-size: inherit;
}
.file-table .file-name-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
}
.file-table .file-name-row .file-name {
    min-width: 0;
}
/* Şəkil önizləmə — raster formatlar */
.file-icon.file-icon--thumb {
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
}
.file-icon.file-icon--thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.file-icon.file-icon--thumb video.file-thumb-inline {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.file-table .file-icon.file-icon--thumb {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 8px;
    background: #e8eaed;
    border: 1px solid #c5cad3;
}
.file-card .file-icon.file-icon--thumb img,
.file-card .file-icon.file-icon--thumb video.file-thumb-inline {
    border-radius: inherit;
}

.file-table .file-name { font-weight: 500; }
.file-table .file-size, .file-table .file-date { color: #666; font-size: 12px; }

/* Əməliyyatlar sütunu və dropdown */
.file-actions-col {
    width: 100px;
    text-align: center;
}
.file-table .file-actions {
    padding: 4px 8px;
    text-align: center;
    position: relative;
}
.file-actions-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #b0b0b0;
    border-radius: var(--radius-small);
    background: linear-gradient(180deg, #f8f8f8 0%, #e5e5e5 100%);
    color: #555;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.file-actions-btn:hover {
    background: linear-gradient(180deg, #fff 0%, #eee 100%);
    color: #333;
}
.file-actions-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 2px;
    min-width: 200px;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #aaa;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-outer);
    z-index: 100;
    padding: 4px 0;
}
.file-actions-dropdown.open {
    display: block;
    position: fixed;
    z-index: 10000;
    margin: 0;
}
.file-actions-dropdown.dropdown-open-up.open {
    top: auto;
}
.file-action-item,
.file-action-sep {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 14px;
    border: none;
    background: none;
    font-family: var(--font-mac);
    font-size: 12px;
    color: #333;
    cursor: pointer;
}
.file-action-item:hover {
    background: #e8f2fc;
}
.file-action-item i {
    margin-right: 8px;
    width: 18px;
    text-align: center;
}
.file-action-item--custom i {
    color: var(--selection-blue);
}
.file-action-sep {
    height: 0;
    padding: 0;
    margin: 4px 0;
    border-top: 1px solid #ddd;
    cursor: default;
}

/* Grid: kartda əməliyyatlar */
.file-card {
    position: relative;
}
.file-card-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 5;
}
.file-card .file-actions-btn {
    width: 26px;
    height: 26px;
    font-size: 11px;
}
.file-card .file-actions-dropdown {
    right: 0;
    left: auto;
    top: 100%;
    margin-top: 2px;
}

/* Grid görünüşü (köhnə iOS ikonlar) */
.view-grid .file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
    padding: 8px;
}
.file-card {
    text-align: center;
    padding: 12px 8px;
    border-radius: var(--radius-small);
    cursor: pointer;
    border: 1px solid transparent;
}
.file-card:hover {
    background: #e8f2fc;
    border-color: #b0d0f0;
}
.file-card.selected {
    background: #cce0f7;
    border-color: var(--selection-blue);
    border-width: 2px;
    box-shadow: 0 0 0 1px var(--selection-blue);
}
.file-card.selected:hover {
    background: #b8d4f0;
}
.file-card .file-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 8px;
    background: linear-gradient(180deg, #f8f8f8 0%, #e8e8e8 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    border: 1px solid #ddd;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}
.file-card .file-icon.file-icon--thumb {
    background: #2c2c2c;
    padding: 0;
}
.file-card .file-icon i {
    font-size: inherit;
}
.file-card .file-name {
    font-size: 12px;
    word-break: break-all;
    color: #333;
}

/* === Sağ klik kontekst menyusu === */
.context-menu {
    display: none;
    position: fixed;
    min-width: 220px;
    max-height: 70vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #999;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-outer), inset 0 1px 0 rgba(255,255,255,0.5);
    padding: 6px 0;
    z-index: 1000;
    font-family: var(--font-mac);
}
.context-menu.active {
    display: block;
}
.context-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: none;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}
.context-menu-item:hover {
    background: #e8f2fc;
}
.context-menu-item i {
    margin-right: 10px;
    width: 18px;
    text-align: center;
}
.context-menu-item--custom i {
    color: var(--selection-blue);
}
.context-menu-sep {
    height: 0;
    margin: 4px 0;
    border-top: 1px solid #ddd;
}

/* Boş vəziyyət / Upload zona */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #888;
}
.empty-state .upload-zone {
    max-width: 400px;
    margin: 24px auto;
    padding: 40px;
    border: 2px dashed #bbb;
    border-radius: var(--radius);
    background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.empty-state .upload-zone:hover,
.empty-state .upload-zone.dragover {
    border-color: var(--selection-blue);
    background: #e8f2fc;
}
.empty-state .upload-zone .icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.7;
}
.empty-state .upload-zone .icon i {
    font-size: inherit;
}

/* === Modal (Köhnə iOS alert) === */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.active {
    display: flex;
}
#fd-dialog-overlay.modal-overlay {
    z-index: 2002;
}
.fd-dialog-message {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.modal-box--folder-pick {
    width: min(520px, 94vw);
}
.fd-fp-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    font-size: 13px;
    margin-bottom: 10px;
    line-height: 1.4;
}
.fd-fp-crumb {
    background: transparent;
    border: none;
    padding: 2px 6px;
    margin: 0;
    font: inherit;
    color: #1565c0;
    cursor: pointer;
    border-radius: 4px;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.fd-fp-crumb:hover {
    background: rgba(21, 101, 192, 0.08);
}
.fd-fp-crumb--current {
    color: #333;
    font-weight: 600;
    text-decoration: none;
    cursor: default;
    pointer-events: none;
}
.fd-fp-sep {
    color: #888;
    user-select: none;
}
.fd-fp-list {
    max-height: min(48vh, 360px);
    overflow: auto;
    border: 1px solid #bbb;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.45);
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
}
.fd-fp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    justify-content: flex-start;
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.7);
}
.fd-fp-row:hover:not(.fd-fp-row--disabled) {
    border-color: #999;
    background: #fff;
}
.fd-fp-row--disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.fd-fp-row .fa-folder {
    color: #e8b44d;
    flex-shrink: 0;
}
.fd-fp-loading,
.fd-fp-empty {
    margin: 0;
    padding: 12px;
    font-size: 13px;
    color: #555;
}
.fd-fp-hint {
    margin: 12px 0 0;
    font-size: 12px;
    color: #666;
    line-height: 1.45;
}
.modal-box {
    background: var(--metal-gradient);
    border-radius: 12px;
    border: 1px solid #999;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.5);
    min-width: 320px;
    max-width: 90vw;
    overflow: hidden;
}
.modal-title {
    padding: 14px 20px;
    background: var(--nav-bar-ios);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}
.modal-body {
    padding: 20px;
    font-size: 13px;
    color: #333;
}
.modal-actions {
    padding: 12px 20px;
    background: #e0e0e0;
    border-top: 1px solid #b0b0b0;
    display: flex;
    justify-content: center;
    gap: 12px;
}
.modal-actions .toolbar-btn { min-width: 80px; }

/* İstifadəçi əlavə/redaktə modalı — geniş, şəbəkəli */
#modal-user.modal-overlay {
    padding: 20px 16px;
    box-sizing: border-box;
}
#modal-user .modal-box--user {
    width: min(600px, calc(100vw - 32px));
    max-width: min(640px, calc(100vw - 24px));
    min-width: 280px;
    max-height: min(92vh, 880px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#modal-user .modal-header--user {
    flex-shrink: 0;
    padding: 14px 22px;
    background: var(--nav-bar-ios);
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}
#modal-user .modal-header--user h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    text-align: center;
    letter-spacing: 0.02em;
    line-height: 1.3;
}
#modal-user .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 22px 26px;
    -webkit-overflow-scrolling: touch;
}
#modal-user .user-modal-grid {
    display: grid;
    gap: 16px 20px;
    align-items: start;
}
@media (min-width: 520px) {
    #modal-user .user-modal-grid {
        grid-template-columns: 1fr 1fr;
    }
    #modal-user .user-modal-span-2 {
        grid-column: 1 / -1;
    }
}
#modal-user .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}
#modal-user .user-modal-pwd-hint {
    display: none;
    font-weight: 400;
    color: #888;
}
#modal-user .form-group .toolbar-search.user-modal-input {
    margin-left: 0;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    min-height: 38px;
}
#modal-user .user-modal-perms {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 18px;
    margin-top: 8px;
}
@media (max-width: 519px) {
    #modal-user .user-modal-perms {
        grid-template-columns: 1fr;
    }
}
#modal-user .user-modal-perm {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}
#modal-user .modal-actions--user {
    flex-shrink: 0;
    justify-content: flex-end;
    padding: 14px 22px;
    gap: 10px;
}

/* Preview modal */
.preview-content {
    text-align: center;
    min-height: 200px;
    padding: 24px;
}
.preview-content img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-outer);
}
.preview-content .file-info {
    margin-top: 12px;
    font-size: 12px;
    color: #666;
}

/* Kod önizləməsi – əsas (Klasik) tema */
body:not(.theme-minimal):not(.theme-modern) .fd-code-view {
    --fd-code-bg: var(--metal-light);
    border-color: var(--metal-dark);
    box-shadow: var(--shadow-inset);
}
body:not(.theme-minimal):not(.theme-modern) .fd-code-view pre {
    color: #333;
}

/* Özəl media pleyer (video / audio) */
.fd-media-player {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.fd-media-player .fd-media-stage {
    position: relative;
    width: 100%;
    background: #000;
}
.fd-media-player.fd-media-audio .fd-media-stage {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2a2a2e 0%, #1a1a1e 100%);
}
.fd-media-player.fd-media-audio .fd-media-stage .fd-media-poster {
    font-size: 48px;
    color: rgba(255,255,255,0.4);
}
.fd-media-player .fd-media-stage video {
    display: block;
    width: 100%;
    max-height: 70vh;
}
.fd-media-player .fd-media-stage audio {
    display: none;
}
.fd-media-controls {
    padding: 10px 14px;
    background: #252528;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.fd-media-controls .fd-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #e0e0e0;
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s, color 0.2s;
}
.fd-media-controls .fd-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.fd-media-controls .fd-progress-wrap {
    flex: 1;
    min-width: 80px;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.fd-media-controls .fd-progress-track {
    width: 100%;
    height: 6px;
    background: #444;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}
.fd-media-controls .fd-progress-fill {
    height: 100%;
    background: #5a9fd4;
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}
.fd-media-controls .fd-time {
    font-size: 12px;
    color: #999;
    min-width: 100px;
    text-align: right;
}
.fd-media-controls .fd-volume-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.fd-media-controls .fd-volume-wrap .fd-btn { width: 32px; height: 32px; font-size: 14px; }
.fd-media-controls .fd-volume-track {
    width: 70px;
    height: 4px;
    background: #444;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}
.fd-media-controls .fd-volume-fill {
    height: 100%;
    background: #5a9fd4;
    border-radius: 2px;
    width: 100%;
    max-width: 100%;
}
.fd-media-player .file-info {
    padding: 8px 14px;
    background: #252528;
    border-top: 1px solid #333;
    font-size: 12px;
    color: #888;
}

.info-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.info-table td { padding: 8px 12px; border-bottom: 1px solid #eee; }
.info-table td:first-child { color: #666; width: 100px; }

/* === Status bar (alt) === */
.status-bar {
    padding: 4px 16px;
    background: linear-gradient(180deg, #e8e8e8 0%, #d8d8d8 100%);
    border-top: 1px solid #b0b0b0;
    font-size: 11px;
    color: #666;
}

/* Toast bildirişlər */
.toast-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-small);
    background: #333;
    color: #fff;
    font-size: 13px;
    box-shadow: var(--shadow-outer);
    animation: toast-in 0.25s ease;
}
.toast.toast-success { background: #2a7a2a; }
.toast.toast-error { background: #a03030; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Yükləmə progress */
.upload-progress-wrap {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 4px;
    z-index: 1500;
    background: rgba(0,0,0,0.08);
}
.upload-progress-inner {
    position: relative;
    margin: 0 auto;
    padding: 0;
}
.upload-progress-wrap:not(.upload-progress-wrap--chunks) .upload-progress-inner {
    max-width: none;
}
.upload-progress-track {
    height: 4px;
    background: rgba(0,0,0,0.12);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.upload-progress-wrap .upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--selection-blue);
    transition: width 0.15s ease;
    border-radius: 4px;
}
.upload-progress-wrap .upload-progress-text {
    display: none;
}
.upload-progress-wrap .upload-progress-detail {
    display: none;
}

/* Parça yükləmə — genişlənmiş panel + animasiya */
.upload-progress-wrap.upload-progress-wrap--chunks {
    top: 12px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(420px, calc(100vw - 24px));
    min-height: 0;
    padding: 0;
    background: transparent;
    border-radius: 12px;
}
.upload-progress-wrap--chunks .upload-progress-inner {
    padding: 14px 18px 16px;
    max-width: 560px;
    background: linear-gradient(165deg, rgba(17,24,39,0.96), rgba(30,41,59,0.94));
    border: 1px solid rgba(148,163,184,0.25);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.04) inset;
    backdrop-filter: blur(10px);
}
.upload-progress-wrap--chunks .upload-progress-track {
    height: 9px;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
    margin-bottom: 12px;
}
.upload-progress-wrap--chunks .upload-progress-bar {
    border-radius: 999px;
    position: relative;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #d946ef, #6366f1);
    background-size: 240% 100%;
    animation: fd-upload-chunk-flow 1.05s linear infinite;
    box-shadow: 0 0 16px rgba(139,92,246,0.45);
    transition: width 0.12s ease-out;
}
@keyframes fd-upload-chunk-flow {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}
.upload-progress-wrap--chunks .upload-progress-text {
    display: block;
    position: static;
    transform: none;
    font-size: 13px;
    font-weight: 600;
    color: #f1f5f9;
    background: transparent;
    box-shadow: none;
    padding: 0;
    letter-spacing: 0.02em;
}
.upload-progress-wrap--chunks .upload-progress-detail {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.35;
    word-break: break-word;
}

/* === Tema: Qaranlıq === */
body.theme-dark {
    background: #3a3a3a;
    background-image: linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px), linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
    color: #e0e0e0;
}
body.theme-dark .app-window {
    background: linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 50%, #2a2a2a 100%);
    border-color: #555;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
body.theme-dark .window-titlebar { background: linear-gradient(180deg, #505050 0%, #404040 100%); border-color: #555; }
body.theme-dark .window-titlebar .title { color: #e0e0e0; }
body.theme-dark .toolbar { background: linear-gradient(180deg, #505050 0%, #454545 50%, #3a3a3a 100%); border-color: #555; }
body.theme-dark .toolbar-btn { background: linear-gradient(180deg, #606060 0%, #505050 50%, #404040 100%); border-color: #666; color: #e0e0e0; }
body.theme-dark .toolbar-btn:hover { background: linear-gradient(180deg, #686868 0%, #585858 50%, #484848 100%); }
body.theme-dark .toolbar-btn.primary { background: linear-gradient(180deg, #4a7fb8 0%, #3a6fa8 50%, #2a5f98 100%); color: #fff; }
body.theme-dark .sidebar { background: linear-gradient(180deg, #454545 0%, #3a3a3a 100%); border-color: #555; }
body.theme-dark .sidebar-item { color: #e0e0e0; }
body.theme-dark .sidebar-item:hover { background: rgba(255,255,255,0.08); }
body.theme-dark .sidebar-item.active { background: var(--selection-blue); color: #fff; }
body.theme-dark .content { background: #353535; border-color: #444; }
body.theme-dark .content-header { background: linear-gradient(180deg, #404040 0%, #383838 100%); border-color: #444; color: #b0b0b0; }
body.theme-dark .content-body { background: #353535; }
body.theme-dark .file-table th { background: linear-gradient(180deg, #404040 0%, #383838 100%); border-color: #555; color: #c0c0c0; }
body.theme-dark .file-table td { border-color: #444; color: #e0e0e0; }
body.theme-dark .file-table tbody tr:hover { background: rgba(59,130,212,0.2); }
body.theme-dark .file-table tbody tr.selected { background: rgba(59,130,212,0.35); border-left-color: var(--selection-blue); }
body.theme-dark .file-card { color: #e0e0e0; }
body.theme-dark .file-card:hover { background: rgba(59,130,212,0.2); }
body.theme-dark .file-card.selected { background: rgba(59,130,212,0.35); }
body.theme-dark .file-table .file-icon.file-icon--thumb {
    background: #2d2d30;
    border-color: #555;
}
body.theme-dark .file-card .file-icon.file-icon--thumb {
    background: #1e1e22;
    border-color: #444;
}
body.theme-dark .status-bar { background: linear-gradient(180deg, #404040 0%, #383838 100%); border-color: #555; color: #a0a0a0; }
body.theme-dark .modal-box { background: linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 100%); border-color: #555; }
body.theme-dark .modal-body { color: #e0e0e0; }
body.theme-dark #modal-user .form-group label { color: #bbb; }
body.theme-dark #modal-user .user-modal-pwd-hint { color: #999; }
body.theme-dark #modal-user .modal-header--user {
    background: linear-gradient(180deg, #505050 0%, #404040 100%);
    border-bottom-color: #555;
}
body.theme-dark #modal-user .modal-header--user h2 { color: #f0f0f0; }
body.theme-dark .context-menu { background: #404040; border-color: #555; }
body.theme-dark .context-menu-item { color: #e0e0e0; }
body.theme-dark .context-menu-item:hover { background: rgba(59,130,212,0.3); }
body.theme-dark .file-actions-dropdown { background: #404040; border-color: #555; }
body.theme-dark .file-action-item { color: #e0e0e0; }
body.theme-dark .file-action-item:hover { background: rgba(59,130,212,0.3); }
body.theme-dark .toolbar-search { background: #353535; border-color: #555; color: #e0e0e0; }
.theme-btn.active,
.daynight-btn.active,
.site-theme-btn.active { font-weight: 600; border-color: var(--selection-blue); }

/* === Responsive / Mobil === */
@media (min-width: 769px) {
    .btn-sidebar-toggle { display: none !important; }
}
@media (max-width: 768px) {
    .btn-sidebar-toggle { display: inline-flex !important; }
    .app-window { margin: 12px auto; max-width: 100%; border-radius: 0; }
    .main-layout { min-height: 320px; }
    .sidebar {
        position: fixed;
        left: -220px;
        top: 0;
        bottom: 0;
        width: 220px;
        z-index: 200;
        transition: left 0.25s ease;
        box-shadow: 4px 0 12px rgba(0,0,0,0.15);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    body.sidebar-open .sidebar { left: 0; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 199;
    }
    body.sidebar-open .sidebar-overlay { display: block; }
    .content { margin-left: 0; min-width: 0; }
    .toolbar { padding: 6px 10px; gap: 6px; }
    .toolbar-btn { padding: 5px 10px; font-size: 11px; }
    .content-header { padding: 6px 12px; font-size: 11px; }
    .file-table { font-size: 12px; }
    .file-table th, .file-table td { padding: 4px 8px; }
    .file-table .file-date { display: none; }
    .view-grid .file-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
    .file-card .file-name { font-size: 11px; }
    .pagination-bar { flex-wrap: wrap; justify-content: center; padding: 8px; }
}
@media (max-width: 480px) {
    .toolbar-search { max-width: 120px; }
    .content-header-select-all { font-size: 11px; }
    .breadcrumb-segment { font-size: 11px; }
}

/* === Black Files — əsas pəncərə, önizləmə, oxuma rejimi === */
.app-window.app-window--files {
    max-width: min(1280px, 100%);
    width: calc(100% - 24px);
    margin: 12px auto;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 24px);
    min-height: 0;
}
.app-window.app-window--files .main-layout {
    flex: 1;
    min-height: 0;
}
/* Yan menyu çox məqalə olduqda görünən sahədən böyük ola bilər; overflow olmadan app-window overflow:hidden alt hissəni kəsir */
.app-window.app-window--files .sidebar {
    min-height: 0;
    align-self: stretch;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.app-window.app-window--files .content {
    min-height: 0;
}
.bf-browse-banner {
    padding: 10px 16px;
    background: linear-gradient(180deg, #fff8e6 0%, #ffe9c2 100%);
    border-bottom: 1px solid #e8c96b;
    font-size: 13px;
    color: #5c4a12;
}
.bf-browse-banner a { color: var(--selection-blue); font-weight: 600; }
body.theme-dark .bf-browse-banner {
    background: linear-gradient(180deg, #4a3f20 0%, #3a3218 100%);
    border-color: #665520;
    color: #f5e6b8;
}
.bf-no-public-share .context-menu-item[data-action="share"],
.bf-no-public-share #modal-share { display: none !important; }
body.bf-readonly-browse #btn-new-folder,
body.bf-readonly-browse #btn-upload,
body.bf-readonly-browse #btn-delete,
body.bf-readonly-browse #btn-zip,
body.bf-readonly-browse #input-upload,
body.bf-readonly-browse .empty-state .upload-zone { display: none !important; }
body.bf-readonly-browse .file-action-item[data-action="share"],
body.bf-readonly-browse .file-action-item[data-action="delete"],
body.bf-readonly-browse .file-action-item[data-action="rename"],
body.bf-readonly-browse .file-action-item[data-action="cut"],
body.bf-readonly-browse .file-action-item[data-action="copy"],
body.bf-readonly-browse .file-action-item[data-action="paste"],
body.bf-readonly-browse .file-action-item[data-action="move"],
body.bf-readonly-browse .file-action-item[data-action="copyto"],
body.bf-readonly-browse .context-menu-item[data-action="share"],
body.bf-readonly-browse .context-menu-item[data-action="delete"],
body.bf-readonly-browse .context-menu-item[data-action="rename"],
body.bf-readonly-browse .context-menu-item[data-action="cut"],
body.bf-readonly-browse .context-menu-item[data-action="copy"],
body.bf-readonly-browse .context-menu-item[data-action="paste"],
body.bf-readonly-browse .context-menu-item[data-action="move"],
body.bf-readonly-browse .context-menu-item[data-action="copyto"] { display: none !important; }
body.bf-preview-open { overflow: hidden; touch-action: none; }
@media (min-width: 769px) {
    #modal-preview.modal-overlay.active {
        align-items: stretch;
        justify-content: stretch;
        padding: 1vh 1.5vw;
    }
    #modal-preview .modal-box {
        width: 100%;
        max-width: none;
        max-height: 96vh;
        display: flex;
        flex-direction: column;
        min-height: 0;
        flex: 1;
    }
    #modal-preview .modal-body.preview-content {
        flex: 1;
        overflow: auto;
        min-height: 0;
        max-height: none;
    }
    #modal-preview .preview-content img {
        max-width: 100%;
        width: auto;
        max-height: min(85vh, 1200px);
    }
    #modal-preview .preview-content embed {
        min-height: min(82vh, 900px) !important;
        height: min(82vh, 900px) !important;
    }
    #modal-preview .fd-media-player {
        max-width: 100%;
    }
    #modal-preview .fd-media-player video {
        max-height: min(78vh, 900px) !important;
    }
}
@media (max-width: 768px) {
    #modal-preview .modal-box {
        width: 100%;
        max-width: 100vw;
        max-height: 92vh;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    #modal-preview .modal-body.preview-content {
        flex: 1;
        overflow: auto;
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }
}

/* Video/audio player — tam ekranda bütün idarəetmə paneli görünsün */
.fd-media-player:fullscreen,
.fd-media-player:-webkit-full-screen {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    background: #111;
    box-sizing: border-box;
    padding: 8px 12px 12px;
}
.fd-media-player:fullscreen .fd-media-stage,
.fd-media-player:-webkit-full-screen .fd-media-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fd-media-player:fullscreen .fd-media-stage video,
.fd-media-player:-webkit-full-screen .fd-media-stage video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}
.fd-media-player:fullscreen .fd-media-controls,
.fd-media-player:-webkit-full-screen .fd-media-controls {
    flex-shrink: 0;
    margin-top: 8px;
}
.fd-media-player:fullscreen .file-info,
.fd-media-player:-webkit-full-screen .file-info {
    flex-shrink: 0;
    color: #ddd;
}

/* Apache ErrorDocument — error.php (giriş pəncərəsi ilə uyğun) */
body.fd-http-error-body {
    min-height: 100vh;
    margin: 0;
    padding: 24px 16px;
    box-sizing: border-box;
}
.fd-http-error-window {
    max-width: 440px;
    margin: 48px auto;
}
.fd-http-error-toolbar {
    justify-content: flex-start;
    gap: 10px;
}
.fd-http-error-content {
    padding: 28px 22px 32px;
}
.fd-http-error-lead {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-primary, #222);
}
.fd-http-error-path {
    margin: 0 0 22px;
    font-size: 12px;
    word-break: break-all;
    color: var(--text-muted, #666);
}
.fd-http-error-path-label {
    font-weight: 600;
    margin-right: 6px;
}
.fd-http-error-path code {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
}
body.theme-dark .fd-http-error-path code {
    background: rgba(255, 255, 255, 0.08);
}
body.theme-dark .fd-http-error-lead {
    color: var(--text-primary, #e8e8e8);
}
.fd-http-error-actions {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.fd-http-error-actions .toolbar-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
