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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.header-title h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 300;
}

/* Authentication */
.header-auth {
    display: flex;
    align-items: center;
}

.auth-loading {
    color: white;
    font-size: 0.9rem;
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.btn-login {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    color: #667eea;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border: 2px solid white;
}

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

.google-icon {
    font-weight: 700;
    font-size: 1.1rem;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px 8px 8px;
    border-radius: 25px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-points {
    font-size: 0.85rem;
    opacity: 0.9;
}

.btn-logout {
    padding: 6px 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-btn {
    padding: 10px 20px;
    background: transparent;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* Main Content */
main {
    padding: 40px 30px;
}

.section {
    animation: fadeIn 0.5s ease-in;
}

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

/* Form Container */
.form-container {
    text-align: center;
}

label {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 15px;
    margin-top: 25px;
}

label:first-of-type {
    margin-top: 0;
}

.language-select,
.grade-select {
    width: 100%;
    max-width: 400px;
    padding: 15px 20px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 25px;
}

.language-select:focus,
.grade-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.language-select:hover,
.grade-select:hover {
    border-color: #764ba2;
}

/* Buttons */
.btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 12px 30px;
    font-size: 1rem;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-secondary-small {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 10px 20px;
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: normal;
}

.btn-secondary-small:hover {
    background: #667eea;
    color: white;
}

/* Save Button */
.btn-save {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.4);
    padding: 12px 30px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(67, 233, 123, 0.6);
}

.btn-save:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* Audio Button */
.btn-audio {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(240, 147, 251, 0.4);
    padding: 12px 30px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
}

.btn-audio:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.6);
}

.btn-audio:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-audio.playing {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
    }
    50% {
        box-shadow: 0 6px 25px rgba(79, 172, 254, 0.8);
    }
}

.audio-icon {
    font-size: 1.2rem;
}

.audio-text {
    font-size: 0.95rem;
}

/* Quiz Button */
.btn-quiz {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.4);
    padding: 15px 40px;
    font-size: 1.1rem;
}

.btn-quiz:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(67, 233, 123, 0.6);
}

