/* ===========================================
   Product Hub — Минималистичный дизайн
   Вдохновлён AURA
   =========================================== */

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

:root {
    /* Цветовая палитра — минималистичная */
    --primary: #3771E4;
    --primary-hover: #2860d4;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --bg-main: #ffffff;
    --bg-sidebar: #fafafa;
    --bg-hover: #f5f5f5;
    --border: #e5e5e5;
    --border-light: #f0f0f0;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #f59e0b;
    --danger: #dc2626;
    
    /* Размеры */
    --sidebar-width: 260px;
    --header-height: 56px;
    
    /* Радиусы */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Отступы */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Утилиты */
.hidden {
    display: none !important;
}

/* ===========================================
   Экраны
   =========================================== */
.screen {
    min-height: 100vh;
}

/* ===========================================
   Экран загрузки
   =========================================== */
#loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
}

.loading-container {
    text-align: center;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===========================================
   Экран авторизации
   =========================================== */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    background: var(--bg-main);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: var(--spacing-2xl);
}

.login-logo {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-section {
    margin-bottom: var(--spacing-xl);
}

.login-instruction {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    font-size: 14px;
}

/* Telegram Login */
.telegram-login {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.telegram-loading {
    color: var(--text-muted);
    font-size: 14px;
}

.telegram-error {
    text-align: center;
    color: var(--error);
    background: var(--error-bg);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 14px;
}

.telegram-error .small {
    font-size: 12px;
    margin-top: var(--spacing-xs);
    color: var(--text-secondary);
}

/* Кнопка входа через Telegram */
.telegram-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.telegram-login-btn:hover {
    background: var(--primary-hover);
}

.telegram-login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.telegram-icon {
    width: 20px;
    height: 20px;
}

.telegram-hint {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.waiting-text {
    color: var(--text-secondary);
}

.error-text {
    color: var(--error);
}

.loading-spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Сообщения */
.error-message {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--error-bg);
    color: var(--error);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
    white-space: pre-line;
}

.success-message {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--success-bg);
    color: var(--success);
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: center;
}

.login-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ===========================================
   Хедер
   =========================================== */
.header {
    height: var(--header-height);
    background: var(--bg-main);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-lg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.header-logo-img {
    height: 28px;
    width: auto;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-display {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===========================================
   Кнопки
   =========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    gap: var(--spacing-xs);
}

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

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

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

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-danger {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border-color: transparent;
}

.btn-danger:hover {
    background: #fecaca;
}

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

/* ===========================================
   Основной лейаут
   =========================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-height);
}

/* ===========================================
   Боковое меню
   =========================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-main);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 50;
}

/* Селектор проекта */
.project-selector {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
}

.project-selector-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
    letter-spacing: 0.5px;
}

.project-select {
    width: 100%;
    padding: 10px 12px;
    padding-right: 32px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.project-select:hover {
    border-color: var(--accent);
}

.project-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.project-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.project-select option {
    padding: 8px 12px;
}

.sidebar-nav {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 400;
    transition: all 0.15s;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(55, 113, 228, 0.1);
    color: var(--primary);
    font-weight: 500;
}

.nav-item.active .nav-icon {
    stroke: var(--primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 1.5;
}

/* ===========================================
   Основной контент
   =========================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--spacing-xl) var(--spacing-2xl);
    max-width: calc(100% - var(--sidebar-width));
}

.content-header {
    margin-bottom: var(--spacing-xl);
}

.content-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.content-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===========================================
   Карточки обзора
   =========================================== */
.sections-overview {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.overview-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.15s;
}

.overview-card:hover {
    border-color: var(--text-muted);
}

.overview-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-sidebar);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.overview-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-secondary);
    stroke-width: 1.5;
}

.overview-info {
    flex: 1;
    min-width: 0;
}

.overview-info h3 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.overview-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.overview-link {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.15s;
}

.overview-link:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

/* ===========================================
   Страницы разделов
   =========================================== */
.page-header {
    margin-bottom: var(--spacing-xl);
}

.page-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Placeholder */
.tools-section {
    margin-top: var(--spacing-lg);
}

.placeholder-message {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-message .placeholder-icon {
    font-size: 32px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.placeholder-message p {
    font-size: 14px;
}

/* Секция-заглушка для главной страницы */
.placeholder-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-lg);
    margin-top: var(--spacing-2xl);
}

.placeholder-section .placeholder-icon {
    margin-bottom: var(--spacing-lg);
    color: var(--text-muted);
    opacity: 0.5;
}

.placeholder-section h2 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.placeholder-section p {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 400px;
    line-height: 1.6;
}

/* ===========================================
   Модалки
   =========================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: var(--spacing-lg);
}

/* ===========================================
   Админ-панель
   =========================================== */
.admin-section {
    margin-bottom: var(--spacing-xl);
}

.admin-section:last-child {
    margin-bottom: 0;
}

.admin-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.settings-note {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.settings-note a {
    color: var(--primary);
    text-decoration: none;
}

.settings-note a:hover {
    text-decoration: underline;
}

.add-user-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.add-user-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s;
}

.add-user-form input:focus {
    outline: none;
    border-color: var(--text-muted);
}

.add-user-form input::placeholder {
    color: var(--text-muted);
}

.users-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
}

