/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 900px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    min-height: 600px;
}

/* Screen Management */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* Typography */
h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
    text-align: center;
}

h2 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

h3 {
    font-size: 1.3rem;
    color: #34495e;
    margin-bottom: 15px;
}

h4 {
    font-size: 1.1rem;
    color: #34495e;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    font-size: 1.2rem;
    color: #7f8c8d;
    margin-bottom: 30px;
}

/* Info Boxes */
.info-box {
    background: #ecf0f1;
    border-left: 4px solid #3498db;
    padding: 20px;
    margin: 20px 0;
    border-radius: 5px;
}

.info-box.warning {
    background: #fff3cd;
    border-left-color: #f39c12;
}

.info-box ul {
    margin-left: 20px;
    margin-top: 10px;
}

.info-box li {
    margin: 8px 0;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 15px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    display: inline-block;
    margin: 10px 5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
    border: 2px solid #bdc3c7;
}

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

.btn-primary:active,
.btn-secondary:active {
    transform: translateY(0);
}

/* Welcome Screen */
#welcome-screen {
    text-align: center;
}

#welcome-screen .btn-primary {
    margin-top: 20px;
    font-size: 1.3rem;
    padding: 20px 40px;
}

/* Calibration Screen */
.calibration-step {
    text-align: center;
    padding: 20px 0;
}

.calibration-step.hidden {
    display: none;
}

.headphone-test {
    margin: 30px 0;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.hint {
    color: #7f8c8d;
    font-style: italic;
    margin: 15px 0;
}

/* Test Screen */
.test-header {
    margin-bottom: 15px;
}

.test-header h2 {
    font-size: 1.8em;
    margin: 0 0 10px 0;
}

.progress-info {
    margin-top: 15px;
}

.current-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.current-info strong {
    color: #667eea;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #ecf0f1;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.test-content {
    text-align: center;
    padding: 40px 0;
}

.instruction {
    margin-bottom: 40px;
}

.instruction p {
    font-size: 1.1rem;
    margin: 10px 0;
}

.btn-hear-it {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    border: 8px solid #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.btn-hear-it:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.5);
}

.btn-hear-it:active {
    transform: scale(0.95);
}

.btn-hear-it .button-text {
    font-size: 2rem;
    display: block;
}

.btn-hear-it .button-hint {
    font-size: 0.9rem;
    margin-top: 10px;
    opacity: 0.8;
    display: block;
}

.test-status {
    margin-top: 30px;
    font-size: 1.1rem;
    color: #7f8c8d;
    min-height: 30px;
}

.skip-container {
    margin-top: 40px;
    text-align: center;
}

.btn-skip {
    padding: 10px 25px;
    font-size: 0.9rem;
    border: 2px solid #95a5a6;
    background: transparent;
    color: #7f8c8d;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-skip:hover {
    background: #ecf0f1;
    border-color: #7f8c8d;
    color: #2c3e50;
}

.btn-skip:active {
    transform: scale(0.98);
}

/* Results Screen */
.audiogram-container {
    margin: 30px 0;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#audiogram-chart {
    max-width: 100%;
    height: auto;
}

.results-info {
    margin: 30px 0;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}

.legend-color {
    width: 30px;
    height: 4px;
    border-radius: 2px;
}

.interpretation {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.interpretation ul {
    margin-left: 20px;
    margin-top: 10px;
}

.interpretation li {
    margin: 8px 0;
}

.results-actions {
    text-align: center;
    margin-top: 30px;
}

/* Tutorial Screen */
.tutorial-header {
    text-align: center;
    margin-bottom: 30px;
}

.tutorial-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 10px 25px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 15px;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.tutorial-content {
    max-width: 700px;
    margin: 0 auto;
}

.tutorial-practice {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin: 30px 0;
    text-align: center;
}

.tutorial-practice h3 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 15px;
}

.tutorial-practice p {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 25px;
}

.tutorial-practice #start-tutorial-btn {
    margin: 20px auto 30px;
    display: block;
}

#tutorial-button {
    margin: 20px auto;
    display: block;
}

.tutorial-status {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 500;
    margin: 20px 0;
    padding: 15px;
    background: white;
    border-radius: 10px;
    border: 2px solid #ecf0f1;
}

.tutorial-progress {
    text-align: center;
    font-size: 1.1rem;
    color: #7f8c8d;
    margin-top: 15px;
}

.tutorial-progress strong {
    color: #3498db;
    font-size: 1.3rem;
}

