/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
}

body {
    background-color: #f5f7ff;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.app-container {
    max-width: 600px;
    width: 100%;
    background-color: white;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 80vh;
}

header {
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    color: white;
    padding: 15px 20px;
    text-align: center;
}

header h1 {
    font-size: 24px;
    font-weight: bold;
}

main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.language-options {
    margin: 20px 0 40px 0; /* Increased bottom margin */
    width: 100%;
    text-align: center;
}

.radio-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.radio-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 20px;
    border-radius: 20px;
    background-color: #f5f7ff;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.radio-option:hover {
    background-color: #eef1ff;
}

.radio-option input[type="radio"] {
    display: none;
}

/* Radio option base styles */
.radio-option {
    position: relative;
    font-size: 14px;
    color: #555;
    transition: all 0.3s ease;
    padding: 10px 20px;
    border-radius: 20px;
    background-color: #f5f7ff;
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0 5px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Hover state */
.radio-option:not(.selected):hover {
    background-color: #eef1ff;
    transform: translateY(-2px);
}

/* Hide the actual radio input */
.radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Selected state */
.radio-option.selected {
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Ensure text is visible over the gradient */
.radio-option span {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* Microphone Section */
.mic-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
}

.mic-button {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    border: none;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.mic-button:hover {
    transform: scale(1.05);
}

.mic-button:active {
    transform: scale(0.98);
}

.mic-button i {
    color: white;
    font-size: 40px;
}

.mic-button.listening {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    }
}

#listening-status {
    font-size: 18px;
    color: #555;
    text-align: center;
}

/* Manual Input */
#manual-input {
    width: 100%;
    text-align: center;
    margin-top: 20px;
}

.input-container {
    display: flex;
    margin-top: 10px;
}

#text-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 10px 0 0 10px;
    font-size: 16px;
}

#submit-text {
    padding: 12px 20px;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    color: white;
    border: none;
    border-radius: 0 10px 10px 0;
    font-size: 16px;
    cursor: pointer;
}

/* Word Choices */
#word-choices {
    width: 100%;
    text-align: center;
    margin-top: 20px;
}

#word-buttons-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.word-choice-button {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.word-choice-button:hover {
    background-color: #e0e0e0;
}

/* Results Section */
#results-section {
    width: 100%;
}

#image-container {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    border-radius: 15px;
    overflow: hidden;
    background-color: #f0f0f0;
}

#word-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.languages-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.language-block {
    padding: 15px;
    border-radius: 15px;
    background-color: #f9f9f9;
}

.language-block h2 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #555;
}

.word-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.word {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.play-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.play-button i {
    color: white;
    font-size: 18px;
}

.reset-button {
    padding: 15px 25px;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Footer */
footer {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
}

.settings-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #f0f0f0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.settings-button i {
    color: #555;
    font-size: 18px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
}

.modal-content h2 {
    margin-bottom: 20px;
    text-align: center;
}

.setting-option {
    margin-bottom: 20px;
}

.setting-option label {
    display: block;
    margin-bottom: 10px;
}

.setting-option select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.close-button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    display: block;
    margin: 0 auto;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #6e8efb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
#error-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

#error-message p {
    background-color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 15px;
    max-width: 300px;
}

#error-close {
    padding: 10px 25px;
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

/* Thai-specific font styling */
#thai-word {
    font-family: 'Sarabun', 'Arial', sans-serif;
}

/* Responsive design */
@media (max-width: 480px) {
    .app-container {
        min-height: 90vh;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .mic-button {
        width: 100px;
        height: 100px;
    }
    
    .mic-button i {
        font-size: 32px;
    }
    
    .word {
        font-size: 20px;
    }
}
