﻿/* static/style.css - ПОЛНОСТЬЮ ПЕРЕПИСАН */
:root {
    --primary: #1976d2;
    --primary-dark: #1565c0;
    --primary-light: #42a5f5;
    --secondary: #ff4081;
    --surface: #ffffff;
    --background: #f5f7fa;
    --on-surface: #212121;
    --on-surface-medium: #666666;
    --on-surface-light: #9e9e9e;
    --border: #e0e0e0;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-small: 8px;
}

[data-theme="dark"] {
    /* Тёмная тема */
    --primary: #42a5f5;
    --primary-dark: #1976d2;
    --primary-light: #90caf9;
    --secondary: #f48fb1;
    --surface: #1e1e1e;
    --background: #121212;
    --on-surface: #e0e0e0;
    --on-surface-medium: #a0a0a0;
    --on-surface-light: #666666;
    --border: #333333;
    --success: #66bb6a;
    --warning: #ffb74d;
    --error: #f44336;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--on-surface);
    background: var(--background);
    font-size: 14px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Переключатель темы */
.theme-toggle {
    background: none;
    border: none;
    color: var(--on-surface-medium);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-small);
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

    .theme-toggle:hover {
        background: var(--background);
        color: var(--primary);
    }


/* Логотип с изображением */
.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 1rem;
}

/* Обновлённые стили для тёмной темы */
[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
}

[data-theme="dark"] .network-info {
    background: linear-gradient(135deg, #485563 0%, #29323c 100%);
}

[data-theme="dark"] .app-icon,
[data-theme="dark"] .app-detail-icon,
[data-theme="dark"] .logo-icon {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

/* Улучшенные тени для тёмной темы */
[data-theme="dark"] .app-card,
[data-theme="dark"] .section,
[data-theme="dark"] .auth-card,
[data-theme="dark"] .download-progress {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Инвертированные иконки для тёмной темы */
[data-theme="dark"] .fas,
[data-theme="dark"] .fab {
    filter: brightness(0.9);
}

.logo-image {
    height: 32px;
    width: auto;
    border-radius: 6px;
}

/* Навигация */
.navbar {
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.logo-icon {
    font-size: 1.8rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--on-surface-medium);
}

.nav-link {
    color: var(--on-surface);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-small);
    transition: all 0.2s ease;
    font-weight: 500;
}

    .nav-link:hover {
        background: var(--background);
        color: var(--primary);
    }

    .nav-link.primary {
        background: var(--primary);
        color: white;
    }

        .nav-link.primary:hover {
            background: var(--primary-dark);
        }

/* Основной контейнер */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* Hero секция */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 60px 0;
    border-radius: var(--radius);
    margin-bottom: 32px;
    text-align: center;
}

    .hero h1 {
        font-size: 2.5rem;
        margin-bottom: 16px;
        font-weight: 700;
    }

    .hero p {
        font-size: 1.2rem;
        opacity: 0.9;
        max-width: 600px;
        margin: 0 auto;
    }

/* Сетка приложений */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.app-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

    .app-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-hover);
    }

.app-card-header {
    padding: 20px 20px 0;
}

.app-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 16px;
}

.app-card-body {
    padding: 0 20px 20px;
}

.app-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--on-surface);
}

.app-developer {
    color: var(--on-surface-medium);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.app-description {
    color: var(--on-surface-medium);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.app-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.app-version {
    background: var(--background);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--on-surface-medium);
}

.app-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--warning);
    font-size: 0.9rem;
}

.app-actions {
    display: flex;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-small);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    flex: 1;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

    .btn-primary:hover {
        background: var(--primary-dark);
        transform: translateY(-1px);
    }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

    .btn-outline:hover {
        background: var(--primary);
        color: white;
    }

/* Детали приложения */
.app-detail-header {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.app-detail-hero {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.app-detail-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    flex-shrink: 0;
}

.app-detail-info {
    flex: 1;
}

    .app-detail-info h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
        font-weight: 600;
    }

.app-detail-developer {
    color: var(--on-surface-medium);
    font-size: 1rem;
    margin-bottom: 16px;
}

.app-detail-meta {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meta-label {
    font-size: 0.8rem;
    color: var(--on-surface-light);
}

.meta-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--on-surface);
}

.app-detail-actions {
    display: flex;
    gap: 12px;
}

.btn-large {
    padding: 12px 32px;
    font-size: 1rem;
    min-width: 140px;
}

.btn-success {
    background: var(--success);
    color: white;
}

    .btn-success:hover {
        background: #45a049;
        transform: translateY(-1px);
    }

/* Секции */
.section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

    .section h2 {
        font-size: 1.3rem;
        font-weight: 600;
        margin-bottom: 16px;
        color: var(--on-surface);
    }

/* Комментарии */
.comment {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

    .comment:last-child {
        border-bottom: none;
    }

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.comment-author {
    font-weight: 500;
    color: var(--on-surface);
}

.comment-date {
    font-size: 0.8rem;
    color: var(--on-surface-light);
}

.comment-text {
    color: var(--on-surface-medium);
    line-height: 1.5;
}

.comment-form {
    margin-top: 20px;
}

.form-group {
    margin-bottom: 20px;
}

    .form-group label {
        display: block;
        margin-bottom: 8px;
        font-weight: 500;
        color: var(--on-surface);
    }

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background: var(--surface);
    color: var(--on-surface);
}

    .form-control:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
    }

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Формы авторизации */
.auth-container {
    max-width: 400px;
    margin: 40px auto;
    padding: 0 20px;
}

