/* web/static/css/dashboard.css */

/* 🔹 Единый контейнер для ВСЕХ страниц (дашборд, избранное, отчёты) */
.dashboard-container,
.category-container,
.favorites-container {
    max-width: 1400px;  /* 🔹 Было 1200px → стало 1400px */
    margin: 0 auto;
    padding: 20px 24px; /* 🔹 Чуть больше отступы по бокам */
    width: 100%;
    box-sizing: border-box;
}

/* 🔹 На очень широких экранах — почти во всю ширину */
@media (min-width: 1600px) {
    .dashboard-container,
    .category-container,
    .favorites-container {
        max-width: 95%;
        padding: 20px 32px;
    }
}

/* 🔹 На мобильных — стандартные отступы */
@media (max-width: 768px) {
    .dashboard-container,
    .category-container,
    .favorites-container {
        padding: 16px;
    }
}

.dashboard-header h1 {
    color: var(--dark);
    border-bottom: 3px solid var(--primary);
    padding-bottom: 10px;
    margin-bottom: 5px;
}
.dashboard-header .meta {
    color: #666;
    margin: 0 0 25px 0;
    font-size: 1.05em;
}

/* 🔹 Секции */
.dashboard-section { margin-bottom: 40px; }
.dashboard-section h2 {
    color: var(--dark);
    margin-top: 35px;
    font-size: 1.3em;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
}

