/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Контейнеры аутентификации */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-form {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.auth-form button:hover {
    background: #764ba2;
}

.auth-form p {
    text-align: center;
    margin-top: 20px;
}

.auth-form a {
    color: #667eea;
    text-decoration: none;
}

/* OAuth разделитель и кнопка */
.oauth-divider {
    text-align: center;
    margin: 15px 0;
    position: relative;
}
.oauth-divider::before,
.oauth-divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: #ddd;
}
.oauth-divider::before { left: 0; }
.oauth-divider::after { right: 0; }
.oauth-divider span {
    background: white;
    padding: 0 10px;
    color: #666;
    font-size: 14px;
}

.oauth-button {
    display: block;
    width: 100%;
    padding: 12px;
    background: #2d3748;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.3s;
    margin-bottom: 15px;
    box-sizing: border-box;
}
.oauth-button:hover {
    background: #1a202c;
}

/* Dashboard Styles */
.dashboard {
    min-height: 100vh;
    background: #f5f5f5;
}

.header {
    background: white;
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
}

.user-info button:hover {
    background: #c82333;
}

.main-content {
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.storage-info {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.storage-bar {
    background: #e9ecef;
    border-radius: 10px;
    height: 20px;
    margin: 10px 0;
    overflow: hidden;
}

.storage-used {
    background: #667eea;
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s;
}

.upload-area {
    border: 2px dashed #667eea;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
    background: #f8f9ff;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    background: #e3e8ff;
}

.upload-area.dragover {
    background: #e3e8ff;
    border-color: #764ba2;
}

.file-list {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.file-list h3 {
    padding: 20px;
    background: #f8f9fa;
    margin: 0;
    border-bottom: 1px solid #dee2e6;
}

.file-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-item:last-child {
    border-bottom: none;
}

.file-info {
    flex: 1;
}

.file-info strong {
    display: block;
    margin-bottom: 5px;
}

.file-info span {
    color: #666;
    font-size: 14px;
}

.file-actions button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 5px;
    transition: background 0.3s;
}

.file-actions button:hover {
    background: #764ba2;
}

.file-actions button:first-child {
    background: #28a745;
}

.file-actions button:first-child:hover {
    background: #218838;
}

/* Дополнительные стили для dashboard */
.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.refresh-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.refresh-btn:hover {
    background: #5a6268;
}

.files-container {
    min-height: 200px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state p:first-child {
    font-size: 18px;
    margin-bottom: 10px;
}

.file-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.file-item:hover {
    background-color: #f8f9fa;
}

.file-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.file-icon {
    font-size: 24px;
    margin-right: 15px;
}

.file-details {
    flex: 1;
}

.file-name {
    display: block;
    margin-bottom: 5px;
    word-break: break-word;
}

.file-meta {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: #6c757d;
}

.file-actions {
    display: flex;
    gap: 8px;
}

.btn-download, .btn-share, .btn-view, .btn-play, .btn-delete, .btn-open {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
    color: white;
}

.btn-download {
    background: #28a745;
}
.btn-download:hover {
    background: #218838;
}

.btn-share {
    background: #17a2b8;
}
.btn-share:hover {
    background: #138496;
}

.btn-view {
    background: #9C27B0;
}
.btn-view:hover {
    background: #7B1FA2;
}

.btn-play {
    background: #FF5722;
}
.btn-play:hover {
    background: #E64A19;
}

.btn-delete {
    background: #dc3545;
}
.btn-delete:hover {
    background: #c82333;
}

.btn-open {
    background: #28a745;
}
.btn-open:hover {
    background: #218838;
}

.upload-hint {
    font-size: 12px;
    color: #6c757d;
    margin-top: 8px;
}

.upload-progress {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.progress-item {
    margin-bottom: 15px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 14px;
}

.filename {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-text {
    color: #6c757d;
    margin-left: 10px;
}

.progress-bar {
    background: #e9ecef;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #007bff;
    border-radius: 10px;
    transition: width 0.3s, background-color 0.3s;
}

/* Модальное окно для просмотра медиа */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    margin: auto;
    padding: 20px;
    width: 90%;
    height: 90%;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-media {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.modal-video {
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.modal-close:hover {
    background: rgba(255, 0, 0, 0.7);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    z-index: 1001;
}

.modal-prev {
    left: 30px;
}

.modal-next {
    right: 30px;
}

.modal-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-info {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    padding: 10px;
    background: rgba(0, 0, 0, 0.7);
}

.modal-filename {
    font-size: 16px;
    margin-bottom: 5px;
}

.modal-fileinfo {
    font-size: 12px;
    opacity: 0.8;
}

/* Миниатюры для изображений */
.file-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 15px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #666;
}

.file-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* Хлебные крошки */
.breadcrumb {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.breadcrumb-item {
    color: #667eea;
    cursor: pointer;
    text-decoration: none;
}

.breadcrumb-item:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 10px;
    color: #666;
}

/* Панель инструментов */
.toolbar {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-toolbar {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-toolbar:hover {
    background: #764ba2;
}

.btn-toolbar:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.btn-danger {
    background: #dc3545;
}
.btn-danger:hover {
    background: #c82333;
}

.selection-info {
    margin-left: auto;
    color: #666;
    font-size: 14px;
}

/* Стили для папок */
.folders-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.folder-item {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s;
}

.folder-item:hover {
    transform: translateY(-2px);
}

.folder-info {
    display: flex;
    align-items: center;
    flex: 1;
    cursor: pointer;
}

.folder-icon {
    font-size: 32px;
    margin-right: 15px;
}

.folder-details {
    flex: 1;
}

.folder-name {
    display: block;
    margin-bottom: 5px;
    word-break: break-word;
}

.folder-meta {
    font-size: 12px;
    color: #666;
}

.folder-actions {
    display: flex;
    gap: 5px;
}

/* Чекбоксы для файлов */
.file-checkbox {
    margin-right: 15px;
}

.file-select {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.file-item.selected {
    background-color: #e3f2fd;
    border-left: 4px solid #667eea;
}

/* Модальные окна для операций */
.modal-dialog {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    margin: 50px auto;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.modal-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    margin-bottom: 15px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-cancel, .btn-confirm {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

.btn-confirm {
    background: #667eea;
    color: white;
}

.btn-confirm:hover {
    background: #764ba2;
}

/* Аудиоплеер */
.audio-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #333;
    color: white;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.audio-player-content {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.audio-info {
    flex: 1;
}

.audio-info span {
    display: block;
}

#audioTitle {
    font-weight: bold;
    margin-bottom: 5px;
}

#audioTime {
    font-size: 12px;
    color: #ccc;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-btn {
    background: #444;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.audio-btn:hover {
    background: #555;
}

.audio-progress {
    width: 200px;
    height: 5px;
    border-radius: 5px;
}

.audio-close {
    background: #dc3545;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
}

.audio-close:hover {
    background: #c82333;
}

/* Стили для уведомлений о лимите хранилища */
.storage-limit-error,
.storage-warning {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.storage-warning {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Профиль пользователя */
.profile-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #667eea;
}

.profile-header h1 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.btn-back {
    background: #6c757d;
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    text-decoration: none;
    transition: background 0.3s;
    font-size: 14px;
}
.btn-back:hover {
    background: #5a6268;
    text-decoration: none;
}

.profile-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.profile-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    font-size: 20px;
    border-left: 4px solid #667eea;
    padding-left: 15px;
}

.info-grid {
    display: grid;
    gap: 15px;
}

.info-item {
    display: flex;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid #dee2e6;
}

.info-label {
    width: 120px;
    font-weight: 600;
    color: #495057;
}

.info-value {
    flex: 1;
    color: #212529;
}

/* Формы в профиле */
.profile-form .form-group {
    margin-bottom: 20px;
}

.profile-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.profile-form input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}
.profile-form input[type="password"]:focus {
    border-color: #667eea;
    outline: none;
}

.btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}
.btn-primary:hover {
    background: #764ba2;
}

.btn-secondary {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}
.btn-secondary:hover {
    background: #138496;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
}
.btn-danger:hover {
    background: #c82333;
}

/* Сообщения форм */
.form-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 5px;
    display: none;
}
.form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}
.form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* KompNK статус */
.kompnk-status {
    margin-bottom: 20px;
    font-size: 16px;
}
.kompnk-status p {
    margin: 5px 0;
}
#kompnkConnectedText {
    color: #28a745;
}
#kompnkConnectedText:contains("Не привязан") {
    color: #6c757d;
}

/* Адаптивность */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .file-actions {
        align-self: flex-end;
    }
    
    .file-meta {
        flex-direction: column;
        gap: 5px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .selection-info {
        margin-left: 0;
        text-align: center;
    }
    
    .file-actions {
        align-self: stretch;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }
    
    .audio-player-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .audio-controls {
        width: 100%;
        justify-content: center;
    }
    
    .folders-container {
        grid-template-columns: 1fr;
    }
    
    .profile-container {
        margin: 20px;
        padding: 20px;
    }
    
    .profile-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .info-label {
        width: auto;
    }
}