/* app/frontend/css/style.css - ПОЛНЫЙ ФАЙЛ С ПОДДЕРЖКОЙ ТЕМЫ БРАУЗЕРА */

/* ===== CSS ПЕРЕМЕННЫЕ ===== */
:root {
    /* Светлая тема (по умолчанию) */
    --bg-body: #f5f7fa;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-hover: #f0f0f0;
    --bg-header: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-table-header: #f8f9fa;
    --bg-table-row-hover: #f8f9fa;
    
    --text-primary: #1a1a2e;
    --text-secondary: #333333;
    --text-muted: #888888;
    --text-light: #555555;
    --text-white: #ffffff;
    
    --border-color: #e8e8e8;
    --border-light: #dddddd;
    --border-input: #dddddd;
    --border-table: #e8e8e8;
    
    --shadow-color: rgba(0,0,0,0.05);
    --shadow-light: rgba(0,0,0,0.1);
    
    --color-primary: #667eea;
    --color-primary-hover: #5a6fd6;
    --color-danger: #e53935;
    --color-danger-hover: #d32f2f;
    --color-success: #28a745;
    --color-success-hover: #218838;
    --color-secondary: #6c757d;
    --color-secondary-hover: #5a6268;
    
    --color-red: #e53935;
    --color-red-dark: #1a1a2e;
    
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== ТЕМНАЯ ТЕМА (автоматически) ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #1a1a2e;
        --bg-primary: #2d2d44;
        --bg-secondary: #3d3d5c;
        --bg-hover: #4a4a6a;
        --bg-header: #2d2d44;
        --bg-card: #2d2d44;
        --bg-input: #3d3d5c;
        --bg-table-header: #3d3d5c;
        --bg-table-row-hover: #4a4a6a;
        
        --text-primary: #e8e8f0;
        --text-secondary: #d0d0e0;
        --text-muted: #9999b0;
        --text-light: #b0b0c8;
        --text-white: #ffffff;
        
        --border-color: #4a4a6a;
        --border-light: #5a5a7a;
        --border-input: #5a5a7a;
        --border-table: #4a4a6a;
        
        --shadow-color: rgba(0,0,0,0.3);
        --shadow-light: rgba(0,0,0,0.4);
        
        --color-primary: #7b93f5;
        --color-primary-hover: #6a82e0;
    }
}

/* ===== БАЗОВЫЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-secondary);
    transition: background 0.3s ease, color 0.3s ease;
}

/* ===== ХЕДЕР ===== */
.header {
    background: var(--bg-header);
    padding: 15px 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.header-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-red);
    letter-spacing: -0.5px;
}

.header-title span {
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-white);
    font-weight: 600;
    font-size: 14px;
}

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

.logout-btn {
    padding: 8px 20px;
    background: var(--color-danger);
    color: var(--text-white);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: var(--color-danger-hover);
}

/* ===== КОНТЕЙНЕР ===== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 10px var(--shadow-color);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* ===== ФИЛЬТРЫ ===== */
.filters-container {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    transition: background 0.3s ease;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 100%;
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: border-color 0.3s, background 0.3s, color 0.3s;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-group .checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 6px;
}

.filter-group .checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.filter-group .checkbox-group label {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-light);
    text-transform: none;
    cursor: pointer;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding-bottom: 2px;
}

/* ===== ТАБЛИЦА ===== */
.table-wrapper {
    border: 1px solid var(--border-table);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.table-scroll {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
}

.table-scroll thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-scroll thead th {
    position: sticky;
    top: 0;
    background: var(--bg-table-header);
    z-index: 11;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.table-scroll table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.table-scroll table thead {
    background: var(--bg-table-header);
}

.table-scroll table th {
    padding: 8px 10px;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-table);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    min-width: 60px;
    vertical-align: middle;
    background: var(--bg-table-header);
}

/* Ширина колонок */
.table-scroll table th:nth-child(1),
.table-scroll table th:nth-child(2) {
    min-width: 120px;
    max-width: 160px;
    text-align: left;
}

.table-scroll table th:nth-child(3),
.table-scroll table th:nth-child(4),
.table-scroll table th:nth-child(5) {
    min-width: 55px;
    max-width: 70px;
}

.table-scroll table th:nth-child(6),
.table-scroll table th:nth-child(7),
.table-scroll table th:nth-child(8),
.table-scroll table th:nth-child(9),
.table-scroll table th:nth-child(10),
.table-scroll table th:nth-child(11) {
    min-width: 75px;
    max-width: 95px;
}

.table-scroll table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-table);
    font-size: 12px;
    color: var(--text-secondary);
    transition: border-color 0.3s ease, color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    vertical-align: middle;
}

