/* General Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    /* Убираем flex с body, он тут мешает */
}

#app {
    width: 100%;
    max-width: 100%; /* Разрешаем на всю ширину для футера */
    min-height: 100vh; /* Минимальная высота - весь экран */
    display: flex;
    flex-direction: column;
    align-items: center; /* Центрируем содержимое (шапку и main) */
    box-sizing: border-box;
    padding: 0; /* Отступы перенесем в main */
}

header, main {
    width: 100%;
    max-width: 1600px; /* Ограничиваем ширину только контента */
    padding: 0 20px;
    box-sizing: border-box;
}

header {
    margin-top: 20px;
}

main {
    flex: 1; /* Растягиваем main, чтобы прижать футер */
    display: flex;
    flex-direction: column;
    align-items: center; /* Центрируем блоки сравнения */
    padding-top: 20px;
    padding-bottom: 40px;
}

/* --- Footer --- */
footer {
    background: #1a1a1a;
    color: #888;
    padding: 60px 40px;
    text-align: center;
    margin-top: auto; /* Дополнительная гарантия прижатия */
    width: 100%;
    align-self: stretch; /* Футер на всю ширину #app */
}

header h1 {
    font-size: 1.5em;
    margin: 0;
    color: #1c1e21;
}

/* Navigation */
nav {
    display: flex;
    gap: 15px;
}
nav a {
    color: #1877f2;
    text-decoration: none;
    font-weight: 500;
}
nav a:hover {
    text-decoration: underline;
}

/* Stats Container */
#stats-container {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
    color: #606770;
}

#stats-container p {
    margin: 0;
}

/* Help Button */
.help-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
}

#help-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #1877f2;
    background-color: #fff;
    color: #1877f2;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
}

#help-btn:hover {
    background-color: #1877f2;
    color: #fff;
    transform: scale(1.05);
}

.help-panel {
    position: fixed;
    bottom: 70px;
    left: 20px;
    width: 280px;
    background-color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid #1877f2;
    z-index: 99;
}

.help-panel p {
    margin: 8px 0;
    line-height: 1.5;
    color: #3c4043;
    font-size: 0.85em;
}

/* Comparison Area */
main#comparison-container {
    padding: 10px;
}

main#comparison-container.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.layout-horizontal {
    display: flex;
    flex-direction: row;
    gap: 25px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: nowrap;
}

.faces-section {
    display: flex;
    flex-direction: row;
    gap: 15px;
    flex-shrink: 0;
}

.face-card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 12px;
    text-align: center;
}

.face-card img {
    width: 220px;
    height: auto;
    border-radius: 6px;
    display: block;
}

.face-label {
    margin-top: 10px;
    font-size: 1em;
    font-weight: 600;
    color: #1c1e21;
}

/* Zone Ratings */
#zones-container {
    flex: 1;
    max-width: 600px;
    background-color: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.zone-rating.focused {
    border: 4px solid #1877f2;
    border-radius: 8px;
    padding: 12px;
    margin: -4px;
    margin-bottom: 14px;
    background-color: #f7f9fc;
}

.zone-rating.focused h3 {
    color: #1877f2;
    font-weight: 700;
    font-size: 1.05em;
}

.zone-rating.focused h3::before {
    content: '▶ ';
}

.zone-rating.keyboard-activated {
    animation: keyboard-flash 0.2s ease;
}

@keyframes keyboard-flash {
    0%, 100% { box-shadow: 0 0 0 rgba(24, 119, 242, 0); }
    50% { box-shadow: 0 0 20px rgba(24, 119, 242, 0.6); }
}

.zone-rating {
    margin-bottom: 18px;
}

.zone-rating:last-child {
    margin-bottom: 0;
}

.zone-rating h3 {
    margin: 0 0 10px 0;
    font-size: 0.95em;
    color: #1c1e21;
    font-weight: 600;
}

.rating-buttons {
    display: flex;
    gap: 8px;
}

