/* assets/style.css */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;800&display=swap');

:root {
    --primary: #6C63FF;
    --primary-dark: #5a52d5;
    --secondary: #FF6584;
    --accent: #43D8C9;
    --bg-gradient: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-main: #2D3436;
    --text-muted: #636e72;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 40px rgba(108, 99, 255, 0.2);
    --radius: 20px;
}

* {
    box-sizing: border-box;
    outline: none;
}

body {
    font-family: 'Nunito', sans-serif;
    background: #f0f2f5;
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-attachment: fixed;
    background-size: cover;
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Логотип на фоне */
body::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    height: 80vh;
    background: url('eEar_tm_transparent.png') no-repeat center center;
    background-size: contain;
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

.app-container {
    max-width: 1000px;
    width: 95%;
    margin: 20px auto;
    animation: fadeIn 0.6s ease-out;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Хедер */
header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--glass-border);
    margin-bottom: 30px;
}

.logo {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

nav {
    display: flex;
    gap: 15px;
}

.btn-nav {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 30px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.btn-nav:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 99, 255, 0.1);
}

.btn-nav.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 5px 15px rgba(108, 99, 255, 0.3);
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-select-wrapper {
    display: inline-block;
}

/* Hide tooltip when dropdown is open */
.lang-select-wrapper:focus-within::after,
.lang-select-wrapper:focus-within::before {
    opacity: 0 !important;
    visibility: hidden !important;
}

.lang-switch select {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: 5px 10px;
    color: var(--text-muted);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: 0.3s;
}

.lang-switch select:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.logout-btn {
    text-decoration: none;
    color: var(--secondary);
    font-weight: bold;
    font-size: 1.2rem;
    transition: 0.3s;
}

.logout-btn:hover {
    transform: scale(1.2);
}

/* Карточки и контент */
.main-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-soft);
    border: 1px solid #ffffff;
    opacity: 0.9;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: var(--text-main);
}

h1 {
    font-weight: 800;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.emoji-raw {
    background: none;
    -webkit-text-fill-color: initial;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #eee;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: 0.3s;
    background: rgba(255, 255, 255, 0.8);
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

/* Кнопки */
.btn-primary,
button[type="submit"] {
    background: linear-gradient(45deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary:hover,
button[type="submit"]:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

/* Сетка тестов */
.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.test-card {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
}

.test-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.test-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: var(--shadow-hover);
    border-color: rgba(108, 99, 255, 0.1);
}

.test-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.test-icon-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.test-icon-img-sm {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Disabled test card (age restricted) */
.test-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(60%);
}

.test-card.disabled::before {
    background: linear-gradient(90deg, #999, #aaa);
}

.test-card.disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: transparent;
}

/* Age restriction badge */
.age-restriction-badge {
    margin-top: 15px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.3);
}

/* Статистика */
.stat-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.ai-box {
    background: linear-gradient(135deg, #6C63FF 0%, #8B85FF 100%);
    color: white;
    padding: 25px;
    border-radius: var(--radius);
    flex: 1;
    min-width: 300px;
    box-shadow: 0 10px 20px rgba(108, 99, 255, 0.3);
}

.chart-container {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow-soft);
    position: relative;
    height: 300px;
}

/* Таблица */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}

th {
    text-align: left;
    color: var(--text-muted);
    padding: 10px 20px;
    font-size: 0.85rem;
    text-transform: uppercase;
}

td {
    background: white;
    padding: 15px 20px;
    transition: 0.2s;
}

tr td:first-child {
    border-radius: 10px 0 0 10px;
}

tr td:last-child {
    border-radius: 0 10px 10px 0;
}

tr:hover td {
    transform: scale(1.01);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    z-index: 1;
    position: relative;
}

/* Приветственное сообщение */
.welcome-message {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-message h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 0px rgba(0, 0, 0, 0.5));
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.7);
    paint-order: stroke fill;
}

