/* css/finance.css */

/* === Общая структура === */
.finance-main {
    padding-top: 120px;
    padding-bottom: 40px;
}

/* === Баланс (Monobank-style карточка) === */
.balance-card {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-radius: 20px;
    padding: 24px;
    color: white;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    transform: rotate(30deg);
}

.balance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.balance-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

.balance-amount {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 10px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.balance-in-pln {
    opacity: 0.85;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* === Кастомный селект валюты (портал-меню) === */
.custom-currency-selector {
    position: relative;
    display: inline-block;
}

.currency-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    justify-content: space-between;
}

.currency-button:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-light);
}

.currency-button svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.currency-button.open svg {
    transform: rotate(180deg);
}

/* Портал-меню — рисуется в корне body */
.currency-menu-portal {
    display: none;
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    min-width: 80px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--text-secondary) var(--card-bg);
}

.currency-menu-portal::-webkit-scrollbar {
    width: 6px;
}

.currency-menu-portal::-webkit-scrollbar-track {
    background: var(--card-bg);
}

.currency-menu-portal::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 6px;
}

.currency-menu-portal::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.currency-option {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    color: var(--text-secondary);
    font-weight: 500;
}

.currency-option:hover,
.currency-option.active {
    background: var(--primary-color);
    color: white;
}

.currency-option.active {
    font-weight: 600;
}

/* Поддержка тем */
.purple-theme .currency-button {
    border-color: var(--primary-color);
}
.purple-theme .currency-button:hover {
    border-color: var(--primary-light);
}
.purple-theme .currency-option:hover,
.purple-theme .currency-option.active {
    background: var(--primary-color);
}

.red-theme .currency-button {
    border-color: var(--primary-color);
}
.red-theme .currency-button:hover {
    border-color: var(--primary-light);
}
.red-theme .currency-option:hover,
.red-theme .currency-option.active {
    background: var(--primary-color);
}

/* === Добавление транзакции === */
.add-transaction {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.add-transaction h2 {
    margin-bottom: 16px;
    font-size: 1.3rem;
    color: var(--text-color);
}

.transaction-form .form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.transaction-form select,
.transaction-form input,
.transaction-form textarea {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(30, 30, 47, 0.5);
    color: white;
    font-size: 1rem;
    width: 100%;
    outline: none;
}

.transaction-form input[type="number"] {
    -webkit-appearance: textfield;
    text-align: right;
}

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

.transaction-form button {
    width: 100%;
    padding: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(93, 93, 255, 0.2);
    margin-top: 8px;
}

.transaction-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(93, 93, 255, 0.3);
}

/* === Статистика === */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 6px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.stat-label span {
    display: block;
    color: var(--text-color);
    font-size: 0.8rem;
    opacity: 0.9;
}

/* === Цели и бюджеты === */
.goals-section {
    margin-bottom: 24px;
}

.goal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.goal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.goal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}

.goal-amount {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.progress-container {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin: 12px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.goal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-secondary {
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* === История операций === */
.history-section h2 {
    margin-bottom: 16px;
    font-size: 1.3rem;
    color: var(--text-color);
}

#transactionsList {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.transaction-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.transaction-info {
    flex: 1;
}

.transaction-description {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--text-color);
}

.transaction-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.transaction-amount {
    font-size: 1.2rem;
    font-weight: bold;
    white-space: nowrap;
}

.transaction-income {
    color: #4cd964;
}

.transaction-expense {
    color: #ff5252;
}

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

.modal-content {
    max-width: 500px;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    color: var(--text-color);
    font-size: 1.3rem;
    margin-bottom: 16px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(30, 30, 47, 0.5);
    color: white;
    font-size: 1rem;
}

.btn-primary, .btn-outline {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(45deg, var(--gradient-start), var(--gradient-end));
    color: white;
}

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

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-light);
}

/* === Сообщения === */
.alert {
    padding: 10px;
    border-radius: 8px;
    margin: 12px 0 20px 0; /* отступ снизу 20px */
    display: none;
    font-size: 0.95rem;
}

.alert.success { 
    background: rgba(76, 217, 100, 0.1); 
    color: #4cd964; 
    border-left: 4px solid #4cd964;
}

.alert.error { 
    background: rgba(255, 82, 82, 0.1); 
    color: #ff5252; 
    border-left: 4px solid #ff5252;
}

/* === Адаптив === */
@media (max-width: 600px) {
    .finance-main {
        padding-top: 140px;
        padding-bottom: 30px;
    }

    .balance-amount {
        font-size: 2rem;
    }

    .currency-button {
        padding: 6px 10px;
        font-size: 0.9rem;
        min-width: 70px;
    }
    .currency-menu-portal {
        min-width: 70px;
        max-height: 180px;
    }
    .currency-option {
        padding: 6px 12px;
        font-size: 0.9rem;
    }

    .transaction-form .form-row {
        flex-direction: column;
        gap: 10px;
    }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .transaction-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .transaction-amount {
        align-self: flex-end;
    }

    .goal-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-content {
        padding: 16px;
    }
}