.quiz-button-container {
    text-align: center;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

/* Loading Spinner */
.loading {
    margin-top: 30px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.spinner-small {
    width: 30px;
    height: 30px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #f093fb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

.loading p {
    color: #667eea;
    font-weight: 600;
}

.audio-loading {
    text-align: center;
    padding: 15px;
    background: #fff5f7;
    border-radius: 10px;
    margin-bottom: 20px;
}

.audio-loading p {
    color: #f5576c;
    font-weight: 600;
    font-size: 0.95rem;
}

.loading-container {
    text-align: center;
    padding: 20px;
}

/* Error Message */
.error-message {
    margin-top: 20px;
    padding: 15px 20px;
    background: #fee;
    border: 2px solid #fcc;
    border-radius: 10px;
    color: #c33;
    font-weight: 500;
}

/* Story Section */
.story-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.story-header h2 {
    color: #667eea;
    font-size: 2rem;
}

.header-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.story-content {
    background: #f9f9f9;
    padding: 30px;
    border-radius: 15px;
    font-size: 1.2rem;
    line-height: 2;
    color: #333;
    margin-bottom: 25px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.story-content p {
    margin-bottom: 20px;
}

/* Word Highlighting */
.story-content .word {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
    position: relative;
}

.story-content .word:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    z-index: 1000;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

.tooltip-save-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.tooltip-save-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Instructions */
.instructions {
    background: #e8f0fe;
    padding: 15px 20px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.instructions p {
    color: #1967d2;
    font-size: 1rem;
}

/* Quiz Section */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.quiz-header h2 {
    color: #43e97b;
    font-size: 2rem;
}

.quiz-content {
    background: #f9f9f9;
    padding: 30px;
    border-radius: 15px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
}

.quiz-instructions {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 25px;
    font-weight: 500;
}

.quiz-question {
    background: white;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.question-number {
    color: #43e97b;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.6;
}

.question-type {
    font-size: 0.85rem;
    color: #888;
    font-style: italic;
    margin-bottom: 15px;
}

.answer-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: #43e97b;
    box-shadow: 0 0 0 3px rgba(67, 233, 123, 0.1);
}

.true-false-options {
    display: flex;
    gap: 15px;
}

.tf-option {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tf-option:hover {
    border-color: #43e97b;
    background: #f0fdf4;
}

.tf-option.selected {
    border-color: #43e97b;
    background: #43e97b;
    color: white;
}

/* Quiz Results */
.quiz-results {
    text-align: center;
}

.quiz-results h3 {
    color: #43e97b;
    font-size: 2rem;
    margin-bottom: 30px;
}

.score-display {
    margin-bottom: 30px;
}

.score-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(67, 233, 123, 0.4);
}

.score-circle span {
    font-size: 3rem;
    font-weight: 700;
    color: white;
}

#score-message {
    font-size: 1.3rem;
    color: #555;
    font-weight: 600;
    margin-bottom: 10px;
}

.points-earned {
    font-size: 1.1rem;
    color: #43e97b;
    font-weight: 600;
}

#question-feedback {
    text-align: left;
    background: #f9f9f9;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.feedback-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #e0e0e0;
}

.feedback-item.correct {
    border-left-color: #43e97b;
    background: #f0fdf4;
}

.feedback-item.incorrect {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.feedback-question {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.feedback-answer {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.feedback-status {
    font-weight: 600;
    margin-top: 8px;
}

.feedback-status.correct {
    color: #43e97b;
}

.feedback-status.incorrect {
    color: #ef4444;
}

.quiz-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Account Section */
#account-section h2 {
    color: #667eea;
    font-size: 2rem;
    margin-bottom: 30px;
}

.account-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.account-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.account-section-header h3 {
    color: #667eea;
    font-size: 1.5rem;
}

.vocab-filter {
    padding: 8px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
}

/* Saved Stories */
.saved-stories-container,
.vocabulary-container {
    margin-bottom: 40px;
}

#saved-stories-list {
    display: grid;
    gap: 15px;
}

.story-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.story-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.story-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.story-card-title {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
    flex: 1;
}

.story-card-actions {
    display: flex;
    gap: 5px;
}

.story-card-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.story-card-btn:hover {
    opacity: 1;
}

.story-card-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 10px;
}

.story-card-preview {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Vocabulary Table */
#vocabulary-table {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
}

.vocab-item {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr auto;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
}

.vocab-item:last-child {
    border-bottom: none;
}

.vocab-item:hover {
    background: #f9f9f9;
}

.vocab-word {
    font-weight: 600;
    color: #333;
}

.vocab-translation {
    color: #666;
}

.vocab-language {
    color: #888;
    font-size: 0.9rem;
    text-transform: capitalize;
}

.vocab-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.vocab-delete:hover {
    opacity: 1;
    color: #ef4444;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 1.05rem;
}

/* Footer */
footer {
    background: #f5f5f5;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    border-top: 1px solid #e0e0e0;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 15px;
    }

    header {
        padding: 30px 20px 20px;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .header-auth {
        justify-content: center;
    }

    .user-profile {
        justify-content: center;
    }

    .header-title h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 30px 20px;
    }

    .story-header,
    .quiz-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .story-header h2,
    .quiz-header h2 {
        font-size: 1.5rem;
    }

    .header-buttons {
        width: 100%;
        flex-direction: column;
    }

    .btn-audio,
    .btn-save {
        width: 100%;
        justify-content: center;
        margin-right: 0;
    }

    .story-content {
        font-size: 1.1rem;
        padding: 20px;
    }

    .btn {
        width: 100%;
        max-width: 400px;
    }

    .quiz-actions {
        flex-direction: column;
    }

    .quiz-actions .btn {
        width: 100%;
    }

    .account-stats {
        grid-template-columns: 1fr;
    }

    .vocab-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .vocab-language,
    .vocab-delete {
        grid-column: 1;
    }
}

@media (max-width: 480px) {
    .header-title h1 {
        font-size: 1.75rem;
    }

    .story-content {
        font-size: 1rem;
        line-height: 1.8;
    }

    .btn-audio,
    .btn-save {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .score-circle {
        width: 120px;
        height: 120px;
    }

    .score-circle span {
        font-size: 2.5rem;
    }
}
