/* frontend/css/theme.css */
:root {
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* Светлая тема (по умолчанию) */
.theme-light {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-table: #ffffff;
    --text-primary: #000000;
    --text-secondary: #6c757d;
    --border-color: #e9ecef;
    --accent-blue: #007AFF;
    --accent-green: #34C759;
    --accent-red: #FF3B30;
    --accent-orange: #FF9500;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --table-header-bg: #f8f9fa;
    --input-bg: #ffffff;
    --input-border: #ced4da;
}

/* Темная тема */
.theme-dark {
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bg-table: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #98989d;
    --border-color: #3a3a3c;
    --accent-blue: #0A84FF;
    --accent-green: #30D158;
    --accent-red: #FF453A;
    --accent-orange: #FF9F0A;
    --shadow: 0 2px 10px rgba(0,0,0,0.3);
    --table-header-bg: #3a3a3c;
    --input-bg: #3a3a3c;
    --input-border: #48484a;
}

/* frontend/css/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
    line-height: 1.5;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Блок истории */
.history-block {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table th {
    background: var(--table-header-bg);
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.history-table td:hover {
    background: var(--bg-secondary);
}

/* Подсветка min/max веса */
.min-weight {
    background: var(--accent-green) !important;
    color: white;
}

.max-weight {
    background: var(--accent-orange) !important;
    color: white;
}

/* Цвета для дельты плана */
.delta {
    font-size: 11px;
    margin-left: 4px;
}

.delta.green {
    color: var(--accent-green);
}

.delta.red {
    color: var(--accent-red);
}

/* Красный фон для плохих показателей */
.red-bg {
    background: rgba(255, 59, 48, 0.15);
    color: var(--accent-red);
    font-weight: 600;
}

/* Поле комментария */
.comment-cell {
    position: relative;
}

.comment-preview {
    max-width: 80px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.expand-comment {
    background: none;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
    font-size: 16px;
    margin-left: 4px;
}

/* Блок прогноза */
.prediction-block {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.prediction-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: center;
}

.prediction-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prediction-field input {
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 16px;
}

.prediction-result {
    display: flex;
    gap: 20px;
    justify-content: space-around;
}

.result-item {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-secondary);
}

.result-item.red {
    background: rgba(255, 59, 48, 0.2);
}

/* Блок графика */
.chart-block {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.chart-container {
    height: 300px;
    width: 100%;
}

/* Настройки */
.settings-block {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.settings-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.settings-group label {
    font-weight: 600;
    color: var(--text-secondary);
}

.settings-group input,
.settings-group select {
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 16px;
}

.save-settings {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
}

/* Кнопки подгрузки */
.load-more-buttons {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
}

.load-more {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
}

/* Модальное окно оплаты */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.tariff-options {
    display: flex;
    gap: 15px;
    margin: 20px 0;
}

.tariff-btn {
    flex: 1;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
}

.tariff-btn.selected {
    border-color: var(--accent-blue);
    background: var(--accent-blue);
    color: white;
}

.modal-content button {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
    font-size: 16px;
    cursor: pointer;
}

.close-modal {
    margin-top: 10px;
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Адаптивность */
@media (max-width: 768px) {
    #app {
        padding: 10px;
    }
    
    .history-table {
        font-size: 12px;
    }
    
    .history-table td, .history-table th {
        padding: 8px 4px;
    }
}

@media (orientation: landscape) {
    .history-table {
        font-size: 14px;
    }
}

/* Анимация загрузки */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-secondary);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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