/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-align: left;
}

h1 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
    color: #2c3e50;
    flex-shrink: 0;
    width: 100%;
}

h1 i {
    color: #e74c3c;
    margin-right: 10px;
}

.container {
    display: flex;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    flex: 1;
    min-height: 0;
    width: 100%;
    text-align: left;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 25px;
    color: #2c3e50;
    top: 0;
    background: white;
    z-index: 5;
    text-align: center;
}

.heart-section {
    width: 25%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-right: 1px solid #dee2e6;
    position: relative;
    overflow: hidden;
}

.heart-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.heart-img {
    width: 100%;
    height: auto;
    max-width: 400px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
    -webkit-user-drag: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    pointer-events: none;
    transform-origin: center center;
    will-change: transform;
    animation: heartbeat 1.4s infinite ease-in-out;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.05); }
    28% { transform: scale(1); }
    42% { transform: scale(1.03); }
    70% { transform: scale(1); }
    100% { transform: scale(1); }
}

.heart-img:hover {
    animation-play-state: paused;
}

.patient-data-section {
    width: 40%;
    padding: 25px;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
}

.results-section {
    width: 35%;
    padding: 25px;
    background-color: #fafbfc;
    overflow-y: auto;
    position: relative;
}

.patient-data-section::-webkit-scrollbar,
.results-section::-webkit-scrollbar {
    width: 6px;
}
.patient-data-section::-webkit-scrollbar-thumb,
.results-section::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.form-group {
    margin-bottom: 22px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
    text-align: left;
}

input[type="number"], input[type="range"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 5px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.heart-mass-options, .ef-method-options {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.heart-mass-option, .ef-method-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    background-color: #f8f9fa;
    text-align: center;
    min-height: 60px;
    transition: all 0.3s ease;
    color: #495057;
}

.heart-mass-option i, .ef-method-option i {
    font-size: 18px;
    margin-bottom: 5px;
    color: #495057;
    transition: color 0.3s ease;
}

.heart-mass-option span, .ef-method-option span {
    font-weight: 500;
    font-size: 13px;
    transition: color 0.3s ease;
}

.heart-mass-option.selected, .ef-method-option.selected {
    background-color: #2c3e50;
    border-color: #2c3e50;
}

.heart-mass-option.selected i, .ef-method-option.selected i {
    color: white;
}

.heart-mass-option.selected span, .ef-method-option.selected span {
    color: white;
}

.heart-mass-option:hover, .ef-method-option:hover {
    background-color: #e9ecef;
}

.heart-mass-input-wrapper {
    width: 100%;
    transition: all 0.3s ease;
    margin-top: 15px;
}

.heart-mass-input-visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
    max-height: 100px;
    overflow: hidden;
}

.heart-mass-input-hidden {
    display: block !important;
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    pointer-events: none;
}

#heart-mass {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background-color: white;
}

#heart-mass:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.ef-section {
    transition: all 0.3s ease;
    margin-top: 15px;
}

.ef-section-visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
    max-height: 500px;
    overflow: visible;
}

.ef-section-hidden {
    display: block !important;
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    pointer-events: none;
}

.occlusion-group {
    margin-top: 10px;
}

.occlusion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.occlusion-name {
    flex: 2;
    font-size: 14px;
    color: #495057;
}

.occlusion-value {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.occlusion-value input {
    width: 80px;
    text-align: center;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 8px;
}

.slider {
    flex: 1;
}

.slider-value {
    font-weight: 600;
    color: #2c3e50;
    min-width: 50px;
}

.result-item {
    background-color: white;
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    text-align: left;
}

.result-label {
    font-size: 14px;
    color: #495057;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.result-value {
    font-size: 18px;
    font-weight: 600;
    color: #212529;
}

.result-value.clickable {
    cursor: pointer;
    text-decoration: underline dotted #3498db;
}

.thickness-info {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
    font-style: italic;
}

.info-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background-color: #3498db;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-left: 4px;
}

.info-trigger i {
    font-size: 12px;
    line-height: 1;
}

.info-trigger:hover {
    background-color: #2980b9;
}

.formula-btn,
.analysis-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 20px;
    padding: 4px 14px;
    margin-left: 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    letter-spacing: 0.3px;
}

.formula-btn:hover,
.analysis-btn:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46a0 100%);
    transform: translateY(-1px);
}

.formula-btn:active,
.analysis-btn:active {
    transform: translateY(1px);
}

.ef-breakdown {
    background-color: #fef9e7;
    border: 1px solid #f1c40f;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    font-size: 13px;
}

.ef-breakdown.hidden {
    display: none;
}

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

.breakdown-header h4 {
    font-size: 16px;
    color: #2c3e50;
    margin: 0;
}

.close-breakdown {
    font-size: 20px;
    cursor: pointer;
    color: #7f8c8d;
}

.close-breakdown:hover {
    color: #e74c3c;
}

