/* common-components.css - Общие компоненты для всего проекта */

/* ==================== ОБЩИЕ КОМПОНЕНТЫ ==================== */

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    text-align: center;
}

.btn-primary {
    background: var(--sea-turquoise);
    color: var(--dark-blue);
}

.btn-primary:hover {
    background: #4a9ca8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--section-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--card-bg);
    border-color: var(--sea-turquoise);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

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

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

/* Формы */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-label {
    font-weight: 600;
    color: var(--text);
    font-size: 0.9rem;
}

.form-input,
.form-textarea {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text);
    transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--sea-turquoise);
    box-shadow: 0 0 0 3px rgba(95, 170, 184, 0.1);
}

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

.form-help {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Базовые стили карточек */
.card-base {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* ==================== СТИЛИ ДЛЯ ПОДСКАЗОК (ОБЩИЕ) ==================== */

/* Базовые стили для триггеров подсказок таблиц */
.table-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    border-bottom: 1px dotted var(--sea-turquoise);
}

/* Правильное позиционирование подсказок таблиц */
.table-tiptext {
    display: none;
    position: fixed;
    z-index: 1500;
    background: var(--dark-blue);
    color: var(--light-beige);
    padding: 12px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.4;
    max-width: 320px;
    min-width: 200px;
    word-wrap: break-word;
    white-space: normal;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Показываем подсказку при наведении */
.table-tooltip:hover .table-tiptext {
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Стрелка подсказки */
.table-tiptext::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    background: inherit;
    transform: rotate(45deg);
}

/* Позиционирование стрелки */
.table-tiptext[data-placement^="top"]::after {
    bottom: -4px;
    left: 50%;
    margin-left: -4px;
}

.table-tiptext[data-placement^="bottom"]::after {
    top: -4px;
    left: 50%;
    margin-left: -4px;
}

.table-tiptext[data-placement^="left"]::after {
    right: -4px;
    top: 50%;
    margin-top: -4px;
}

.table-tiptext[data-placement^="right"]::after {
    left: -4px;
    top: 50%;
    margin-top: -4px;
}

/* ==================== ЦВЕТОВЫЕ КЛАССЫ ДЛЯ ЗНАЧЕНИЙ ==================== */

.val-positive {
    color: var(--green) !important;
}

.val-negative {
    color: var(--red) !important;
}

.val-neutral {
    color: var(--sea-turquoise) !important;
}

/* ==================== СТИЛИ ДЛЯ ПОЛОЖИТЕЛЬНЫХ/ОТРИЦАТЕЛЬНЫХ ЗНАЧЕНИЙ ==================== */

.positive {
    color: var(--green);
}

.negative {
    color: var(--red);
}

.neutral {
    color: var(--sea-turquoise);
}

/* ==================== УВЕДОМЛЕНИЯ (NOTIFICATIONS) ==================== */

/* Базовые стили для уведомлений */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--sea-turquoise);
    color: white;
    border-radius: 8px;
    z-index: 10000;
    box-shadow: var(--shadow);
    font-weight: 600;
    transition: all 0.3s ease;
}

.notification.success {
    background: var(--green);
}

.notification.error {
    background: var(--red);
}

.notification.warning {
    background: var(--orange);
}

/* Анимации для уведомлений */
@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.notification.slide-in {
    animation: notificationSlideIn 0.3s ease forwards;
}

.notification.slide-out {
    animation: notificationSlideOut 0.3s ease forwards;
}

/* ==================== ОБЩИЕ КЛАССЫ ДЛЯ МЕТРИК ==================== */

/* Карточка метрики (общий стиль) */
.metric-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid var(--border);
}

.metric-name {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.metric-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.metric-value.positive {
    color: var(--green);
}

.metric-value.negative {
    color: var(--red);
}

.metric-value.neutral {
    color: var(--sea-turquoise);
}

/* ==================== ОБЩИЕ СТИЛИ ДЛЯ МОДАЛЬНЫХ ОКОН ==================== */

/* Закрывающая кнопка для модальных окон */
.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: #a0aec0;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background-color: #f7fafc;
    color: var(--text);
}

