:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-header: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-primary: #333333;
    --text-secondary: #5f6368;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --border-light: #f1f3f4;
    --accent-blue: #1a73e8;
    --accent-green: #188038;
    --hover-bg: #f8f9fa;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.dark-theme {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-header: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #888888;
    --border-color: #2d3748;
    --border-light: #2d3748;
    --accent-blue: #63b3ed;
    --accent-green: #68d391;
    --hover-bg: #2d3748;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    background: var(--bg-primary); 
    color: var(--text-primary); 
    line-height: 1.6;
    min-height: 100vh;
    transition: none;
}

body.loaded * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.container { 
    max-width: 100%; 
    margin: 0 auto; 
    background: var(--bg-secondary); 
    min-width: 320px;
    min-height: 100vh;
    box-shadow: var(--shadow);
}

@media (min-width: 768px) {
    .container { 
        max-width: 1000px; 
        margin: 10px auto; 
        min-height: auto;
        border-radius: 8px;
        overflow: hidden;
    }
}

.theme-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 1000;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.dark-theme .theme-toggle {
    background: rgba(0,0,0,0.2);
    color: var(--text-primary);
}

.scroll-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    background: var(--accent-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: rgba(255,255,255,0.3);
}

.dark-theme .theme-toggle:hover {
    background: rgba(0,0,0,0.3);
}

.header { 
    background: var(--bg-header); 
    color: white; 
    padding: 1.5rem 1rem; 
    text-align: center; 
    position: relative;
}

h1 { 
    font-size: 1.8rem; 
    font-weight: 700; 
    margin-bottom: 0.5rem;
}

.content { 
    padding: 1rem; 
    min-width: 0;
}

.breadcrumb { 
    background: var(--bg-primary); 
    padding: 1rem; 
    margin: 0 0 1rem 0; 
    border-bottom: 1px solid var(--border-color); 
    font-size: 0.9rem; 
    overflow-x: auto; 
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.breadcrumb a { 
    color: var(--accent-blue); 
    text-decoration: none; 
    font-weight: 500; 
    display: inline-block;
}

.breadcrumb a:hover { 
    text-decoration: underline; 
}

ul { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
}

li { 
    padding: 1rem 0.5rem; 
    border-bottom: 1px solid var(--border-light); 
    display: flex; 
    align-items: center;
    flex-wrap: wrap;
}

li:last-child { border-bottom: none; }

li:hover { 
    background-color: var(--hover-bg); 
}

/* Стили для строки файла */
.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-grow: 1;
    min-width: 0;
    gap: 1rem;
}

.file-link {
    color: var(--accent-blue);
    font-weight: 500;
    text-decoration: none;
    display: flex;
    align-items: center;
    flex-grow: 1;
    min-width: 0;
}

.dir-link {
    color: var(--accent-green);
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.file-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.size {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    min-width: 70px;
    text-align: right;
}

.file-icon { 
    margin-right: 1rem; 
    font-size: 1.4rem; 
    flex-shrink: 0; 
    width: 24px; 
    text-align: center; 
}

.file-name { 
    flex-grow: 1; 
    min-width: 0; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
    font-size: 0.95rem;
}

.section-title { 
    color: var(--text-secondary); 
    font-size: 0.9rem; 
    font-weight: 600; 
    margin: 1.5rem 0 0.5rem 0; 
    padding: 0.75rem 0.5rem; 
    border-bottom: 2px solid var(--border-light); 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    background: var(--bg-primary);
}

.stats { 
    text-align: center; 
    color: var(--text-secondary); 
    margin-top: 2rem; 
    padding-top: 1.5rem; 
    border-top: 1px solid var(--border-color); 
    font-size: 0.9rem;
}

.empty-state { 
    text-align: center; 
    padding: 3rem 1rem; 
    color: var(--text-secondary); 
}

.empty-state .icon { 
    font-size: 3rem; 
    margin-bottom: 1rem; 
    opacity: 0.5; 
}

.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-content {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.footer-content span,
.footer-content a {
    display: inline;
    vertical-align: baseline;
}

.footer-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
    margin-left: 0.3rem;
}

.footer-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Стили для кнопки предпросмотра */
.preview-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.preview-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    opacity: 1;
    transform: scale(1.05);
}

/* Модальное окно предпросмотра */
.preview-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    overflow: auto;
}

.preview-content {
    background: var(--bg-secondary);
    margin: 2% auto;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.preview-title {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 1rem;
}

.close-preview {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1.2rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.close-preview:hover {
    background: #c82333;
}

.preview-iframe {
    flex-grow: 1;
    border: none;
    background: white;
    min-height: 0;
}

.preview-iframe.pdf {
    background: var(--bg-primary);
}

/* Стили для контейнера изображения */
.preview-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding: 10px;
    background: var(--bg-primary);
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.preview-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: block;
}

/* Улучшаем скроллинг для очень больших изображений */
.preview-modal::-webkit-scrollbar {
    width: 8px;
}

.preview-modal::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

.preview-modal::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}

.preview-modal::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* Адаптивность */
@media (max-width: 768px) {
    .preview-content {
        margin: 2.5% auto;
    }
    
    .preview-header {
        padding: 0.75rem;
    }
    
    .preview-title {
        font-size: 0.9rem;
    }
    
    .preview-image-container {
        padding: 5px;
    }
}

@media (max-width: 480px) {
    .theme-toggle {
        top: 5px;
        right: 5px;
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    .scroll-top {
        bottom: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    .header {
        padding: 1rem 0.5rem;
    }
    h1 {
        font-size: 1.5rem;
        padding: 0 0.5rem;
    }
    .content {
        padding: 0.75rem;
    }
    .breadcrumb {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    li {
        padding: 0.75rem 0.25rem;
    }
    .file-row {
        gap: 0.5rem;
    }
    .file-controls {
        gap: 0.5rem;
    }
    .size {
        font-size: 0.8rem;
        min-width: 60px;
    }
    .file-icon {
        margin-right: 0.75rem;
        font-size: 1.2rem;
        width: 20px;
    }
    .file-name {
        font-size: 0.9rem;
    }
    .section-title {
        font-size: 0.85rem;
        padding: 0.5rem;
        margin: 1rem 0 0.25rem 0;
    }
    .footer {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    .preview-btn {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    .preview-content {
        margin: 1% auto;
        border-radius: 4px;
    }
    .preview-image-container {
        padding: 2px;
    }
    .preview-image {
        border-radius: 4px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
}

@media (max-width: 360px) {
    .container {
        min-width: 100%;
        margin: 0;
    }
    .content {
        padding: 0.5rem;
    }
    .file-name {
        font-size: 0.85rem;
    }
    .size {
        font-size: 0.75rem;
    }
    .file-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    .file-controls {
        align-self: flex-end;
    }
    .file-link {
        width: 100%;
    }
}