/* Кнопки */
.btn {
    padding: calc(var(--spacing-sm) + 2px) var(--spacing-xl);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

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

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

.btn-warning {
    background: var(--color-warning);
    color: var(--text-light);
}

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

.btn-info {
    background: var(--color-info);
    color: var(--text-light);
}

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

/* Состояния кнопок */
.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Формы */
.form-control {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 2px solid var(--color-secondary);
    border-radius: var(--radius-md);
    font-size: 1em;
    transition: all 0.3s ease;
    background: var(--bg-primary);
    color: var(--text-primary);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.input-group input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #4299e1;
}

@media (max-width: 480px) {
    .input-group {
        flex-direction: column;
    }

    .input-group input {
        width: 100%;
    }

    .input-group .btn {
        width: 100%;
        justify-content: center;
    }
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--text-dark);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #4a5568;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4299e1;
}

/* Радио кнопки */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

.radio-label:hover {
    background-color: #f7fafc;
}

.radio-label input[type="radio"] {
    margin-right: 10px;
    width: auto;
}

/* Чекбоксы */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
}

/* Кнопка редактирования */
.btn-edit {
    background: #4299e1;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.btn-edit:hover {
    background: #3182ce;
}

.btn-edit i {
    font-size: 1em;
}

/* Форма редактирования */
.edit-expense-form {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

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

.edit-expense-form label {
    display: block;
    margin-bottom: 8px;
    color: #4a5568;
    font-weight: 500;
}

.edit-expense-form input,
.edit-expense-form select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.edit-expense-form input:focus,
.edit-expense-form select:focus {
    outline: none;
    border-color: #4299e1;
}

.edit-expense-form .checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.edit-expense-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.edit-expense-form .checkbox-label:hover {
    border-color: #4299e1;
}

.edit-expense-form .checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    transition: all 0.3s ease;
}

.checkbox-label:hover {
    border-color: #4299e1;
    background-color: #f7fafc;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: auto;
}

.checkbox-label.checked {
    border-color: #4299e1;
    background-color: #ebf8ff;
}



#add-participant-form,
#add-expense-form {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

#participant-name,
#expense-name,
#expense-amount {
    flex-grow: 1;
}

.form-container {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-end;
    margin-bottom: var(--spacing-lg);
}

/* Карточки */
.card {
    background: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 2px solid var(--color-secondary);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #4a5568;
}

#modal-message {
    margin-bottom: 30px;
    color: #718096;
    line-height: 1.5;
}