.auth-card {
    background: var(--surface);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    text-align: center;
}

    .auth-card h2 {
        font-size: 1.5rem;
        margin-bottom: 8px;
        font-weight: 600;
    }

    .auth-card p {
        color: var(--on-surface-medium);
        margin-bottom: 32px;
    }

/* Прогресс загрузки */
.download-progress {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin: 24px 0;
    box-shadow: var(--shadow);
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #66bb6a);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--on-surface-medium);
}

/* Сетевой информер */
.network-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    text-align: center;
}

    .network-info p {
        margin: 0;
        font-size: 0.9rem;
    }

.network-address {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-family: monospace;
    font-weight: 500;
    margin-top: 8px;
    display: inline-block;
}

/* Уведомления */
.flash-message {
    background: var(--success);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-small);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

    .flash-message.error {
        background: var(--error);
    }

    .flash-message.warning {
        background: var(--warning);
    }

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .apps-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 16px;
    }

    .app-detail-hero {
        flex-direction: column;
        text-align: center;
    }

    .app-detail-meta {
        justify-content: center;
        flex-wrap: wrap;
    }

    .app-detail-actions {
        flex-direction: column;
    }

    .nav-links {
        gap: 12px;
    }

    .nav-user span {
        display: none;
    }

    .hero {
        padding: 40px 20px;
    }

        .hero h1 {
            font-size: 2rem;
        }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-card, .section {
    animation: fadeIn 0.5s ease;
}

/* Состояния загрузки */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Кастомный скроллбар */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--on-surface-light);
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--on-surface-medium);
    }

/* Выпадающее меню пользователя */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropbtn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-small);
    background: transparent;
    color: var(--on-surface);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

    .dropbtn:hover {
        background: var(--background);
        color: var(--primary);
    }

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--surface);
    min-width: 200px;
    box-shadow: var(--shadow-hover);
    border-radius: var(--radius);
    z-index: 1001;
    overflow: hidden;
    margin-top: 8px;
}

    .dropdown-content.show {
        display: block;
        animation: fadeIn 0.2s ease;
    }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--on-surface);
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.9rem;
}

    .dropdown-item:hover {
        background: var(--background);
        color: var(--primary);
    }

    .dropdown-item.user-info {
        background: var(--primary-light);
        color: white;
        font-weight: 500;
        cursor: default;
    }

        .dropdown-item.user-info:hover {
            background: var(--primary-light);
            color: white;
        }

/* Адаптивность для выпадающего меню */
@media (max-width: 768px) {
    .dropbtn span:not(.fa) {
        display: none;
    }

    .dropbtn {
        padding: 8px 12px;
    }

    .dropdown-content {
        right: -10px;
        min-width: 180px;
    }
}

/* Стили для системы оценок */
.rating-system {
    margin: 20px 0;
}

.rating-stars {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.rating-star {
    font-size: 1.5rem;
    color: var(--on-surface-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

    .rating-star:hover {
        transform: scale(1.2);
    }

    .rating-star.active {
        color: var(--warning);
    }

    .rating-star.saved {
        color: var(--warning);
    }

.rating-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--on-surface-medium);
}

.rating-average {
    font-weight: 600;
    color: var(--on-surface);
}

.rating-count {
    color: var(--on-surface-light);
}

.rating-user {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--on-surface-light);
}

/* Обновим существующие стили рейтинга */
.app-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--warning);
    font-size: 0.9rem;
}

    .app-rating .rating-stars {
        margin-bottom: 0;
        gap: 1px;
    }

    .app-rating .rating-star {
        font-size: 0.8rem;
        cursor: default;
    }

        .app-rating .rating-star:hover {
            transform: none;
        }

/* Стили для отображения рейтинга в карточке */
.app-card-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.app-card-rating-stars {
    display: flex;
    gap: 1px;
}

.app-card-rating-star {
    font-size: 0.8rem;
    color: var(--warning);
}

.app-card-rating-text {
    font-size: 0.8rem;
    color: var(--on-surface-light);
}

/* Стили для круглого прогресс-бара */
.app-detail-icon-container {
    position: relative;
    display: inline-block;
}

.download-progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 8px;
    box-sizing: border-box;
}

    .download-progress-overlay svg {
        position: relative;
        z-index: 1;
    }

    .download-progress-overlay .progress-text {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
        color: white;
        font-size: 0.75rem;
        line-height: 1.2;
        font-weight: bold;
        z-index: 2;
    }

/* Ограничение описания */
.app-description-text {
    color: var(--on-surface-medium);
    line-height: 1.6;
    white-space: pre-wrap;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    /* Ограничение по высоте для 5 строк */
    max-height: 8em; /* примерно 5 строк при line-height 1.6 */
}

    .app-description-text.collapsed {
        max-height: 8em;
        overflow: hidden;
    }

    .app-description-text.expanded {
        max-height: none;
    }

    /* Индикатор "ещё" для обрезанного текста */
    .app-description-text.collapsed::after {
        content: " ещё";
        position: absolute;
        bottom: 0;
        right: 0;
        background: linear-gradient(90deg, transparent, var(--surface) 30%);
        padding-left: 20px;
        color: var(--on-surface-light);
        font-weight: bold;
    }