.user-item:last-child {
    border-bottom: none;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.username {
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: var(--spacing-xs);
}

.user-id {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

.user-note {
    font-size: 12px;
    color: var(--text-secondary);
}

.admin-badge {
    display: inline-block;
    font-size: 11px;
    background: var(--bg-sidebar);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 100px;
    margin-left: var(--spacing-sm);
}

.empty-list,
.error-list,
.loading-inline {
    padding: var(--spacing-lg);
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.error-list {
    color: var(--error);
}

/* ===========================================
   Адаптивность
   =========================================== */
@media (max-width: 1024px) {
    .main-content {
        padding: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: var(--spacing-md);
    }
    
    .header {
        padding: 0 var(--spacing-md);
    }
    
    .content-header h1 {
        font-size: 20px;
    }
    
    .overview-card {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .overview-link {
        width: 100%;
        text-align: center;
        margin-top: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: var(--spacing-lg);
    }
    
    .login-logo h1 {
        font-size: 20px;
    }
}

/* ===========================================
   Баг-репортер
   =========================================== */

/* Кнопка в хедере */
.bug-report-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    animation: subtle-glow 3s ease-in-out infinite;
}

.bug-report-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

.bug-report-btn svg {
    width: 14px;
    height: 14px;
}

@keyframes subtle-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(55, 113, 228, 0);
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(55, 113, 228, 0.15);
    }
}

/* Оверлей для выделения области */
.bug-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.3);
    cursor: crosshair;
}

.selection-hint {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-main);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001;
}

.selection-box {
    position: fixed;
    border: 2px dashed var(--primary);
    background: rgba(55, 113, 228, 0.1);
    pointer-events: none;
    z-index: 10001;
}

/* Модальное окно баг-репорта */
.bug-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.bug-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.bug-modal-content {
    position: relative;
    background: var(--bg-main);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
}

.bug-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.bug-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.bug-modal-body {
    padding: var(--spacing-lg);
}

.bug-screenshot-preview {
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.bug-screenshot-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.bug-screenshot-preview .remove-screenshot {
    margin-top: var(--spacing-sm);
}

.bug-description-container {
    position: relative;
}

.bug-description-container textarea {
    width: 100%;
    padding: var(--spacing-md);
    padding-right: 50px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 100px;
}

.bug-description-container textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.bug-description-container .voice-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.bug-description-container .voice-btn:hover {
    background: var(--border);
}

.bug-description-container .voice-btn.recording {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
    animation: pulse-recording 1s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.bug-hint {
    margin-top: var(--spacing-sm);
    font-size: 12px;
    color: var(--text-muted);
}

.bug-modal-footer {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
}

/* Toast уведомление */
.bug-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--success);
    color: white;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10001;
}

.bug-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.bug-toast svg {
    width: 20px;
    height: 20px;
}