/* ===== РЕГИОНЫ - ЯВНЫЙ ЦВЕТ ===== */
.table-scroll table td.region-cell {
    font-size: 13px !important;
    font-weight: 500 !important;
    text-align: left !important;
    color: #1a1a2e !important;
    white-space: normal;
    word-wrap: break-word;
    overflow: visible;
    background: var(--bg-primary);
}

.table-scroll table td:first-child,
.table-scroll table td:nth-child(2) {
    text-align: left !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    color: #1a1a2e !important;
    white-space: normal;
    word-wrap: break-word;
    overflow: visible;
    background: var(--bg-primary);
}

@media (prefers-color-scheme: dark) {
    .table-scroll table td.region-cell {
        color: #e8e8f0 !important;
    }
    .table-scroll table td:first-child,
    .table-scroll table td:nth-child(2) {
        color: #e8e8f0 !important;
    }
}

.table-scroll table tbody tr:hover {
    background: var(--bg-table-row-hover);
}

/* ===== ПОДЗАГОЛОВКИ В ЗАГОЛОВКАХ ===== */
.th-wrap {
    display: block;
    line-height: 1.3;
}

.th-wrap .sub {
    font-weight: 400;
    font-size: 8px;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

/* ===== ССЫЛКИ В ТАБЛИЦЕ ===== */
.link-price {
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

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

.link-ati {
    color: var(--color-danger);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
}

.link-ati:hover {
    color: var(--color-danger-hover);
}

/* ===== СТАТУСЫ ===== */
.status-completed {
    color: #155724;
    background: #d4edda;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 10px;
    display: inline-block;
    white-space: nowrap;
}

.status-incomplete {
    color: #721c24;
    background: #f8d7da;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 10px;
    display: inline-block;
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    .status-completed {
        color: #8fdfb0;
        background: #1a4a2a;
    }
    .status-incomplete {
        color: #f5a0a0;
        background: #4a1a1a;
    }
}

/* ===== ATI СТАВКИ ===== */
.ati-outdated {
    background-color: #fff3cd;
    color: #856404;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: help;
    display: inline-block;
}

@media (prefers-color-scheme: dark) {
    .ati-outdated {
        background-color: #4a3a1a;
        color: #f0d080;
    }
}

.ati-latest {
    color: var(--color-success);
}

/* ===== ЦЕЛЕВАЯ СТАВКА ===== */
.target-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.target-cell input[type="number"] {
    width: 60px;
    padding: 2px 4px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    font-size: 11px;
    text-align: center;
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: border-color 0.3s, background 0.3s, color 0.3s;
}

.target-cell input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

.target-status {
    font-size: 12px;
    margin-left: 2px;
    display: inline-block;
    min-width: 16px;
}

/* ===== КНОПКИ ===== */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    white-space: nowrap;
}

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

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

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

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

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

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

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

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

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

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

/* ===== МЕТРИКИ ===== */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: var(--radius);
    text-align: center;
    transition: background 0.3s ease;
}

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

.metric-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== ПАГИНАЦИЯ ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 15px 0;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--color-primary);
    color: var(--text-white);
    border-color: var(--color-primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 14px;
    color: var(--text-muted);
}

/* ===== ЗАГРУЗКА ===== */
.loading {
    text-align: center;
    padding: 50px;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-secondary);
    border-top: 4px solid var(--color-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== TOAST УВЕДОМЛЕНИЯ ===== */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 99999;
    box-shadow: 0 4px 12px var(--shadow-light);
    animation: slideIn 0.3s ease;
    max-width: 400px;
    transition: opacity 0.3s ease;
}

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

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .filters-row {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .filter-actions {
        flex-wrap: wrap;
    }
    
    .metrics {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .table-scroll {
        max-height: 400px;
    }
    
    .table-scroll table {
        font-size: 10px;
    }
    
    .table-scroll table th,
    .table-scroll table td {
        padding: 4px 6px;
    }
}
/* ===== ПОДВАЛ ===== */
.footer {
    margin-top: 30px;
    padding: 10px 20px;
    text-align: right;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 400;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.footer-copy {
    letter-spacing: 0.2px;
}

/* Для темной темы */
@media (prefers-color-scheme: dark) {
    .footer {
        border-top-color: var(--border-color);
        color: var(--text-muted);
    }
}

.admin-link {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.admin-link:hover {
    background: var(--bg-hover);
    text-decoration: underline;
}