/* Базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    padding: 20px;
    transition: all 0.3s ease;
}

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

/* Общие стили для кнопок и карточек */
.btn, .admin-btn, .storage-btn {
    transition: all 0.2s ease;
    cursor: pointer;
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn:hover, .admin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.small-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.small-btn:hover {
    transform: translateY(-1px);
}

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

.header h1 {
    font-size: 28px;
    font-weight: 600;
    margin: 0;
}

/* Переключатель хранилища */
.storage-switch {
    display: flex;
    gap: 8px;
    background: rgba(0,0,0,0.05);
    padding: 4px;
    border-radius: 14px;
}

.storage-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

/* Навигация */
.path {
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 25px;
    font-size: 14px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.path a {
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.path a:hover {
    text-decoration: underline;
}

/* Сетка файлов */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.file-item {
    border-radius: 16px;
    padding: 20px 16px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.file-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.file-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.file-icon img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 12px;
}

.file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    word-break: break-word;
    line-height: 1.4;
}

.file-meta {
    font-size: 11px;
    margin-bottom: 8px;
}

.file-owner {
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 10px;
    display: inline-block;
}

.file-size {
    font-size: 12px;
    margin-bottom: 12px;
}

.file-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.file-actions .small-btn {
    padding: 6px 12px;
    font-size: 12px;
}

/* Модальное окно для фото */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.9);
}

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

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.image-modal-close {
    position: absolute;
    top: -40px;
    right: -40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
}

.image-modal-close:hover {
    transform: rotate(90deg);
    background: rgba(255,255,255,0.3);
}

.image-modal-download {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
    background: #3b82f6;
    color: white;
}

.image-modal-download:hover {
    transform: translateX(-50%) translateY(-2px);
}

/* Модальное окно для форм */
.form-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1001;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
}

.form-modal.show {
    display: flex;
}

.form-modal-content {
    border-radius: 24px;
    padding: 32px;
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.form-modal-content h2 {
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 600;
}

.form-modal-close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-width: 2px;
}

.form-group input[type="file"] {
    padding: 10px;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.submit-btn:hover {
    transform: translateY(-2px);
}

/* Пустая папка */
.empty-folder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    border-radius: 20px;
}

.empty-folder p:first-child {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-folder p:last-child {
    font-size: 16px;
}

/* Выпадающий список темы */
.theme-select {
    padding: 10px 20px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-select:hover {
    border-width: 2px;
}

/* Информация о пользователе */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info span {
    font-weight: 500;
    font-size: 14px;
}

/* Кнопки действий */
.actions-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

/* АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ (квадратные блоки на всю ширину) */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
        padding: 16px 20px;
        width: 100%;
    }
    
    .header h1 {
        font-size: 22px;
        width: 100%;
    }
    
    /* Все блоки на всю ширину */
    .storage-switch,
    .theme-select,
    .user-info,
    .actions-bar,
    .path,
    .empty-folder {
        width: 100%;
    }
    
    /* Переключатель хранилища */
    .storage-switch {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .storage-btn {
        flex: 1;
        min-width: 100px;
        text-align: center;
        justify-content: center;
    }
    
    /* Выбор темы */
    .theme-select {
        width: 100%;
        max-width: none;
    }
    
    /* Информация о пользователе */
    .user-info {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    /* Кнопки действий - на всю ширину */
    .actions-bar {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    
    .actions-bar .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
    
    /* Сетка файлов - одна колонка, квадратные блоки */
    .file-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .file-item {
        padding: 20px 16px;
        text-align: center;
        display: block;
    }
    
    .file-icon {
        font-size: 56px;
        margin-bottom: 12px;
    }
    
    .file-icon img {
        width: 56px;
        height: 56px;
    }
    
    .file-name {
        font-size: 14px;
        margin-bottom: 8px;
        text-align: center;
    }
    
    .file-meta {
        font-size: 11px;
        margin-bottom: 8px;
        text-align: center;
    }
    
    .file-size {
        font-size: 12px;
        margin-bottom: 12px;
        text-align: center;
    }
    
    .file-actions {
        flex-direction: row;
        gap: 8px;
        justify-content: center;
    }
    
    .file-actions .small-btn {
        width: auto;
        min-width: 80px;
        text-align: center;
    }
    
    /* Навигация */
    .path {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Модальные окна */
    .form-modal-content {
        padding: 20px;
        width: calc(100% - 24px);
    }
    
    .form-modal-content h2 {
        font-size: 20px;
    }
    
    /* Пустая папка */
    .empty-folder {
        padding: 40px 20px;
    }
    
    .empty-folder p:first-child {
        font-size: 48px;
    }
    
    .empty-folder p:last-child {
        font-size: 14px;
    }
    
    /* Изображения в модалке */
    .image-modal-close {
        top: -35px;
        right: -35px;
        width: 32px;
        height: 32px;
        font-size: 22px;
    }
    
    .image-modal-download {
        bottom: -45px;
        padding: 8px 20px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .header {
        padding: 14px 16px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .storage-btn {
        min-width: 80px;
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .btn, .admin-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .small-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    .file-item {
        padding: 16px 12px;
    }
    
    .file-icon {
        font-size: 48px;
    }
    
    .file-icon img {
        width: 48px;
        height: 48px;
    }
    
    .file-name {
        font-size: 13px;
    }
    
    .form-modal-content {
        padding: 16px;
    }
    
    .form-modal-content h2 {
        font-size: 18px;
        margin-bottom: 16px;
    }
    
    .submit-btn {
        padding: 10px;
        font-size: 14px;
    }
    
    .form-group {
        margin-bottom: 14px;
    }
    
    .form-group input {
        padding: 10px 14px;
    }
    
    .file-actions .small-btn {
        min-width: 70px;
        padding: 5px 10px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-item {
    animation: fadeIn 0.4s ease forwards;
}