/**
 * Единые стили для всего сайта Маркетплейс
 */

/* === Базовые стили === */
* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; padding: 1rem; background: #f5f5f5; }
.container { max-width: 1200px; margin: 0 auto; }

/* === Верхняя панель === */
.top-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.logo { display: flex; align-items: center; }
.logo img { height: 40px; width: auto; }
.main-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.nav-link { padding: 0.5rem 1rem; border-radius: 6px; text-decoration: none; color: #6c757d; background: #e9ecef; font-size: 0.95rem; }
.nav-link:hover { background: #dee2e6; color: #000; }
.nav-link.active { background: #0d6efd; color: white; }
.auth-buttons { display: flex; gap: 0.5rem; align-items: center; }

/* === Гамбургер меню === */
.hamburger { display: none; flex-direction: column; cursor: pointer; width: 30px; height: 25px; justify-content: space-between; }
.hamburger span { display: block; height: 3px; width: 100%; background: #6c757d; border-radius: 3px; transition: 0.3s; }
.hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(6px, 6px); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(6px, -6px); }
.mobile-menu { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100vh; background: rgba(0,0,0,0.5); z-index: 999; }
.mobile-menu.active { display: block; }
.mobile-menu-content { background: white; width: 280px; height: 100%; padding: 1.5rem; box-shadow: 2px 0 10px rgba(0,0,0,0.1); }
.mobile-menu-content .nav-link { display: block; padding: 0.75rem 1rem; margin-bottom: 0.5rem; }
.mobile-auth { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #eee; display: flex; flex-direction: column; gap: 0.5rem; }

/* === Кнопки === */
.btn { display: inline-flex; justify-content: center; align-items: center; padding: 0.5rem 1.25rem; border-radius: 6px; text-decoration: none; font-size: 0.95rem; border: none; cursor: pointer; text-align: center; white-space: nowrap; box-sizing: border-box; height: 40px; }
.btn-primary { background: #0d6efd; color: white; }
.btn-primary:hover { background: #0b5ed7; }
.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5c636a; }
.auth-btn { background: #0d6efd !important; color: white !important; width: 110px !important; padding: 0.5rem 1.25rem !important; height: 40px !important; }
.auth-btn:hover { background: #0b5ed7 !important; }
.btn-account { background: #198754 !important; color: white !important; width: 110px !important; padding: 0.5rem 1.25rem !important; height: 40px !important; }
.btn-account:hover { background: #146c43 !important; }
.btn-logout { background: #6c757d !important; color: white !important; width: 110px !important; padding: 0.5rem 1.25rem !important; height: 40px !important; }
.btn-logout:hover { background: #5c636a !important; }
.btn-link { background: none !important; border: none !important; color: #0d6efd !important; padding: 0 !important; width: auto !important; height: auto !important; }
.btn-link:hover { text-decoration: underline !important; }

/* === Состояния кнопок авторизации === */
.auth-buttons { visibility: hidden; }
.auth-buttons.ready { visibility: visible; }
.auth-buttons .btn { display: none; }
.auth-buttons .auth-btn { display: inline-block; }
.auth-buttons.logged-in .auth-btn { display: none; }
.auth-buttons.logged-in .btn-account { display: inline-block; }
.auth-buttons.logged-in .btn-logout { display: inline-block; }

/* Мобильное меню */
.mobile-auth { visibility: hidden; }
.mobile-auth.ready { visibility: visible; }
.mobile-auth .btn { display: none; }
.mobile-auth .auth-btn { display: inline-block; }
.mobile-auth.logged-in .auth-btn { display: none; }
.mobile-auth.logged-in .btn-account { display: inline-block; }
.mobile-auth.logged-in .btn-logout { display: inline-block; }

/* === Модальные окна === */
.plugin-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; justify-content: center; align-items: center; }
.plugin-modal.active { display: flex; }
.plugin-modal-content { background: white; border-radius: 12px; max-width: 700px; width: 90%; max-height: 85vh; overflow: hidden; margin: 1rem; display: flex; flex-direction: column; }
.plugin-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid #eee; flex-shrink: 0; }
.plugin-modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.plugin-modal-img { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; margin-bottom: 1rem; }
.plugin-modal-meta { color: #6c757d; font-size: 0.85rem; margin: 1rem 0; }
.plugin-modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #6c757d; padding: 0; line-height: 1; }
.plugin-modal-close:hover { color: #000; }

/* === Поиск === */
.search-container { position: relative; margin-bottom: 1.5rem; }
.search { display: flex; gap: 0.5rem; }
.search input { padding: 0.5rem 0.75rem; border: 1px solid #ccc; border-radius: 6px; min-width: 200px; flex: 1; }
.search button { padding: 0.5rem 1rem; background: #0d6efd; color: white; border: none; border-radius: 6px; cursor: pointer; }
.search button:hover { background: #0b5ed7; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #ddd; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 1000; max-height: 300px; overflow-y: auto; display: none; }
.search-results.active { display: block; }
.search-result-item { padding: 0.75rem 1rem; border-bottom: 1px solid #eee; cursor: pointer; display: flex; align-items: center; gap: 0.75rem; }
.search-result-item:hover { background: #f8f9fa; }
.search-result-item:last-child { border-bottom: none; }
.search-result-img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; background: #e9ecef; }
.search-result-info { flex: 1; min-width: 0; }
.search-result-name { font-weight: 500; margin-bottom: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-desc { font-size: 0.8rem; color: #6c757d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-no-results { padding: 1rem; text-align: center; color: #6c757d; }

/* === Карточки плагинов === */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.card { background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.card-img { width: 100%; object-fit: cover; background: #e9ecef; }
.card-body { padding: 1rem; flex: 1; }
.card-title { margin: 0 0 0.5rem; font-size: 1.1rem; }
.card-desc { margin: 0; color: #6c757d; font-size: 0.9rem; line-height: 1.4; }
.card-footer { padding: 1rem; border-top: 1px solid #eee; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.card-flex { display: flex; flex-direction: column; }

/* === Категории === */
.categories { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.cat-tab { padding: 0.5rem 1rem; border-radius: 6px; text-decoration: none; color: #6c757d; background: #e9ecef; cursor: pointer; border: none; font-size: 0.9rem; }
.cat-tab:hover { background: #dee2e6; }
.cat-tab.active { background: #0d6efd; color: white; }

/* === FAQ === */
.faq-item { border: 1px solid #dee2e6; border-radius: 6px; margin-bottom: 0.5rem; overflow: hidden; }
.faq-question { width: 100%; padding: 1rem 1.5rem; background: #f8f9fa; border: none; text-align: left; font-size: 1rem; font-weight: 500; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.faq-question:hover { background: #e9ecef; }
.faq-question::after { content: '+'; font-size: 1.5rem; color: #6c757d; transition: transform 0.3s; }
.faq-question.active::after { content: '−'; transform: rotate(180deg); }
.faq-answer { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; padding: 0 1.5rem; background: white; }
.faq-answer.open { padding: 1rem 1.5rem; max-height: 500px; }
.faq-answer p { margin: 0; color: #495057; line-height: 1.6; }

/* === Контакты === */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.contact-info h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.contact-item { display: flex; gap: 0.75rem; margin-bottom: 1rem; align-items: flex-start; }
.contact-icon { width: 24px; height: 24px; flex-shrink: 0; color: #0d6efd; }
.contact-text { color: #495057; line-height: 1.5; }
.social-links { display: flex; gap: 1rem; margin-top: 1.5rem; }
.social-link { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 6px; text-decoration: none; font-size: 0.9rem; transition: background 0.2s; }
.social-link.telegram { background: #229ED9; color: white; }
.social-link.telegram:hover { background: #1b7db5; }
.social-link.vk { background: #0077FF; color: white; }
.social-link.vk:hover { background: #0060cc; }
.social-icon { width: 20px; height: 20px; }
.contact-form h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: #495057; }
.form-group input, .form-group textarea { width: 100%; padding: 0.75rem; border: 1px solid #ced4da; border-radius: 6px; font-size: 1rem; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: #0d6efd; box-shadow: 0 0 0 3px rgba(13,110,253,0.1); }
.form-group textarea { resize: vertical; min-height: 120px; }

/* === Сообщения === */
.msg { padding: 1rem; border-radius: 6px; margin-bottom: 1.5rem; }
.msg.success { background: #d1e7dd; color: #0f5132; }
.msg.error { background: #f8d7da; color: #842029; }

/* === Прочее === */
h1 { margin: 0 0 1.5rem; font-size: 1.5rem; }
h2 { margin: 2rem 0 1rem; font-size: 1.25rem; }
.badge { font-size: 0.75rem; padding: 0.2rem 0.5rem; background: #0d6efd; color: white; border-radius: 4px; }
.empty { text-align: center; padding: 3rem; color: #6c757d; }
.loading { text-align: center; padding: 2rem; color: #6c757d; display: none; }
.intro { background: white; padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* === Header на главной === */
header.header-page { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
header.header-page h1 { margin: 0; font-size: 1.5rem; }
header.header-page nav { display: flex; gap: 0.5rem; align-items: center; }

/* === Адаптивность === */
@media (max-width: 768px) {
    .hamburger { display: flex; }
    .main-nav { display: none; }
    .auth-buttons { display: none; }
    .top-bar { grid-template-columns: auto 1fr auto; justify-content: space-between; align-items: center; }
    .hamburger { order: 1; justify-self: start; }
    .logo { order: 2; position: absolute; left: 50%; transform: translateX(-50%); }
    .logo img { height: 35px; }

    .search { flex-direction: column; }
    .search input { min-width: auto; width: 100%; }
    .search-container { min-width: auto; width: 100%; }
    .search-container { min-width: 400px; }
    .search input { min-width: 350px; }

    .contact-grid { grid-template-columns: 1fr; }
    .plugin-modal-content { max-width: 95%; margin: 0.5rem; max-height: 90vh; }
    .plugin-modal-header { padding: 0.75rem 1rem; }
    .plugin-modal-body { padding: 1rem; }
    .plugin-modal-img { height: 150px; }
    
    header.header-page { flex-direction: column; align-items: flex-start; }
    header.header-page h1 { margin: 0 0 1rem; }
    header.header-page nav { width: 100%; justify-content: center; }
}
