* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f4f8;
    color: #1e2a3a;
    transition: background 0.3s, color 0.3s;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Панель входа */
.login-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    padding: 30px;
    width: 350px;
    text-align: center;
    transition: background 0.3s;
}

.card h2 {
    margin-bottom: 20px;
    color: #0a4b7a;
}

.input-group {
    display: flex;
    align-items: center;
    background: #f0f4f8;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
}

.input-group i {
    color: #6c86a3;
    width: 24px;
}

.input-group input {
    border: none;
    background: transparent;
    padding: 12px 0;
    width: 100%;
    outline: none;
    font-size: 14px;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: #1e6f9f;
    color: white;
}
.btn-primary:hover {
    background: #0a4b7a;
}

.btn-secondary {
    background: #e2e8f0;
    color: #1e2a3a;
}
.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-small {
    background: #e2e8f0;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}
.btn-small:hover {
    background: #cbd5e1;
}

/* Шапка */
.app-header {
    background: white;
    border-radius: 16px;
    padding: 15px 25px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

.app-header h1 {
    font-size: 1.6rem;
    color: #0a4b7a;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

#logout-btn {
    background-color: #dc3545;
    color: white;
}
#logout-btn:hover {
    background-color: #c82333;
}

/* Поиск и сортировка */
.search-bar {
    background: white;
    border-radius: 40px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px 0;
    font-size: 14px;
    background: transparent;
    color: #1e2a3a;
}
.search-bar input::placeholder {
    color: #6c86a3;
}

#sort-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: white;
}

/* Drag & Drop зона */
.dropzone {
    border: 2px dashed #ccc;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
    border-radius: 16px;
    background: #fafafa;
    transition: background 0.2s;
    cursor: pointer;
}
.dropzone.drag-over {
    background: #e9ecef;
    border-color: #007bff;
}

/* Две колонки */
.main-layout {
    display: flex;
    gap: 20px;
}

.folders-panel {
    flex: 1;
    background: white;
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

.files-panel {
    flex: 3;
    background: white;
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
}

.panel-header h3 {
    font-size: 1.2rem;
    color: #1e2a3a;
}

/* Дерево папок */
.folder-tree {
    max-height: 500px;
    overflow-y: auto;
}

.folder-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 8px;
    margin: 2px 0;
    transition: 0.1s;
}
.folder-item:hover {
    background: #eef2f6;
}
.folder-item.selected {
    background: #d9e9f7;
    font-weight: bold;
    color: #0a4b7a;
}
.folder-name {
    font-size: 14px;
}
.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #dc3545;
    transition: background 0.2s, color 0.2s;
}
.btn-icon:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #a71d2a;
}

/* Список файлов */
.file-list {
    list-style: none;
}
.file-list li {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.file-list li .file-name {
    flex: 2;
    cursor: pointer;
}
.file-checkbox {
    margin-right: 8px;
}

/* Контекстное меню */
.custom-context-menu {
    position: fixed;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 5px 0;
    min-width: 150px;
    z-index: 10000;
}
.custom-context-menu .menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
}
.custom-context-menu .menu-item:hover {
    background: #f0f0f0;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: white;
    border-radius: 16px;
    width: 500px;
    max-width: 90%;
    padding: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.modal-content h3 {
    margin-bottom: 15px;
    color: #0a4b7a;
}
.modal-content input {
    width: 100%;
    padding: 10px;
    margin: 15px 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
}
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
}
.modal-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.modal-buttons button:first-child {
    background-color: #28a745;
    color: white;
}
.modal-buttons button:first-child:hover {
    background-color: #218838;
}
.modal-buttons button:last-child {
    background-color: #6c757d;
    color: white;
}
.modal-buttons button:last-child:hover {
    background-color: #5a6268;
}

/* Модальное окно выбора папки (перемещение) */
#move-folder-modal .modal-content {
    width: 400px;
}
#move-folder-tree {
    max-height: 300px;
    overflow-y: auto;
    margin: 15px 0;
    text-align: left;
}
#move-folder-tree .folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}
#move-folder-tree .folder-item:hover {
    background: #eef2f6;
}
#move-folder-tree .folder-item i {
    width: 20px;
    color: #f0ad4e;
}
#move-folder-tree .folder-item span {
    flex: 1;
}

/* Модальное окно предпросмотра */
#preview-modal .modal-content {
    width: 700px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}
#preview-content {
    margin: 15px 0;
    text-align: center;
}
#preview-content img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
#preview-content pre {
    text-align: left;
    max-height: 60vh;
    overflow: auto;
    background: #f5f5f5;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}
