/* frontend/css/style.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #ffffff;
    --income-color: #4caf50;
    --expense-color: #f44336;
    --warning-color: #ff9800;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    padding: 16px;
    line-height: 1.6;
}

#app {
    max-width: 600px;
    margin: 0 auto;
}

/* Загрузка */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--tg-theme-button-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Карточка баланса */
.balance-card {
    background: linear-gradient(135deg, var(--tg-theme-button-color), #1a5fa0);
    color: white;
    padding: 24px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.balance-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.balance-amount {
    font-size: 36px;
    font-weight: bold;
}

/* Операции */
.operations-summary {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.operation-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.operation-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.operation-icon {
    font-size: 24px;
}

.operation-title {
    font-weight: 600;
    font-size: 16px;
}

.operation-content {
    padding-left: 32px;
}

.operation-name {
    font-size: 15px;
    margin-bottom: 4px;
}

.operation-amount {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 4px;
}

.income-card .operation-amount {
    color: var(--income-color);
}

.expense-card .operation-amount {
    color: var(--expense-color);
}

.operation-date {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
}

.no-data {
    color: var(--tg-theme-hint-color);
    font-size: 14px;
}

/* Прогноз */
.forecast-card {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.forecast-label {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 8px;
}

.forecast-amount {
    font-size: 24px;
    font-weight: bold;
}

.forecast-amount.positive {
    color: var(--income-color);
}

.forecast-amount.negative {
    color: var(--expense-color);
}

/* Предстоящие операции */
.upcoming-section {
    margin-bottom: 24px;
}

.upcoming-section h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

.operations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.operation-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.operation-info {
    flex: 1;
}

.operation-item-name {
    font-size: 15px;
    margin-bottom: 2px;
}

.operation-item-date {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

.operation-item-amount {
    font-size: 16px;
    font-weight: bold;
}

.operation-item.income .operation-item-amount {
    color: var(--income-color);
}

.operation-item.expense .operation-item-amount {
    color: var(--expense-color);
}

/* Кнопки */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.btn-primary:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.btn-secondary {
    background: #f5f5f5;
    color: var(--tg-theme-text-color);
}

.btn-secondary:active {
    background: #e0e0e0;
}

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

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 16px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--tg-theme-hint-color);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Форма */
form {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--tg-theme-button-color);
}

.form-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn {
    flex: 1;
}

/* Экран регулярных операций */
.screen-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.back-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--tg-theme-button-color);
    cursor: pointer;
    padding: 8px;
}

.recurring-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recurring-item {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.recurring-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.recurring-item-info {
    flex: 1;
}

.recurring-item-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.recurring-item-details {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
}

.recurring-item-amount {
    font-size: 20px;
    font-weight: bold;
}

.recurring-item.income .recurring-item-amount {
    color: var(--income-color);
}

.recurring-item.expense .recurring-item-amount {
    color: var(--expense-color);
}

.recurring-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.edit-recurring-btn,
.delete-recurring-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

.edit-recurring-btn {
    color: var(--tg-theme-button-color);
}

.delete-recurring-btn {
    color: var(--expense-color);
}

/* Адаптивность */
@media (max-width: 400px) {
    body {
        padding: 12px;
    }
    
    .balance-amount {
        font-size: 28px;
    }
    
    .form-actions {
        flex-direction: column;
    }
}