/* ==================== ВСПОМОГАТЕЛЬНЫЕ КЛАССЫ ==================== */

/* Скрытие элементов */
.hidden {
    display: none !important;
}

/* Показ элементов */
.visible {
    display: block !important;
}

/* Гибкий контейнер */
.flex-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ==================== ДОПОЛНИТЕЛЬНЫЕ ОБЩИЕ КЛАССЫ ==================== */

/* Общие контейнеры */
/* УДАЛЕНО: .mobile-actions-container - контейнер удален из HTML */

/* Контейнеры для мобильной версии */
.mobile-prices-container {
    margin: 0 16px 20px;
}

.mobile-prices-container .financials-mobile-card {
    margin-bottom: 0;
}

/* Секции цен */
.financials-price-section {
    margin-bottom: 16px;
}

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

.financials-price-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    padding-left: 4px;
}

/* Контейнеры для мобильных вкладок */
.mobile-tab-contents {
    width: 100%;
}

.mobile-tab-contents .mobile-tab-content {
    display: none;
    padding: 16px;
}

.mobile-tab-contents .mobile-tab-content.active {
    display: block;
}

/* Общие стили для финансовых карточек на мобильных */
.financials-mobile-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    overflow: hidden;
}

.financials-mobile-card.active {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--sea-turquoise);
}

.financials-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
}

.financials-sector-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.financials-card-toggle {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--sea-turquoise);
    font-size: 1.2rem;
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.financials-card-toggle:hover {
    background: rgba(95, 170, 184, 0.1);
}

.financials-card-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    margin-bottom: 12px;
}

.financials-summary-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

.financials-summary-label {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 500;
    min-width: 80px;
}

.financials-summary-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    flex: 1;
}

.financials-card-details {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    padding-top: 0;
    border-top: 1px solid transparent;
}

.financials-mobile-card.active .financials-card-details {
    max-height: 200px;
    opacity: 1;
    padding-top: 12px;
    border-top-color: var(--border-light);
}

/* Разделители */
.financials-card-separator {
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--border) 20%, 
        var(--border) 80%, 
        transparent 100%);
    margin: 8px 0;
}

/* Горизонтальный скролл по годам */
.financials-years-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--sea-turquoise) rgba(95, 170, 184, 0.08);
    padding-bottom: 8px;
    scroll-behavior: smooth;
}

.financials-years-scroll-wrapper::-webkit-scrollbar {
    height: 6px;
}

.financials-years-scroll-wrapper::-webkit-scrollbar-track {
    background: rgba(95, 170, 184, 0.08);
    border-radius: 3px;
}

.financials-years-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--sea-turquoise);
    border-radius: 3px;
    opacity: 0.5;
}

.financials-years-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    opacity: 0.8;
}

.financials-years-scroll {
    display: flex;
    gap: 16px;
    min-width: min-content;
    padding: 0 4px;
}

.financials-year-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    padding: 8px;
    background: var(--section-bg);
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.financials-year-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 4px;
    white-space: nowrap;
}

.financials-year-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    text-align: center;
}

.financials-year-growth {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
    }
    
    .form-input,
    .form-textarea {
        padding: 10px 14px;
    }
    
    /* Скрываем десктопные таблицы внутри вкладок на мобильных */
    .mobile-tab-content .table-desktop {
        display: none !important;
    }
    
    .mobile-tab-content .table-mobile {
        display: block !important;
    }
    
    /* Специфичные мобильные стили для финансовых карточек */
    .financials-year-column {
        min-width: 60px;
        padding: 6px;
    }
    
    .financials-year-value {
        font-size: 0.9rem;
    }
    
    .financials-year-header {
        font-size: 0.8rem;
    }
    
    .financials-sector-title {
        font-size: 0.95rem;
    }
    
    /* Уведомления на мобильных */
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .form-actions {
        flex-direction: column;
    }
    
    /* Очень маленькие экраны - дополнительные стили */
    .financials-year-column {
        min-width: 55px;
        padding: 4px;
    }
    
    .financials-year-value {
        font-size: 0.85rem;
    }
    
    .financials-year-header {
        font-size: 0.75rem;
    }
    
    .financials-sector-title {
        font-size: 0.9rem;
    }
    
    .financials-summary-label {
        font-size: 0.85rem;
        min-width: 70px;
    }
    
    .financials-summary-value {
        font-size: 0.9rem;
    }
}