#preview-close {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
}
#preview-close:hover {
    background-color: #5a6268;
}

/* Модальное окно версий */
#versions-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 15px 0;
    text-align: left;
}
.version-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
}
.version-item button {
    margin-left: 8px;
    padding: 4px 8px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.version-item button:hover {
    background-color: #0056b3;
}
#close-modal-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    margin-top: 10px;
}
#close-modal-btn:hover {
    background-color: #5a6268;
}

/* Кнопки в корзине */
.buttons-wrapper {
    display: flex;
    gap: 8px;
}
.buttons-wrapper button {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
}
.buttons-wrapper button:first-child {
    background-color: #28a745;
}
.buttons-wrapper button:first-child:hover {
    background-color: #218838;
}
.buttons-wrapper button:last-child {
    background-color: #dc3545;
}
.buttons-wrapper button:last-child:hover {
    background-color: #c82333;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    z-index: 2000;
    transition: opacity 0.3s;
    display: none;
    opacity: 1;
}
.toast.success { background: #28a745; }
.toast.error { background: #dc3545; }
.toast.info { background: #17a2b8; }
.toast.warning { background: #ffc107; color: #212529; }

.message, #app-message {
    margin-top: 15px;
    font-size: 13px;
    text-align: center;
}

/* Тёмная тема */
body.dark {
    background: #1e2a3a;
    color: #e2e8f0;
}
body.dark .card,
body.dark .app-header,
body.dark .folders-panel,
body.dark .files-panel,
body.dark .search-bar,
body.dark .modal-content,
body.dark .dropzone,
body.dark .custom-context-menu {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
}
body.dark .app-header h1,
body.dark .panel-header h3,
body.dark .card h2 {
    color: #ffffff;
}
body.dark .btn-primary {
    background: #2b6cb0;
}
body.dark .btn-primary:hover {
    background: #2c5282;
}
body.dark .btn-secondary,
body.dark .btn-small {
    background: #4a5568;
    color: #e2e8f0;
}
body.dark .btn-secondary:hover,
body.dark .btn-small:hover {
    background: #2d3748;
}
body.dark .folder-item:hover,
body.dark .file-list li:hover {
    background: #4a5568;
}
body.dark .folder-item.selected {
    background: #2b6cb0;
    color: white;
}
body.dark .btn-icon {
    color: #f8d7da;
}
body.dark .btn-icon:hover {
    background: rgba(248, 215, 218, 0.2);
    color: #ffc0c0;
}
body.dark .custom-context-menu .menu-item:hover {
    background: #4a5568;
}
body.dark .input-group {
    background: #4a5568;
    border-color: #2d3748;
}
body.dark .input-group input {
    color: #e2e8f0;
}
body.dark .input-group input::placeholder {
    color: #a0aec0;
}
body.dark #sort-select {
    background: #4a5568;
    color: #e2e8f0;
    border-color: #2d3748;
}
body.dark .modal-content input {
    background: #4a5568;
    color: #e2e8f0;
    border-color: #2d3748;
}
body.dark #move-folder-tree .folder-item:hover {
    background: #4a5568;
}
body.dark #preview-content pre {
    background: #2d3748;
    color: #e2e8f0;
}
body.dark .version-item button {
    background-color: #2b6cb0;
}
body.dark .version-item button:hover {
    background-color: #2c5282;
}
body.dark #close-modal-btn {
    background-color: #4a5568;
}
body.dark #close-modal-btn:hover {
    background-color: #2d3748;
}
body.dark .buttons-wrapper button:first-child {
    background-color: #2e7d32;
}
body.dark .buttons-wrapper button:last-child {
    background-color: #c62828;
}
body.dark .search-bar input {
    color: #e2e8f0;
}
body.dark .search-bar input::placeholder {
    color: #a0aec0;
}
body.dark .search-bar i {
    color: #cbd5e1;
}
/* Прогресс-бар в тёмной теме */
body.dark #upload-progress {
    background: rgba(30, 30, 30, 0.9);
}

/* Адаптив */
@media (max-width: 800px) {
    .main-layout {
        flex-direction: column;
    }
    .search-bar {
        flex-direction: column;
        align-items: stretch;
        border-radius: 16px;
    }
    .search-bar input {
        width: 100%;
    }
    .file-list li {
        flex-direction: column;
        align-items: stretch;
    }
    #dropzone {
        display: none;
    }
}