.breakdown-content table {
    width: 100%;
    border-collapse: collapse;
}

.breakdown-content th {
    text-align: left;
    background-color: #ecf0f1;
    padding: 8px;
    font-weight: 600;
    font-size: 12px;
}

.breakdown-content td {
    padding: 6px 8px;
    border-bottom: 1px solid #ddd;
}

.breakdown-content .factor-name {
    font-weight: 500;
}

.breakdown-content .value {
    text-align: center;
}

.breakdown-content .impact {
    text-align: right;
    font-family: monospace;
}

.breakdown-content .total-row {
    font-weight: 600;
    background-color: #f8f9fa;
}

.breakdown-note {
    margin-top: 10px;
    font-style: italic;
    color: #7f8c8d;
    font-size: 12px;
}

.toggle-results-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-top: 15px;
    background-color: #ffffff;
    color: #2c3e50;
    border: 2px solid #3498db;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.toggle-results-btn:hover {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
}

/* ====================== МОДАЛЬНІ ВІКНА ====================== */
.formula-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 35, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: overlayFadeIn 0.25s ease;
}

.formula-modal.hidden {
    display: none;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.formula-modal-box {
    background: #ffffff;
    border-radius: 16px;
    width: 94%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.1);
    animation: modalSlideIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Сховати скролбар, але залишити прокрутку */
.formula-modal-box {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}
.formula-modal-box::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

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

.formula-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px 16px;
    background: linear-gradient(135deg, #3a49af 0%, #2a3a8f 100%);
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.formula-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.formula-modal-title i {
    font-size: 20px;
    opacity: 0.9;
}

.formula-modal-title h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.2px;
}

.formula-modal-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.formula-modal-close-btn:hover {
    background: rgba(255,255,255,0.35);
}

.formula-modal-body {
    padding: 22px 24px 26px;
}

/* Стилі для блоків у модальних вікнах */
.ef-main-formula,
.fib-main-formula {
    background: linear-gradient(135deg, #eef6fc 0%, #e2f0f7 100%);
    border: 2px solid #b0d4ee;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 20px;
    text-align: center;
}

.ef-main-formula-label,
.fib-main-formula-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #2c7da0;
    margin-bottom: 8px;
}

.normal-formula-text {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.4;
    word-break: break-word;
}

.ef-inputs-block,
.fib-inputs-block {
    margin-bottom: 20px;
}

.ef-section-title,
.fib-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #7f8c8d;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ef-section-title::after,
.fib-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ecf0f1;
}

.ef-inputs-grid,
.fib-inputs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.ef-input-chip,
.fib-input-chip {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}

.ef-input-chip .chip-var,
.fib-input-chip .chip-var {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #1f6392;
}

.ef-input-chip .chip-desc,
.fib-input-chip .chip-desc {
    font-size: 11px;
    color: #6c757d;
    margin-top: 3px;
    line-height: 1.3;
}

.ef-steps,
.fib-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ef-step,
.fib-step {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.ef-step-header,
.fib-step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.ef-step-num,
.fib-step-num {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #3a49af, #2a3a8f);
    color: white;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ef-step-title,
.fib-step-title {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
}

.ef-step-body,
.fib-step-body {
    padding: 12px 14px;
}

.ef-formula-line,
.fib-formula-line {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    background: #f8f9fa;
    border-left: 3px solid #3a49af;
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    color: #2c3e50;
    line-height: 1.6;
    margin-bottom: 6px;
}

.ef-formula-line:last-child,
.fib-formula-line:last-child {
    margin-bottom: 0;
}

.ef-result-note,
.fib-result-note {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #eaf6fb;
    border: 1px solid #aed6f1;
    border-radius: 7px;
    padding: 10px 14px;
    margin-top: 18px;
    font-size: 13px;
    color: #1a5276;
}

.ef-result-note i,
.fib-result-note i {
    color: #2980b9;
    font-size: 15px;
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    body {
        overflow-y: auto;
        height: auto;
    }
    .container {
        flex-direction: column;
        height: auto;
    }
    .heart-section, .patient-data-section, .results-section {
        width: 100%;
        border-right: none;
        overflow: visible;
    }
    .heart-section {
        min-height: 250px;
        border-bottom: 1px solid #dee2e6;
    }
    .patient-data-section {
        border-bottom: 1px solid #dee2e6;
    }
    .heart-mass-options, .ef-method-options {
        flex-direction: column;
    }
    .radio-group {
        flex-direction: column;
        gap: 10px;
    }
    .occlusion-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .occlusion-value {
        width: 100%;
        justify-content: flex-start;
    }
    .formula-btn, .analysis-btn {
        margin-left: 0;
        margin-top: 6px;
        padding: 6px 16px;
        font-size: 13px;
    }
    .formula-modal-box, .fib-modal-box {
        max-width: 95%;
    }
}

input:focus, select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}