/* === GLOBAL RESET === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* === BODY & BASIC LAYOUT === */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #d3eaff 0%, #c7ddff 35%, #bad1ff 70%, #aec5ff 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    width: 100%;
}

h1, h2, h3, h4, h5, h6 {
    color: #2F4FA8;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 400;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

main {
    max-width: 700px;
    margin: 0 auto;
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.08);
    backdrop-filter: blur(10px);
    box-sizing: border-box;
}

/* === FORM STRUCTURE === */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.field-row {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    padding: 1.25rem 0;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.3s ease;
    position: relative;
}

.field-row:hover {
    background: #fafafa;
    border-radius: 8px;
    padding: 1.25rem;
    margin: 0 -1rem;
}

.field-left {
    flex: 1;
    min-width: 280px;
}

.field-right {
    flex: 1;
    min-width: 240px;
}

/* === SALARY FIELD & ERRORS === */
.salary-field-container {
    position: relative;
    width: 100%;
}

.field-message {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    color: #d32f2f;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    padding: 12px;
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.field-message:empty {
    display: none;
}

.field-message.error:not(:empty),
.field-message.warning:not(:empty) {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.field-message::before {
    content: "⚠️";
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

.field-message.warning {
    color: #f57c00;
    background: #fff3e0;
    border: 1px solid #ffe0b2;
}

.field-message.warning::before {
    content: "💡";
}

.field-error {
    border: 2px solid #e74c3c !important;
    background: #fff5f5 !important;
    animation: shake 0.3s ease;
}

.field-select {
    width: 100%;
    max-width: 230px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #fff;
    font-size: 0.95rem;
    appearance: none;
    transition: border-color 0.2s ease;
}

.field-select:hover,
.field-select:focus {
    border-color: #999;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* === TOOLTIP SYSTEM === */
.field-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.field-header label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 1rem;
    margin: 0;
}

.field-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    /* Увеличиваем z-index для контейнера */
    z-index: 100;
}

.tooltip-icon {
    background: #2980b9;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.tooltip-icon:hover {
    transform: scale(1.1);
    background: #3498db;
}

.tooltip-text {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    max-width: 280px;
    font-size: 0.9rem;
    padding: 12px 14px;
    background: rgba(44,62,80,0.95);
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
    /* Увеличиваем z-index для самого тултипа */
    z-index: 1001;
    word-wrap: break-word;
}

.tooltip-text.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tooltip-text.tooltip-above::after,
.tooltip-text.tooltip-below::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(44,62,80,0.95);
}

.tooltip-text.tooltip-above::after {
    top: 100%;
}

.tooltip-text.tooltip-below::after {
    bottom: 100%;
    transform: translateX(-50%) rotate(180deg);
}

/* === TOOLTIP FIXES FOR ACCORDION === */
/* Специальные стили для тултипов внутри аккордеона */
#additional-params .field-tooltip {
    z-index: 150;
}

#additional-params .tooltip-text {
    z-index: 151;
}