.zone-btn {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #dddfe2;
    border-radius: 6px;
    background-color: #fff;
    color: #1c1e21;
    font-weight: 500;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.zone-btn:hover {
    background-color: #f0f2f5;
    border-color: #1877f2;
}

.zone-btn.selected {
    background-color: #1877f2;
    color: #fff;
    border-color: #1877f2;
}

.zone-btn.selected:hover {
    background-color: #166fe5;
    border-color: #166fe5;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.zone-btn.pulse {
    animation: pulse 0.3s ease;
}

.zone-btn.equal {
    background-color: #f7f9fc;
    border-color: #b0c4de;
}

.zone-btn.equal:hover {
    background-color: #e8f0fe;
    border-color: #1877f2;
}

.zone-btn.equal.selected {
    background-color: #606770;
    color: #fff;
    border-color: #606770;
    font-style: normal;
}

/* Submit Section */
.submit-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

#submit-btn {
    padding: 14px 50px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    background-color: #1877f2;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
}

#submit-btn:hover:not(:disabled) {
    background-color: #166fe5;
}

#submit-btn:disabled {
    background-color: #dddfe2;
    color: #8a8d91;
    cursor: not-allowed;
    box-shadow: none;
}

#submit-btn.submitting {
    background-color: #8a8d91;
    cursor: wait;
}

#submit-btn.pulse-hint {
    animation: pulse-hint 1s ease;
}

@keyframes pulse-hint {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
    }
    25%, 75% {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(24, 119, 242, 0.6);
    }
    50% {
        transform: scale(1);
        box-shadow: 0 2px 6px rgba(24, 119, 242, 0.3);
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

#loading-message {
    text-align: center;
    font-size: 1.2em;
    color: #606770;
    margin-top: 100px;
}

.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background-color: #42b983;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

/* Mobile Responsive */
@media (max-width: 1000px) {
    .layout-horizontal {
        flex-direction: column;
        align-items: center;
    }
    .face-card img {
        width: 180px;
    }
}

/* --- Footer --- */
footer {
    background: #1a1a1a;
    color: #888;
    padding: 60px 40px;
    text-align: center;
    margin-top: 100px;
    width: 100%;
    box-sizing: border-box;
}

footer p {
    margin: 10px 0;
}

footer .footer-nav {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

footer .footer-nav a {
    color: #fff;
    text-decoration: none;
    font-size: 0.9em;
    opacity: 0.6;
    transition: opacity 0.3s;
}

footer .footer-nav a:hover {
    opacity: 1;
}

/* --- Mobile Responsiveness for Comparison Tool --- */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    header h1 {
        font-size: 1.4em;
    }

    nav {
        font-size: 0.95em;
    }

    #stats-container {
        font-size: 0.8em;
        justify-content: center;
        width: 100%;
        gap: 15px;
    }

    main#comparison-container {
        padding: 10px 5px;
    }

    /* Force layout column */
    .layout-horizontal {
        flex-direction: column;
        gap: 15px;
    }

    /* Keep faces side-by-side but smaller */
    .faces-section {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
    }

    .face-card {
        width: 48%; /* Fit two cards */
        padding: 8px;
        box-sizing: border-box;
    }

    .face-card img {
        width: 100%; /* Responsive image width */
        height: auto;
    }

    .face-label {
        font-size: 0.9em;
        margin-top: 5px;
    }

    /* Zones container full width */
    #zones-container {
        width: 100%;
        max-width: 100%;
        padding: 15px 10px;
        box-sizing: border-box;
    }

    .rating-buttons {
        gap: 5px;
    }

    .zone-btn {
        padding: 12px 5px;
        font-size: 0.9em;
        /* Increase touch target */
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Sticky submit button at bottom */
    .submit-section {
        position: sticky;
        bottom: 0;
        background: rgba(255, 255, 255, 0.95);
        padding: 15px;
        margin-top: 0;
        border-top: 1px solid #ddd;
        z-index: 90;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        width: 100vw;
        margin-left: -10px; /* Counteract main padding */
        width: calc(100% + 20px);
    }

    #submit-btn {
        width: 90%;
        padding: 15px;
        font-size: 1.1em;
    }

    /* Adjust Help Panel Position */
    .help-toggle {
        bottom: 80px; /* Above sticky submit */
        left: 15px;
    }
    
    .help-panel {
        bottom: 130px;
        left: 10px;
        right: 10px;
        width: auto;
    }

    .desktop-only {
        display: none !important;
    }
}