.modal-content p {
    margin-bottom: 25px;
    color: #718096;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Секции */
.section {
    background: rgba(255, 255, 255, 0.95);
    margin-bottom: 25px;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.section h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.section h2 i {
    margin-right: 10px;
    color: #4299e1;
}

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

.stat-card {
    background: linear-gradient(135deg, #4299e1, #667eea);
    color: white;
    padding: 25px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 5px 20px rgba(66, 153, 225, 0.3);
}

.stat-card i {
    font-size: 2.5em;
    opacity: 0.8;
}

.stat-card h3 {
    font-size: 2em;
    margin-bottom: 5px;
}

.stat-card p {
    opacity: 0.9;
}

/* Балансы */
.balances-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.balance-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-radius: 10px;
    font-weight: 600;
}

.balance-card.positive {
    background: #f0fff4;
    border-left: 5px solid #48bb78;
    color: #22543d;
}

.balance-card.negative {
    background: #fff5f5;
    border-left: 5px solid #f56565;
    color: #742a2a;
}

.balance-card.zero {
    background: #f7fafc;
    border-left: 5px solid #a0aec0;
    color: #4a5568;
}

/* Переводы */
.settlements-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settlement-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    border: none;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settlement-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s;
}

.settlement-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.settlement-card:hover::before {
    left: 100%;
}

.settlement-info {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.settlement-participant {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1.1em;
}

.settlement-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.settlement-arrow {
    font-size: 1.8em;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: pulse 2s infinite;
}

.settlement-amount {
    font-size: 1.4em;
    font-weight: 700;
    text-align: right;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.settlement-amount-label {
    font-size: 0.85em;
    opacity: 0.8;
    display: block;
    margin-bottom: 4px;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.9;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Альтернативные цветовые схемы для разнообразия */
.settlement-card:nth-child(2n) {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    box-shadow: 0 8px 25px rgba(229, 62, 62, 0.3);
}

.settlement-card:nth-child(2n):hover {
    box-shadow: 0 15px 35px rgba(229, 62, 62, 0.4);
}

.settlement-card:nth-child(3n) {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    box-shadow: 0 8px 25px rgba(56, 161, 105, 0.3);
}

.settlement-card:nth-child(3n):hover {
    box-shadow: 0 15px 35px rgba(56, 161, 105, 0.4);
}

.settlement-card:nth-child(4n) {
    background: linear-gradient(135deg, #d69e2e 0%, #b7791f 100%);
    box-shadow: 0 8px 25px rgba(214, 158, 46, 0.3);
}

.settlement-card:nth-child(4n):hover {
    box-shadow: 0 15px 35px rgba(214, 158, 46, 0.4);
}

/* Состояние "нет данных" */
.no-data {
    text-align: center;
    color: #a0aec0;
    padding: 40px 20px;
}

.no-data i {
    font-size: 3em;
    margin-bottom: 15px;
    display: block;
}

.no-data p {
    font-size: 1.1em;
}

/* Адаптивность */
@media (max-width: 768px) {
    .settlement-card {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px;
    }

    .settlement-info {
        flex-direction: column;
        gap: 15px;
        width: 100%;
    }

    .settlement-participant {
        justify-content: center;
        font-size: 1em;
    }

    .settlement-arrow {
        transform: rotate(90deg);
        font-size: 1.5em;
    }

    .settlement-amount {
        text-align: center;
        font-size: 1.2em;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        justify-content: center;
        text-align: center;
    }
}

/* Оповещения */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    position: relative;
    text-align: center;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
}

.room-info {
    margin-top: 15px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 0.9em;
    color: #4a5568;
    background: rgba(0, 0, 0, 0.03);
    padding: 10px 20px;
    border-radius: 20px;
}

.alert-link {
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.btn-share {
    padding: 5px 15px;
    font-size: 0.9em;
}

/* История комнат */
.history-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: -10px -10px 20px -10px;
    /* Offset parent padding */
    padding: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-primary);
    /* background: white */
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: #4299e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    background: #f7fafc;
}

.history-item.current {
    border-color: #48bb78;
    background: #f0fff4;
}

.history-icon {
    font-size: 1.5em;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #edf2f7;
    border-radius: 50%;
}

.history-item.current .history-icon {
    background: #c6f6d5;
}

.history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}

.history-name {
    font-weight: 600;
    font-size: 1em;
    color: #2d3748;
}

.history-date {
    font-size: 0.85em;
    color: #718096;
}

.history-id {
    font-size: 0.75em;
    font-family: monospace;
    color: #a0aec0;
}

.history-arrow {
    color: #cbd5e0;
    font-size: 1.2em;
}

.history-item:hover .history-arrow {
    color: #4299e1;
}

.history-footer {
    display: flex;
    justify-content: center;
    padding-top: 10px;
    border-top: 2px solid #edf2f7;
}

.btn-text {
    background: none;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    display: inline-flex;
}

.history-item-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-item-container .history-item {
    flex: 1;
}

.btn-delete-room {
    background: none;
    border: none;
    color: var(--color-danger);
    padding: 10px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.btn-delete-room:hover {
    opacity: 1;
    background: rgba(245, 101, 101, 0.1);
    transform: scale(1.1);
}

.btn-text:hover {
    text-decoration: underline;
}

.text-danger {
    color: #e53e3e;
}

.text-danger:hover {
    color: #c53030;
}

/* Header buttons fix */
#history-btn {
    padding: 5px 15px;
    /* Match btn-share */
    font-size: 0.9em;
}

/* Edit Icon */
.edit-icon {
    font-size: 0.5em;
    color: #a0aec0;
    cursor: pointer;
    margin-left: 10px;
    vertical-align: middle;
    transition: color 0.3s ease;
}

.edit-icon:hover {
    color: #4299e1;
}

/* Modal Danger Button */
.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background: #c53030;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

/* Spacing for modal buttons (CSP fix) */
.modal-buttons.spaced {
    margin-top: 25px;
}