.welcome-message p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Адаптивность */
@media (max-width: 768px) {
    header {
        padding: 10px 15px;
        flex-direction: column;
        gap: 10px;
    }

    .main-card {
        padding: 10px;
    }

    #factoryballs-container {
        margin-left: -10px;
        margin-right: -10px;
        width: calc(100% + 20px) !important;
    }
}

/* Help Feature Styles */
.help-icon-container {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(108, 99, 255, 0.3);
    transition: all 0.3s ease;
    position: relative;
    margin-right: 10px;
}

.help-icon-container:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 6px 15px rgba(108, 99, 255, 0.5);
}

/* Tooltip */
.help-icon-container::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.help-icon-container::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.help-icon-container:hover::after,
.help-icon-container:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Generic Tooltip Class for Header Elements */
.has-tooltip {
    position: relative;
    transition: all 0.3s ease;
}

.has-tooltip:hover {
    transform: scale(1.05) rotate(3deg);
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.has-tooltip::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent rgba(0, 0, 0, 0.85) transparent;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.has-tooltip:hover::after,
.has-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Generic Modal Styles */
.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Help Modal Specifics */
.help-modal-content {
    max-width: 700px;
    width: 95%;
    text-align: left;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s;
    z-index: 10;
}

.close-modal-btn:hover {
    color: var(--secondary);
}

.help-header {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    padding: 30px;
    text-align: center;
    position: relative;
}

.help-header h2 {
    margin: 15px 0 0;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.help-logo img {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.help-body {
    padding: 30px;
    overflow-y: auto;
}

.help-intro {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-main);
    margin-bottom: 30px;
    text-align: center;
}

.help-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.help-feature-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    transition: transform 0.3s;
}

.help-feature-card:hover {
    transform: translateY(-5px);
    background: white;
    box-shadow: var(--shadow-soft);
}

.feature-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
}

.help-feature-card h4 {
    margin: 0 0 10px;
    color: var(--primary);
}

.help-feature-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

.help-tests-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.help-test-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    transition: all 0.2s;
}

.help-test-item:hover {
    border-color: var(--primary);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.test-item-icon {
    font-size: 1.5rem;
    background: #f0f2f5;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
}

.help-test-item strong {
    display: block;
    margin-bottom: 5px;
    color: var(--text-main);
}

.help-test-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Access Key Styles */
.access-key-card {
    background: linear-gradient(135deg, #6C63FF 0%, #4834d4 100%);
    color: white;
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(108, 99, 255, 0.2);
}

.access-key-card h3 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}

.access-key-card p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.key-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 15px;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    user-select: all;
}

.copy-btn {
    background: white;
    color: #6C63FF;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 20px;
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.qr-section {
    background: white;
    padding: 15px;
    border-radius: 15px;
    display: inline-block;
}

.qr-code-container {
    margin-bottom: 5px;
}

.qr-label {
    color: #333;
    font-size: 0.8rem !important;
    margin: 0 !important;
    font-weight: 600;
}

/* Results Collapse Feature */
.results-wrapper {
    position: relative;
}

.results-wrapper table tbody tr {
    transition: opacity 0.3s ease;
}

.results-wrapper.collapsed .hidden-row {
    display: none;
}

.results-wrapper .fade-row-1 td {
    opacity: 0.9;
}

.results-wrapper.collapsed .fade-row-2 td {
    opacity: 0.6;
}

.results-wrapper.collapsed .fade-row-3 td {
    opacity: 0.3;
}

.show-more-btn {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #f0f2f5, #e8eaed);
    border: 1px solid #ddd;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    text-align: center;
}

.show-more-btn:hover {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 99, 255, 0.3);
}

/* Toast Notification - Celebratory Style */
.toast-notification {
    visibility: hidden;
    min-width: 280px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FF8C00 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #4a3000;
    text-align: center;
    border-radius: 16px;
    padding: 16px 40px;
    position: fixed;
    z-index: 3000;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    font-size: 1.3rem;
    font-weight: 800;
    box-shadow: 0 15px 50px rgba(255, 165, 0, 0.5),
        0 0 30px rgba(255, 215, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.6);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);

    /* Flex centering for content */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.toast-notification.show {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}