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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 25px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Секция управления участниками */
.participants-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

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

.participants-input {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

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

.participants-input input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.add-participant-main-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.2);
}

.add-participant-main-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.3);
}

.participants-list {
    min-height: 60px;
}

.no-participants {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 20px;
}

.participant-chip {
    display: inline-flex;
    align-items: center;
    background: #e2e8f0;
    color: #4a5568;
    padding: 8px 12px;
    border-radius: 20px;
    margin: 5px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
}

.participant-chip:hover {
    background: #cbd5e0;
    transform: translateY(-1px);
}

.participant-chip .remove-participant-chip {
    background: #e53e3e;
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.participant-chip .remove-participant-chip:hover {
    background: #c53030;
    transform: scale(1.1);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.add-expense-section,
.expenses-list-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.add-expense-section h2,
.expenses-list-section h2 {
    margin-bottom: 20px;
    color: #4a5568;
    font-size: 1.5rem;
}

.expense-type-tabs {
    display: flex;
    margin-bottom: 20px;
    background: #f7fafc;
    border-radius: 8px;
    padding: 4px;
}

.tab-button {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-button.active {
    background: #4299e1;
    color: white;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}

.expense-form {
    display: none;
}

.expense-form.active {
    display: block;
}

/* Keep only the small text style as it's unique */
.form-group small {
    color: #718096;
    font-size: 14px;
}

/* Чекбоксы участников */
.participants-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    max-height: 200px;
    overflow-y: auto;
    padding: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .participants-checkboxes {
        grid-template-columns: 1fr;
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .participants-checkboxes {
        padding: 15px;
        gap: 10px;
    }
    
    .participant-checkbox {
        padding: 10px 12px;
        min-height: 40px;
        gap: 12px;
    }
    
    .participant-checkbox input[type="checkbox"] {
        transform: scale(1.1);
    }
    
    .participant-checkbox label {
        font-size: 14px;
    }
}

.participant-checkbox {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    user-select: none;
    position: relative;
    overflow: hidden;
    outline: none !important;
    min-height: 45px;
    gap: 15px;
}

.participant-checkbox:focus,
.participant-checkbox:focus-within {
    outline: none !important;
}

.participant-checkbox::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(66, 153, 225, 0.1), rgba(72, 187, 120, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.participant-checkbox:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(66, 153, 225, 0.2);
    border-color: #4299e1;
}

.participant-checkbox:hover::before {
    opacity: 1;
}

.participant-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    transform: scale(1.3);
    accent-color: #48bb78;
    position: relative;
    z-index: 1;
    outline: none !important;
    border: none !important;
    justify-self: start;
}

.participant-checkbox input[type="checkbox"]:focus,
.participant-checkbox input[type="checkbox"]:active,
.participant-checkbox input[type="checkbox"]:checked:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.participant-checkbox label {
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: color 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    text-align: left;
    justify-self: stretch;
}

.participant-checkbox.checked {
    background: linear-gradient(135deg, #c6f6d5, #9ae6b4);
    border-color: #48bb78;
    box-shadow: 0 4px 20px rgba(72, 187, 120, 0.3);
    transform: translateY(-2px);
}

.participant-checkbox.checked::before {
    opacity: 0;
}

.participant-checkbox.checked label {
    color: #22543d;
    font-weight: 600;
}

.individual-participants-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 15px;
    border: 2px solid #cbd5e0;
    border-radius: 12px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.individual-participant-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.individual-participant-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(66, 153, 225, 0.08), rgba(72, 187, 120, 0.08));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.individual-participant-row:hover {
    transform: translateY(-1px);
    border-color: #4299e1;
    box-shadow: 0 4px 12px rgba(66, 153, 225, 0.15);
}

.individual-participant-row:hover::before {
    opacity: 1;
}

.individual-participant-row input[type="checkbox"] {
    grid-column: 1;
    transform: scale(1.3);
    cursor: pointer;
    accent-color: #4299e1;
    z-index: 1;
    position: relative;
    outline: none !important;
    border: none !important;
    justify-self: center;
}

.individual-participant-row input[type="checkbox"]:focus,
.individual-participant-row input[type="checkbox"]:active,
.individual-participant-row input[type="checkbox"]:checked:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

.individual-participant-row .participant-name-label {
    grid-column: 2;
    font-weight: 600;
    color: #2d3748;
    z-index: 1;
    position: relative;
    text-align: center;
    justify-self: center;
}

.individual-participant-row .participant-amount-input {
    grid-column: 3;
    width: 110px;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: right;
    background: #f7fafc;
    transition: all 0.3s ease;
    z-index: 1;
    position: relative;
    justify-self: end;
}

.individual-participant-row .participant-amount-input:focus {
    outline: none;
    border-color: #4299e1;
    background: white;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.individual-participant-row.checked {
    background: #e6fffa;
    border-color: #48bb78;
}

.individual-participant-row.checked .participant-name-label {
    color: #2f855a;
}

.no-participants-warning {
    text-align: center;
    color: #f56565;
    font-style: italic;
    padding: 20px;
    margin: 0;
}

.participant-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.participant-name,
.participant-amount {
    flex: 1;
}

.remove-participant {
    background: #e53e3e;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-participant:hover {
    background: #c53030;
    transform: scale(1.1);
}

.add-participant-btn {
    background: #48bb78;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.add-participant-btn:hover {
    background: #38a169;
    transform: translateY(-2px);
}

.add-btn,
.calculate-btn {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.2);
}

.add-btn:hover,
.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(66, 153, 225, 0.3);
}

.clear-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.clear-btn:hover {
    background: #c53030;
    transform: translateY(-2px);
}

.filters {
    margin-bottom: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
}

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

.filters select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease;
}

