/* Interactive Reader Styles */
/* Based on story_target_grammar.html */

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 20px;
    background-color: #f9f9f9;
    color: #333;
}

/* Container */
.reader-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Navigation */
.reader-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.reader-nav a {
    color: #2980b9;
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 4px;
}

.reader-nav a:hover {
    background-color: #f0f0f0;
}

.reader-nav .chapter-title {
    font-weight: bold;
    color: #333;
}

/* Paragraph */
.paragraph {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* Sentence */
.sentence {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.sentence:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.sentence-words {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 4px 12px;
}

/* Token base styles */
.token {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Known word styles */
.known-word {
    position: relative;
    color: #2980b9;
    font-weight: bold;
    cursor: pointer;
}

.known-word:hover {
    color: #1abc9c;
}

.known-word .placeholder {
    visibility: hidden;
    font-size: 0.7em;
    line-height: 1.2;
}

.known-word .placeholder::before {
    content: "\00a0";
}

.known-word .placeholder-bottom {
    visibility: hidden;
    font-size: 0.75em;
    line-height: 1.2;
}

.known-word .placeholder-bottom::before {
    content: "\00a0";
}

.known-word .text {
    border-bottom: 1px dashed #2980b9;
}

.known-word:hover .text {
    border-bottom: 1px solid #1abc9c;
}

/* Unknown word styles */
.unknown-word {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.unknown-word .reading {
    color: #27ae60;
    font-size: 0.7em;
    line-height: 1.2;
}

.unknown-word .target {
    color: #d35400;
    font-weight: bold;
}

.unknown-word .english {
    color: #666;
    font-size: 0.75em;
    line-height: 1.2;
}

/* Popup styles (shared) */
.english-definition {
    text-align: center;
    display: none;
    position: absolute;
    background-color: #f0f0f0;
    padding: 12px;
    border-radius: 6px;
    min-width: 150px;
    max-width: 250px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

.known-word.active .english-definition,
.unknown-word.active .english-definition {
    display: block;
}

.popup-target-word {
    font-size: 1.2em;
    margin-bottom: 6px;
    color: #2980b9;
    font-weight: bold;
}

.popup-pinyin {
    margin-bottom: 6px;
    font-size: 0.95em;
}

.popup-translation {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

/* Action buttons in popups */
.mark-known-btn,
.mark-unknown-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.2s;
}

.mark-known-btn {
    background-color: #27ae60;
    color: white;
}

.mark-known-btn:hover {
    background-color: #219a52;
}

.mark-unknown-btn {
    background-color: #e74c3c;
    color: white;
}

.mark-unknown-btn:hover {
    background-color: #c0392b;
}

/* Translate button */
.translate-btn {
    font-size: 0.8em;
    background: #2980b9;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
    margin-left: 8px;
    align-self: center;
}

.translate-btn:hover {
    background: #1abc9c;
}

/* Translation popup */
.translation-popup {
    display: none;
    position: absolute;
    background-color: #f0f0f0;
    padding: 12px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 100;
    max-width: 350px;
    white-space: normal;
}

.translation-popup.active {
    display: block;
}

.translation-popup .reading {
    color: #27ae60;
    font-weight: 500;
}

/* New vocabulary section */
.new-vocab {
    font-style: italic;
    background-color: #fff8e1;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.new-vocab ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.new-vocab li {
    margin: 10px 0;
    padding-left: 20px;
    position: relative;
}

.new-vocab li::before {
    content: "•";
    color: #f39c12;
    font-size: 1.5em;
    position: absolute;
    left: 0;
    top: -2px;
}

.new-vocab b {
    color: #d35400;
    font-weight: bold;
}

.new-vocab .reading {
    color: #27ae60;
    font-weight: 500;
}

.new-vocab-header {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 10px;
    color: #e67e22;
}

/* Auth forms */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2980b9;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #2980b9;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background-color: #2980b9;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background-color: #2472a4;
}

.auth-links {
    text-align: center;
    margin-top: 20px;
}

.auth-links a {
    color: #2980b9;
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 20px;
}

.flash {
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.flash-error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.flash-success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.flash-info {
    background-color: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

/* Stories list */
.stories-container {
    max-width: 800px;
    margin: 20px auto;
}

.language-section {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.language-section h2 {
    color: #2980b9;
    margin-top: 0;
    margin-bottom: 15px;
    text-transform: capitalize;
}

.story-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.story-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.story-list li:last-child {
    border-bottom: none;
}

.story-list a {
    color: #333;
    text-decoration: none;
    display: block;
}

.story-list a:hover {
    color: #2980b9;
}

/* Chapters list */
.chapters-container {
    max-width: 600px;
    margin: 20px auto;
}

.chapters-header {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chapters-header h1 {
    margin: 0 0 10px 0;
    color: #333;
    text-transform: capitalize;
}

.chapters-header .back-link {
    color: #2980b9;
    text-decoration: none;
}

.chapter-list {
    background-color: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-list li {
    border-bottom: 1px solid #eee;
}

.chapter-list li:last-child {
    border-bottom: none;
}

.chapter-list a {
    display: block;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
}

.chapter-list a:hover {
    background-color: #f5f5f5;
    color: #2980b9;
}

/* Mobile responsive */
@media screen and (max-width: 600px) {
    body {
        margin: 0;
    }

    .paragraph {
        padding: 10px;
        border-radius: 0;
    }

    .new-vocab {
        border-radius: 0;
    }

    .reader-nav {
        border-radius: 0;
        padding: 10px;
    }

    .auth-container {
        margin: 20px;
        padding: 20px;
    }

    .stories-container,
    .chapters-container {
        margin: 10px;
    }

    .language-section,
    .chapters-header,
    .chapter-list {
        border-radius: 0;
    }
}