#finish-tutorial-btn {
    margin: 30px auto 20px;
    display: block;
}

.tutorial-content .hint {
    text-align: center;
    margin-top: 40px;
}

/* Test Selection Screen */
.test-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.test-card {
    background: #f8f9fa;
    border: 3px solid #ecf0f1;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.test-card:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.test-card-recommended {
    border-color: #f39c12;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
}

.test-card-recommended:hover {
    border-color: #e67e22;
}

.test-card-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 5px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(243, 156, 18, 0.3);
}

.test-card-icon {
    font-size: 3.5rem;
    margin-bottom: 15px;
}

.test-card h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.test-card p {
    color: #7f8c8d;
    line-height: 1.6;
    margin-bottom: 20px;
}

.test-card-features {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}

.test-card-features li {
    color: #34495e;
    padding: 8px 0;
    border-bottom: 1px solid #ecf0f1;
}

.test-card-features li:last-child {
    border-bottom: none;
}

.test-card .btn-primary {
    margin-top: auto;
    width: 100%;
    flex-shrink: 0;
}

.test-card-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.language-notice {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    color: #856404;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
}

/* Speech Test Screen */
.speech-test-content {
    text-align: center;
    padding: 40px 20px;
    max-width: 700px;
    margin: 0 auto;
}

.speech-word-display {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 30px 0;
}

.listening-indicator {
    font-size: 1.5rem;
    color: #667eea;
    font-weight: 600;
}

.speech-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 30px 0;
}

.btn-speech-option {
    padding: 20px;
    font-size: 1.2rem;
    background: white;
    border: 3px solid #ecf0f1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    color: #2c3e50;
}

.btn-speech-option:hover {
    border-color: #667eea;
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.btn-speech-option:active {
    transform: translateY(0);
}

.speech-replay {
    margin-top: 30px;
}

.speech-replay .btn-secondary {
    margin: 0 auto;
    display: block;
}

/* Speech Results */
.results-section {
    margin: 30px 0;
}

.results-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

.speech-results-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
}

.speech-threshold-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 30px;
    border: 2px solid #ecf0f1;
}

.speech-threshold-label {
    font-size: 1.1rem;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.speech-threshold-value {
    font-size: 3rem;
    font-weight: bold;
    color: #667eea;
    margin: 15px 0;
}

.speech-threshold-desc {
    font-size: 0.95rem;
    color: #95a5a6;
    margin-top: 10px;
}

.speech-chart-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
}

.speech-performance-table {
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border-collapse: collapse;
}

.speech-performance-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.speech-performance-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.speech-performance-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #ecf0f1;
}

.speech-performance-table tr:last-child td {
    border-bottom: none;
}

.speech-performance-table tr:hover {
    background: #f8f9fa;
}

.percentage-bar {
    position: relative;
    width: 100%;
    height: 30px;
    background: #ecf0f1;
    border-radius: 15px;
    overflow: hidden;
}

.percentage-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 100%);
    transition: width 0.3s ease;
}

.percentage-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .btn-hear-it {
        width: 250px;
        height: 250px;
    }

    .btn-hear-it .button-text {
        font-size: 1.5rem;
    }

    .current-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .headphone-test {
        flex-direction: column;
        align-items: center;
    }

    .legend {
        flex-direction: column;
        align-items: center;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* Language Selector */
.language-selector-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.language-selector {
    padding: 8px 12px;
    font-size: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.language-selector:hover {
    background: white;
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.language-selector:focus {
    outline: none;
    border-color: #667eea;
}

/* RTL Support for Hebrew */
body.rtl {
    direction: rtl;
}

body.rtl .language-selector-container {
    left: 20px;
    right: auto;
}

body.rtl .container {
    text-align: right;
}

body.rtl .btn-primary,
body.rtl .btn-secondary,
body.rtl .btn-skip {
    text-align: center;
}

body.rtl ul,
body.rtl ol {
    padding-right: 20px;
    padding-left: 0;
}

body.rtl .info-box ul {
    margin-right: 20px;
    margin-left: 0;
}

body.rtl .interpretation ul {
    margin-right: 20px;
    margin-left: 0;
}

body.rtl .current-info {
    direction: rtl;
}

body.rtl .legend {
    direction: rtl;
}

body.rtl .legend-item {
    flex-direction: row-reverse;
}

/* Hebrew font support */
body.rtl {
    font-family: 'Segoe UI', 'Arial', 'Helvetica', sans-serif;
}