.filters select:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.expenses-container {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.expense-item {
    background: #f7fafc;
    border-left: 4px solid #4299e1;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 0 8px 8px 0;
    position: relative;
}

.expense-item.individual {
    border-left-color: #48bb78;
}

.expense-header {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2d3748;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.expense-category {
    background: #e2e8f0;
    color: #4a5568;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.expense-details {
    color: #4a5568;
    font-size: 14px;
}

.expense-description {
    color: #718096;
    font-size: 13px;
    font-style: italic;
    margin-top: 3px;
}

.individual-details {
    margin-top: 8px;
    padding-left: 15px;
}

.individual-details div {
    margin-bottom: 3px;
}

.expense-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

.edit-expense,
.delete-expense {
    background: #4299e1;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-expense {
    background: #48bb78;
}

.edit-expense:hover {
    background: #38a169;
    transform: scale(1.1);
}

.delete-expense {
    background: #e53e3e;
}

.delete-expense:hover {
    background: #c53030;
    transform: scale(1.1);
}

.no-expenses {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 40px;
}

.list-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

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

.summary,
.balances,
.transfers {
    margin-bottom: 25px;
}

.summary h3,
.balances h3,
.transfers h3 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.stat-item {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4299e1;
}

.stat-label {
    color: #4a5568;
    font-size: 14px;
    margin-top: 5px;
}

.balance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 8px;
}

.balance-positive {
    background: #f0fff4;
    border-left: 4px solid #48bb78;
}

.balance-negative {
    background: #fef5e7;
    border-left: 4px solid #ed8936;
}

.balance-zero {
    background: #edf2f7;
    border-left: 4px solid #a0aec0;
}

.transfer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #e6fffa;
    border: 2px solid #38b2ac;
    border-radius: 8px;
    margin-bottom: 10px;
    font-weight: 500;
}

.transfer-amount {
    font-size: 1.1rem;
    color: #38b2ac;
    font-weight: 700;
}

.no-transfers {
    text-align: center;
    color: #48bb78;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 20px;
    background: #f0fff4;
    border-radius: 8px;
    border: 2px solid #48bb78;
}

.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-error {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #fc8181;
}

.alert-success {
    background: #c6f6d5;
    color: #2f855a;
    border: 1px solid #68d391;
}

/* Убираем outline для всех checkbox */
input[type="checkbox"] {
    outline: none !important;
}

input[type="checkbox"]:focus,
input[type="checkbox"]:active,
input[type="checkbox"]:checked:focus {
    outline: none !important;
    box-shadow: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 25px 0 25px;
    border-bottom: 2px solid #f7fafc;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: #2d3748;
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: #e53e3e;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #c53030;
    transform: scale(1.1);
}

.modal-body {
    padding: 0 25px;
}

.modal-footer {
    padding: 20px 25px 25px 25px;
    border-top: 2px solid #f7fafc;
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.cancel-btn {
    background: #a0aec0;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: #718096;
    transform: translateY(-2px);
}

.save-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.2);
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.3);
}

.edit-form {
    display: none;
}

.edit-form.active {
    display: block;
}

@media (max-width: 768px) {
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .cancel-btn,
    .save-btn {
        width: 100%;
    }
}

/* Индикатор сессии */
.session-status {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    z-index: 1100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    max-width: 300px;
    text-align: center;
    animation: slideInRight 0.3s ease-out;
}

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

.session-status-success {
    background: #c6f6d5;
    color: #2f855a;
    border: 1px solid #68d391;
}

.session-status-error {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #fc8181;
}

.session-status-warning {
    background: #fef5e7;
    color: #dd6b20;
    border: 1px solid #f6ad55;
}

.session-status-info {
    background: #bee3f8;
    color: #2c5282;
    border: 1px solid #63b3ed;
}

@media (max-width: 768px) {
    .session-status {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 13px;
        padding: 10px 15px;
    }
}