/* 🔹 Сетка категорий */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 15px;
}
.category-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    text-decoration: none;
    color: var(--dark);
    border: 1px solid var(--border);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    border-color: var(--primary);
}
.category-card.has-premium {
    border-left: 4px solid var(--warning);
    background: #fffdf5;
}
.category-card strong {
    font-size: 1.1em;
    margin-bottom: 8px;
    display: block;
}
.category-card .meta {
    font-size: 0.85em;
    color: #666;
    margin: 0;
}
.badge {
    display: inline-block;
    background: var(--new-badge);
    color: var(--new-text);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    margin-top: 6px;
}
.badge.zero { background: #f5f5f5; color: #757575; }

/* 🔹 Неделя: горизонтальный скролл */
.week-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-top: 15px;
    scroll-behavior: smooth;
}
.day-card {
    flex: 0 0 140px;
    background: #fff;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--dark);
    transition: all 0.2s;
    text-align: center;
}
.day-card:hover { border-color: var(--primary); background: var(--hover); }
.day-card.today {
    border: 2px solid var(--primary);
    background: var(--even-row);
    font-weight: 500;
}
.day-label {
    font-weight: 600;
    font-size: 0.9em;
    display: block;
    margin-bottom: 6px;
}
.day-stats {
    font-size: 0.8em;
    color: #555;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-total { color: #444; }
.stat-new { color: var(--new-text); font-weight: 500; }

/* 🔹 Архив */
.history-list {
    list-style: none;
    padding: 0;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    margin-top: 15px;
}
.history-list li { border-bottom: 1px solid var(--border); }
.history-list li:last-child { border-bottom: none; }
.history-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--dark);
    transition: background 0.2s;
}
.history-list a:hover { background-color: var(--hover); }
.history-list .date { font-weight: 500; }
.history-list .count { color: #888; font-size: 0.9em; }

/* 🔹 Адаптив */
@media (max-width: 768px) {
    .category-grid { grid-template-columns: 1fr; }
    .week-grid { padding: 0 10px; }
    .day-card { flex: 0 0 120px; }
}

/* 🔹 Итог за год */
.year-summary {
    background: #fff; padding: 20px; border-radius: 8px; 
    border: 1px solid var(--border); margin-bottom: 25px; 
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px;
}
.summary-stats { display: flex; gap: 20px; flex-wrap: wrap; font-size: 1.05em; }
.summary-stats span { font-weight: 500; color: var(--dark); }

/* 🔹 Компактная статистика в карточках */
.card-stats { 
    display: flex; gap: 8px; margin-top: 8px; font-size: 0.9em; color: #555; 
}

/* 🔹 День недели */
.stat-row { font-size: 0.85em; color: #555; display: block; margin-top: 4px; }

.card-stats-row {
    display: flex; gap: 10px; margin-top: 8px; font-size: 0.85em; color: #444; flex-wrap: wrap;
}
.card-stats-row span { white-space: nowrap; }
/* 🔹 Итоги в заголовках секций */
.section-summary {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--dark);
    margin: 8px 0 12px 0;
    letter-spacing: 2px;
    font-family: monospace;
}

/* 🔹 Карточки категорий */
.card-emoji-stats {
    display: flex; flex-direction: column; gap: 4px; margin: 8px 0;
    font-size: 0.95em; color: #333; font-weight: 500;
}
.card-totals {
    font-size: 0.85em; color: #666; border-top: 1px solid var(--border);
    padding-top: 6px; margin-top: 4px; letter-spacing: 0.5px;
}

/* 🔹 Статистика в дне недели */
.stat-row {
    font-size: 0.85em; color: #555; letter-spacing: 0.5px; display: block; margin-top: 4px;
}
/* 🔹 Аккордеон архива - ФИНАЛЬНАЯ ВЕРСТКА */
.archive-accordion { display: flex; flex-direction: column; gap: 10px; }

.archive-week {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.archive-week[open] {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    border-color: var(--primary);
}

.archive-header {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    list-style: none;
    background: #fff;
    transition: background 0.2s;
    user-select: none;
}
.archive-header:hover { background: var(--hover); }
.archive-header::-webkit-details-marker { display: none; }

/* 🔹 Дата: фиксирована слева */
.archive-header .date {
    font-weight: 600;
    color: var(--dark);
    font-size: 1.05em;
    flex-shrink: 0;
}

/* 🔹 Статистика: прижата вправо, моноширинный шрифт */
.archive-header .count {
    margin-left: auto;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 0.95em;
    color: #555;
    letter-spacing: 1.5px;
    margin-right: 14px;
    white-space: nowrap;
}

/* 🔹 Стрелка: круглая кнопка с анимацией */
.accordion-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    transition: transform 0.25s ease, color 0.2s, background 0.2s;
    font-size: 0.7em;
    background: var(--light-bg);
    border-radius: 50%;
    flex-shrink: 0;
}
.archive-week[open] .accordion-icon {
    transform: rotate(180deg);
    color: var(--primary);
    background: var(--new-badge);
}

/* 🔹 Внутренний блок дней */
.archive-days {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 0 18px 16px 18px;
    background: #fff;  /* 🔹 Чистый белый */
    scroll-behavior: smooth;
}
.archive-days .day-card {
    flex: 0 0 135px;
    min-width: 120px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.2s;
}
.archive-days .day-card:hover { border-color: var(--primary); background: var(--hover); transform: translateY(-1px); }
.archive-days .day-label { font-weight: 600; font-size: 0.85em; display: block; margin-bottom: 6px; }
.archive-days .stat-row { font-size: 0.8em; color: #555; letter-spacing: 0.5px; }

/* 🔹 Сетка для избранного (вместо горизонтального скролла) */
.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding: 16px 18px;
    background: #fff;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 4px solid #3498DB;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    border-color: var(--primary);
}
.card.premium {
    border-left: 4px solid #FFC107 !important;
    background: #fff !important;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.1);
}
.card.premium:hover {
    box-shadow: 0 8px 20px rgba(255, 193, 7, 0.2);
}
.card.premium .card-title {
    color: #856404;
    font-weight: 600;
}
.card.premium .card-number {
    color: #856404;
    font-weight: 700;
}

/* 🔹 Шапка карточки */
.card-header {
    display: flex;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.card-number {
    font-weight: 600;
    font-size: 1em;
    color: var(--dark);
}
.card-deadline {
    font-size: 0.85em;
    color: var(--warning);
    background: #fff3cd;
    padding: 2px 8px;
    border-radius: 10px;
}

/* 🔹 Ссылка на тендер */
.card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    max-height: 2.7em;
    cursor: help;
    font-weight: 500;
    color: #0056b3;
    text-decoration: none;
    font-size: 0.95em;
}
.card-title:hover { text-decoration: underline; }
.card-title.disabled {
    color: #666;
    cursor: not-allowed;
    pointer-events: none;
    background: #f7fafc;
    padding: 2px 6px;
    border-radius: 4px;
}

/* 🔹 Мета-инфо */
.card-meta {
    font-size: 0.85em;
    color: #666;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 4px 0;
}
.card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 🔹 Сниппет поиска */
.card-search {
    font-size: 0.85em;
    font-style: italic;
    color: #777;
    background: #f8f9fa;
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 3px solid var(--border);
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}
.card-search:hover {
    max-height: none;
    overflow: visible;
}

/* 🔹 Форма инлайн-редактирования */
.card-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 100px auto;
    gap: 10px;
    align-items: end;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-group.full-width { width: 100%; }
.form-group label {
    font-size: 0.8em;
    font-weight: 500;
    color: #555;
}
select, input[type="text"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9em;
    width: 100%;
    box-sizing: border-box;
}
select:focus, input[type="text"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

/* 🔹 Звёзды */
.star-rating {
    display: inline-flex;
    gap: 2px;
    cursor: pointer;
}
.star-rating span {
    font-size: 1.3em;
    color: #ccc;
}
.star-rating span.selected {
    color: var(--warning);
}

/* 🔹 Кнопки */
.btn-save {
    padding: 8px 14px;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-save:hover { background: #219a52; }
.btn-fav {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0;
    opacity: 0.7;
    transition: transform 0.15s;
}
.btn-fav:hover, .btn-fav.active {
    opacity: 1;
    transform: scale(1.1);
}
.btn-fav.active { color: var(--warning); }

/* 🔹 Сетка для избранного */
.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding: 16px 18px;
    background: #fff;
}

/* 🔹 Адаптив */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .btn-save { width: 100%; margin-top: 5px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 4px; }
    .favorites-grid { grid-template-columns: 1fr; }
}
.export-btn { padding: 8px 14px; background: #2c3e50; color: #fff; border-radius: 6px; text-decoration: none; font-size: 0.9em; font-weight: 500; }
.export-btn:hover { background: #1a252f; transform: translateY(-1px); }

.global-search { display: flex; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; margin: 0 auto; max-width: 400px; }
.global-search input { border: none; outline: none; flex: 1; font-size: 0.9em; padding: 4px; }

/* 🔹 Шапка сайта */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

/* 🔹 Логотип */
.site-logo {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--dark);
    text-decoration: none;
    white-space: nowrap;
}
.site-logo:hover { color: var(--primary); }

/* 🔹 Поиск */
.global-search {
    display: flex;
    align-items: center;
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    flex: 1;
    max-width: 400px;
}
.global-search input {
    border: none;
    outline: none;
    background: transparent;
    flex: 1;
    font-size: 0.9em;
    padding: 4px;
}
.search-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    color: #666;
    padding: 4px;
}
.search-btn:hover { color: var(--primary); }

/* 🔹 Пользовательское меню */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.user-greeting {
    font-size: 0.9em;
    font-weight: 500;
    color: var(--dark);
    background: var(--light-bg);
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
}
.logout-form { display: inline; }
.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: #666;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1em;
}
.btn-logout:hover {
    background: #ffebee;
    border-color: #e74c3c;
    color: #e74c3c;
}
.btn-login {
    padding: 8px 12px;
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1.1em;
}
.btn-login:hover { background: #2980b9; }

/* 🔹 Flash messages */
.flash-messages {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.flash-message {
    padding: 12px 20px;
    background: #d4edda;
    color: #155724;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 0.9em;
}
.flash-message.error {
    background: #f8d7da;
    color: #721c24;
}

/* 🔹 Основной контент */
.page-main {
    min-height: calc(100vh - 140px);
    padding: 20px 0;
}

/* 🔹 Адаптив */
@media (max-width: 768px) {
    .header-container { padding: 0 16px; gap: 12px; }
    .global-search { display: none; } /* Скрываем поиск на мобильных */
    .user-greeting { display: none; } /* Скрываем имя, оставляем иконки */
    .site-logo { font-size: 1em; }
}

.btn-work { 
    transition: transform 0.15s, color 0.2s; 
    opacity: 0.7; 
}
.btn-work:hover, .btn-work.active { 
    opacity: 1; 
    transform: scale(1.1); 
    color: #27ae60; 
}
.btn-work.active { 
    color: #27ae60; 
}
.btn-sales {
    padding: 6px 10px;
    background: var(--light-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--dark);
    text-decoration: none;
    font-size: 1.1em;
    transition: all 0.2s;
}
.btn-sales:hover {
    background: #e8f4fd;
    border-color: var(--primary);
    color: var(--primary);
}

/* 🔹 Контейнер кнопок в шапке */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}



.sales-btn .badge {
    background: #3498db;
    color: #fff;
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    min-width: 20px;
    text-align: center;
    display: inline-block;
}

/* 🔹 Единый стиль для всех кнопок в шапке */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9em;
    transition: all 0.2s;
    white-space: nowrap;
}

/* ⭐ Избранное */
.action-btn.fav {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}
.action-btn.fav:hover {
    background: #ffeaa7;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* 💼 В работе */
.action-btn.sales {
    background: #e8f4fd;
    border: 1px solid #3498db;
    color: #2980b9;
}
.action-btn.sales:hover {
    background: #d4e6f1;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(52,152,219,0.15);
}

/* 📥 Excel */
.action-btn.export {
    background: #2c3e50;
    border: 1px solid #1a252f;
    color: #fff;
}
.action-btn.export:hover {
    background: #1a252f;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* 🔹 Бейдж (общий для всех кнопок) */
.action-btn .badge {
    background: rgba(0,0,0,0.15);
    color: inherit;
    font-size: 0.75em;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-left: 2px;
}

/* 🔹 Адаптив: на мобильных скрываем текст, оставляем иконки + бейджи */
@media (max-width: 768px) {
    .action-btn span:not(.badge) { display: none; }
    .action-btn { padding: 8px 12px; }
    .action-btn .badge { margin-left: 0; }
}

/* 🔧 В проработке */
.action-btn.processing {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    color: #2e7d32;
}
.action-btn.processing:hover {
    background: #c8e6c9;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(76,175,80,0.15);
}

/* 🔹 Бейджи статусов */
.status-badge {
    font-size: 0.8em;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.status-match { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status-participating { background: #cce5ff; color: #004085; border: 1px solid #b8daff; }
.status-won { background: #d4edda; color: #155724; border: 2px solid #28a745; font-weight: 600; }
.status-lost { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status-clarify { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.status-rejected { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status-pending { background: #e2e3e5; color: #383d41; border: 1px solid #d6d8db; }