/* Планшеты */
@media (min-width: 481px) and (max-width: 768px) {
    .financials-year-column {
        min-width: 80px;
    }
}

/* ==================== ТЕМНАЯ ТЕМА ДЛЯ ДОБАВЛЕННЫХ КОМПОНЕНТОВ ==================== */

:root[data-theme="dark"] .financials-mobile-card {
    background: var(--card-bg);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .financials-mobile-card.active {
    border-color: var(--sea-turquoise);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] .financials-year-column {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .financials-card-separator {
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.1) 20%, 
        rgba(255, 255, 255, 0.1) 80%, 
        transparent 100%);
}

/* Темная тема для уведомлений */
:root[data-theme="dark"] .notification {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] .close-modal:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Темная тема для карточек метрик */
:root[data-theme="dark"] .metric-card {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .metric-name {
    color: rgba(255, 255, 255, 0.6);
}

/* ==================== ПОДСКАЗКИ БЕЗ СТРЕЛОК ==================== */

/* Скрываем оригинальные подсказки */
#detail-modal .table-tiptext {
    display: none !important;
}

/* Подсказки без стрелок */
.enhanced-tooltip-no-arrow {
    position: fixed !important;
    z-index: 10001 !important;
    background: #0D1A29 !important;
    background-color: #0D1A29 !important;
    opacity: 1 !important;
    max-width: 480px !important;
    min-width: 350px !important;
    width: auto !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6) !important;
    border: 2px solid #5FAAB8 !important;
    border-radius: 12px !important;
    padding: 20px !important;
    line-height: 1.5 !important;
    color: #F8F4F2 !important;
    font-size: 13px !important;
    pointer-events: none;
}

/* Мобильные подсказки */
@media (max-width: 768px) {
    .enhanced-tooltip-no-arrow {
        max-width: 280px !important;
        min-width: 250px !important;
        width: 280px !important;
        padding: 12px !important;
        font-size: 12px !important;
        padding-top: 40px !important;
        /* 🔥 ИСПРАВЛЕНИЕ: Гарантируем, что тултип не выходит за правый край */
        box-sizing: border-box !important;
        margin-right: 10px !important;
    }
}

/* УБИРАЕМ ВСЕ СТРЕЛКИ */
.no-tooltip-arrow::after,
.no-tooltip-arrow::before,
.enhanced-tooltip-no-arrow::after,
.enhanced-tooltip-no-arrow::before,
#detail-modal .table-tiptext::after,
#detail-modal .table-tiptext::before,
.enhanced-tooltip-clone::after,
.enhanced-tooltip-clone::before {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    content: none !important;
    background: none !important;
    border: none !important;
}

/* Убираем горизонтальный скролл */
#detail-modal {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.enhanced-detail-modal {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

/* Темная тема */
:root[data-theme="dark"] .enhanced-tooltip-no-arrow {
    background: #0D1A29 !important;
    color: #F8F4F2 !important;
}

/* Гарантируем что подсказки поверх всего */
.enhanced-tooltip-no-arrow {
    z-index: 10001 !important;
}

/* 🔥 ПРЕДОТВРАЩЕНИЕ МИГАНИЯ КУРСОРА И ФИКСАЦИЯ ПОДСКАЗОК */
.table-tooltip {
    cursor: help !important;
}

.enhanced-tooltip-no-arrow {
    pointer-events: none !important;
    transition: opacity 0.2s ease, visibility 0.2s ease !important;
}

/* Когда подсказка видима, разрешаем взаимодействие */
.enhanced-tooltip-no-arrow[style*="visibility: visible"],
.enhanced-tooltip-no-arrow[style*="opacity: 1"] {
    pointer-events: auto !important;
}

/* Предотвращаем быстрое исчезновение при случайном наведении */
.enhanced-tooltip-no-arrow:hover {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Убираем стандартную стрелку у подсказок */
.table-tiptext::after,
.table-tiptext::before {
    display: none !important;
}