/* === INPUTS === */
input[type="text"], select {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #fafbfc;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: #3498db;
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

input::placeholder {
    color: #999;
    font-style: italic;
}

/* === SALARY FIELD === */
.salary-field {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.salary-field input {
    padding-right: 2.5rem;
}

.ruble {
    position: absolute;
    right: 0.875rem;
    color: #666;
    font-weight: 600;
    font-size: 1rem;
}

/* === DATE FIELD === */
.date-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.date-field select {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: #fff;
    font-size: 0.95rem;
    appearance: none;
    transition: border-color 0.2s ease;
}

.date-field select:hover,
.date-field select:focus {
    border-color: #999;
}

.date-field span {
    color: #444;
    font-size: 1rem;
}

/* === CHECKBOXES === */
.checkbox-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.checkbox-inline:hover {
    background: #f8f9fa;
}

.checkbox-inline input[type="checkbox"] {
    width: auto;
    margin: 0;
    transform: scale(1.2);
    accent-color: #3498db;
}

.checkbox-inline span {
    font-weight: 500;
}

/* === EXCLUSIVE CHECKBOXES === */
.exclusive-checkboxes {
    gap: 4px;
    position: relative;
}

.exclusive-option {
    transition: all 0.3s ease;
    border-radius: 6px;
    padding: 0.375rem 0.5rem;
}

.exclusive-option.selected {
    background: #e3f2fd;
    border: 2px solid #3498db;
}

.exclusive-option input[type="checkbox"]:checked + span {
    font-weight: 600;
    color: #2c3e50;
}

/* === UNDER-TITLE LINKS === */
.under-title {
    font-size: 0.875rem;
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
    margin-top: 4px;
}

.under-title:hover {
    color: #3498db;
}

/* === BUTTONS === */
button, 
a.button,
a.back-button,
a.primary-button {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

button:hover, 
a.button:hover,
a.back-button:hover,
a.primary-button:hover {
    background: linear-gradient(135deg, #2980b9, #2471a3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

button:active, 
a.button:active,
a.back-button:active,
a.primary-button:active {
    transform: translateY(0);
}

button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* === BUTTON SIZES === */
a.back-button,
button.small {
    padding: 10px 20px;
    font-size: 14px;
}

button,
a.primary-button,
a.button {
    padding: 12px 24px;
    font-size: 16px;
}

button.large,
a.button.large {
    padding: 1.125rem 2.5rem;
    font-size: 1.1rem;
    width: 100%;
    max-width: 300px;
    align-self: center;
}

/* === NOTE BLOCK === */
.calculator-note {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 4px solid #3498db;
    margin-top: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.calculator-note p {
    margin-bottom: 0.75rem;
    color: #555;
}

.calculator-link {
    color: #3498db;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.calculator-link:hover {
    text-decoration: underline;
    color: #2980b9;
}

/* === FOOTER === */
.site-footer {
    text-align: center;
    padding: 40px 20px 30px;
    font-size: 13px;
    color: #8a8a8a;
    margin-top: 60px;
    border-top: 1px solid rgba(255, 255, 255, 0.4); /* мягкий белый разделитель */
}

.footer-links {
    display: flex;
    flex-wrap: wrap;           /* позволяет переносить строки */
    justify-content: center;   /* центрует даже при переносе */
    gap: 10px 16px;            /* вертикальный и горизонтальный отступ */
    max-width: 100%;
    margin-bottom: 8px;
}

.footer-link {
    white-space: nowrap;       /* пункт всегда целиком, не делится по словам */
    color: #597ccf;
    text-decoration: none;
    font-size: 13px;
    transition: opacity 0.2s;
}

.footer-link:hover {
    opacity: 0.75;
}

.footer-copy {
    font-size: 12px;
    color: #9c9c9c;
    margin-top: 4px;
}


/* === ADDITIONAL PARAMETERS === */
.additional-toggle {
    margin: 0.5rem 0 0;
    padding: 0.875rem 1.25rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    font-weight: 500;
    font-size: clamp(0.95rem, 2.6vw, 1.05rem);
    letter-spacing: 0.1px;
    line-height: 1.3;
    color: #2c3e50;
    background: #f4f6f8;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
}

.additional-toggle:hover {
    background: #eef2f6;
    border-color: #cfd6dd;
    transform: translateY(-1px);
}

.additional-toggle::after {
    content: "▼";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: #2980b9;
    transition: transform 0.35s cubic-bezier(.25,.46,.45,.94);
}

#additional-params {
    /* Убираем overflow: hidden и используем max-height с padding */
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: max-height 0.45s ease, opacity 0.35s ease, transform 0.35s ease;
    /* Добавляем padding для внутреннего пространства */
    padding: 0;
}

#additional-params.open {
    max-height: 2000px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    /* Добавляем небольшой отступ снизу для tooltips */
    padding-bottom: 10px;
}

#additional-params.open .field-row {
    animation: fadeInParams 0.4s ease forwards;
    animation-delay: 0.05s;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .field-row {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem 0;
        align-items: stretch;
    }

    .field-left, .field-right {
        width: 100%;
        min-width: auto;
    }

    main {
        padding: 1.5rem;
        max-width: 100%;
    }

    header h1 {
        font-size: 2rem;
    }

    /* УПРОЩЕННЫЕ СТИЛИ ТУЛТИПОВ */
    .field-tooltip .tooltip-text {
        font-size: 0.9rem;
        z-index: 10000;
        padding: 12px 14px;
        box-sizing: border-box;
        background: rgba(44,62,80,0.95);
        color: #fff;
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        line-height: 1.4;
        position: absolute;
        width: 300px;
        max-width: 300px;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        transform: none;
    }

    /* Скрываем стрелки на мобильных */
    .field-tooltip .tooltip-text.tooltip-above::after,
    .field-tooltip .tooltip-text.tooltip-below::after {
        display: none;
    }

    .field-message {
        font-size: 0.85rem;
        padding: 10px;
        position: relative;
        margin-top: 0.5rem;
    }

    /* Аккордеон на мобильных */
    .additional-toggle {
        padding: 1rem;
        font-size: 1rem;
    }

    #additional-params.open {
        padding-bottom: 20px;
        overflow: visible;
    }

    #additional-params {
        overflow: visible;
    }

    /* Предотвращаем горизонтальный скролл при открытых тултипах */
    body.tooltip-mobile-open {
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    main {
        padding: 1rem;
        border-radius: 12px;
    }

    header h1 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }

    input[type="text"], select {
        font-size: 1rem;
        padding: 0.75rem;
        border-radius: 10px;
    }

    button,
    a.button {
        font-size: 1rem;
        padding: 0.875rem;
        border-radius: 10px;
        width: 100%;
    }

    .field-tooltip .tooltip-text {
        padding: 10px 12px;
    }

    .field-tooltip {
        padding: 4px 0;
    }
    
    .exclusive-option {
        padding: 0.5rem 0.75rem;
    }
    
    .checkbox-inline {
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 360px) {
    .date-field select {
        min-width: 100px;
        font-size: 0.85rem;
        padding: 0.5rem;
    }
    
    .date-field {
        gap: 0.5rem;
    }

    .field-tooltip .tooltip-text {
        font-size: 0.85rem;
        padding: 8px 10px;
    }

    .additional-toggle {
        padding: 0.875rem;
        font-size: 0.95rem;
    }

    .field-row {
        padding: 0.75rem 0;
        gap: 0.75rem;
    }
}

/* Дополнительные улучшения для touch-устройств */
@media (hover: none) and (pointer: coarse) {
    .tooltip-icon {
        min-width: 24px;
        min-height: 24px;
        cursor: pointer;
    }
    
    .checkbox-inline {
        padding: 0.5rem 0.75rem;
        cursor: pointer;
    }
    
    .exclusive-option {
        padding: 0.5rem 0.75rem;
        cursor: pointer;
    }

    .tooltip-icon:active {
        transform: scale(0.95);
        background: #2471a3;
    }
}

/* ГАРАНТИРУЕМ, ЧТО ТУЛТИПЫ ВСЕГДА ПОВЕРХ ВСЕГО КОНТЕНТА */
.field-tooltip .tooltip-text {
    z-index: 10001;
}

/* Предотвращаем скролл страницы при открытых тултипах */
body.tooltip-mobile-open {
    overflow: hidden;
}