/**
 * Activity Renderer Styles
 *
 * Styles for unified activity display (stories, grammar lessons, etc.)
 * Consistent with existing satzklar design
 */

/* Container and Layout */
.activity-container {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333 !important;  /* Force dark text color throughout */
}

/* Ensure all text elements are dark */
.activity-container * {
    color: inherit;  /* Inherit the dark color */
}

/* Exception: Character picker buttons should keep their blue color */
.activity-container .char-picker-trigger {
    color: #2196f3 !important;
}

.activity-container .char-picker-trigger:hover {
    color: white !important;
}

.activity-container p,
.activity-container div,
.activity-container span,
.activity-container li {
    color: #333;  /* Fallback to ensure readability */
}

.activity-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.activity-title {
    font-size: 26px;
    font-weight: 700;
    color: #1a1a1a !important; /* Force dark text for readability */
    margin: 0;
}

/* Ensure all headings in activities have dark text */
#storyText h1,
#storyText h2,
#storyText h3 {
    color: #1a1a1a !important;
}

/* Metadata */
.activity-metadata {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

.activity-metadata span {
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 4px;
}

.metadata-level {
    background: #e3f2fd;
    color: #1565c0;
}

.metadata-time {
    background: #f3e5f5;
    color: #7b1fa2;
}

.metadata-focus {
    background: #e8f5e9;
    color: #388e3c;
}

/* Sections */
.activity-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.activity-section {
    padding: 15px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

/* Text Sections */
.text-section {
    line-height: 1.6;
    color: #333 !important;  /* Force dark text color */
    padding: 15px;
}

.text-section p {
    color: #333 !important;  /* Ensure paragraphs are dark */
}

.text-section.normal {
    background: transparent;
    border: none;
    padding: 0;
}

.text-section.emphasis {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    padding-left: 20px;
}

.text-section.note {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding-left: 20px;
    font-style: italic;
}

.text-section.warning {
    background: #ffebee;
    border-left: 4px solid #f44336;
    padding-left: 20px;
}

/* Example Sections */
.example-section {
    background: white;
    padding: 20px;
    border: 1px solid #ddd;
}

.example-text {
    font-size: 18px;
    line-height: 1.8;
    color: #333;
    margin-bottom: 10px;
}

.example-text .highlight {
    padding: 2px 4px;
    border-radius: 3px;
    cursor: help;
    position: relative;
}

.highlight-modal-verb {
    background: #e3f2fd;
    color: #1565c0;
    border-bottom: 2px solid #1565c0;
}

.highlight-infinitive {
    background: #f3e5f5;
    color: #7b1fa2;
    border-bottom: 2px solid #7b1fa2;
}

.highlight-subject {
    background: #e8f5e9;
    color: #388e3c;
    border-bottom: 2px solid #388e3c;
}

.highlight-object {
    background: #fff3e0;
    color: #ff9800;
    border-bottom: 2px solid #ff9800;
}

.highlight-grammar {
    background: #e8eaf6;
    color: #5e35b1;
    border-bottom: 2px solid #5e35b1;
    font-weight: 600;
}

.example-translation {
    font-size: 14px;
    color: #666;
    font-style: italic;
    padding: 10px;
    background: #f5f5f5;
    border-left: 3px solid #ccc;
    margin: 10px 0;
}

.example-note {
    font-size: 14px;
    color: #555;
    padding: 10px;
    background: #fffbf0;
    border: 1px solid #ffc107;
    border-radius: 4px;
    margin-top: 10px;
}

/* Exercise Sections */
.exercise-section {
    background: white;
    padding: 20px;
}

.exercise-instruction {
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    font-size: 16px;
}

.exercise-context {
    font-style: italic;
    color: #666;
    padding: 10px;
    background: #f9f9f9;
    border-left: 3px solid #2196f3;
    margin-bottom: 15px;
}

.exercise-template {
    font-size: 18px;
    line-height: 1.8;
    margin-bottom: 15px;
}

/* Multiple Choice */
.exercise-options.multiple-choice {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #ffffff !important;
    color: #333 !important;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.option-label:hover {
    background: #f0f8ff !important;
    border-color: #2196f3;
}

.option-label input[type="radio"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0; /* Prevent radio button from shrinking */
    /* Ensure radio button is visible */
    opacity: 1;
    position: relative;
    appearance: auto; /* Use browser's default radio style */
}

.option-text {
    color: #333 !important;  /* Force dark text color */
    font-size: 16px;
    line-height: 1.4;
    flex: 1; /* Take up remaining space */
}

.option-label.correct-answer {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #1b5e20;
}

.option-label:has(input:checked) {
    background: #e3f2fd !important;
    border-color: #1565c0 !important;
}

/* Fallback for browsers that don't support :has() */
.option-label input[type="radio"]:checked + .option-text {
    font-weight: 600;
}

.option-label.incorrect-selected {
    background: #ffebee;
    border-color: #f44336;
    color: #c62828;
}

/* Fill in the Blank */
.blank-input {
    display: inline-block;
    width: 150px;
    padding: 4px 8px;
    border: 2px solid #1565c0;
    border-radius: 4px;
    font-size: 16px;
    margin: 0 5px;
}

.blank-input:focus {
    outline: none;
    border-color: #0d47a1;
    background: #e3f2fd;
}

.exercise-check-button {
    padding: 10px 20px;
    background: #1565c0;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.exercise-check-button:hover {
    background: #0d47a1;
}

/* Exercise Feedback */
.exercise-feedback {
    padding: 15px;
    border-radius: 4px;
    margin-top: 15px;
    font-size: 14px;
}

.exercise-feedback.correct {
    background: #c8e6c9;
    color: #1b5e20;
    border: 1px solid #4caf50;
}

.exercise-feedback.incorrect {
    background: #ffcdd2;
    color: #b71c1c;
    border: 1px solid #f44336;
}

.exercise-feedback.partial {
    background: #fff9c4;
    color: #f57f17;
    border: 1px solid #fbc02d;
}

/* Highlight Sections */
.highlight-section {
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    color: #333;  /* Ensure text is dark */
}

.highlight-tip {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    color: #333;
}

.highlight-warning {
    background: #ffebee;
    border-left: 4px solid #f44336;
    color: #333;
}

.highlight-rule {
    background: #f3e5f5;
    border-left: 4px solid #9c27b0;
    color: #333;
}

.highlight-culture-note {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    color: #333;
}

.highlight-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    text-transform: uppercase;
    color: #444;  /* Darker title text */
}

.highlight-text {
    line-height: 1.5;
    color: #333;  /* Ensure text is readable */
}

/* Error Correction Exercises */
.incorrect-sentence {
    padding: 12px;
    background: #ffebee;
    border-left: 4px solid #f44336;
    border-radius: 4px;
    margin: 15px 0;
    font-size: 16px;
    color: #c62828;
}

.correction-input-container,
.transform-input-container {
    margin: 15px 0;
}

.correction-label,
.transform-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.correction-input,
.transform-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.2s;
}

.correction-input:focus,
.transform-input:focus {
    outline: none;
    border-color: #1565c0;
    background: #f5f9ff;
}

.exercise-hint {
    padding: 10px;
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    color: #e65100;
}

/* Transformation Exercises */
.original-sentence {
    padding: 12px;
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 4px;
    margin: 15px 0;
    font-size: 16px;
    color: #0d47a1;
}

.transformation-type {
    padding: 12px;
    background: #f3e5f5;
    border-left: 4px solid #9c27b0;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    color: #4a148c;
}

.exercise-example {
    padding: 10px;
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
    color: #1b5e20;
}

/* Media Sections */
.media-section {
    text-align: center;
    padding: 20px;
}

.media-section img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.media-section audio {
    width: 100%;
    max-width: 400px;
}

.media-caption {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Activity Type Specific */
.activity-story .activity-sections {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.activity-grammar .example-section {
    background: #f8f9fa;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .activity-container {
        padding: 15px;
    }

    .activity-title {
        font-size: 20px;
    }

    .activity-metadata {
        flex-wrap: wrap;
        gap: 8px;
    }

    .example-text {
        font-size: 16px;
    }

    .blank-input {
        width: 100px;
    }

    .option-label {
        padding: 10px;
        font-size: 14px;
    }
}

/* Main App Lesson Form - Inline form in Activities tab */
.main-app-lesson-form {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 0;
    margin: 20px auto 0 auto;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 600px;
    width: 100%;
}

.main-app-lesson-form .form-header {
    background: #fff;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 12px 12px 0 0;
}

.main-app-lesson-form .form-header h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.4rem;
}

.main-app-lesson-form .form-header p {
    margin: 0;
    color: #666;
    font-size: 0.95rem;
}

.main-app-lesson-form .lesson-form {
    padding: 25px;
}

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

.main-app-lesson-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.main-app-lesson-form .required {
    color: #e74c3c;
}

.main-app-lesson-form input[type="text"],
.main-app-lesson-form select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    background: #fff;
    color: #333;
    box-sizing: border-box;
}

.main-app-lesson-form input[type="text"]:focus,
.main-app-lesson-form select:focus {
    outline: none;
    border-color: #1565c0;
}

.main-app-lesson-form input[type="text"][readonly] {
    background: #f8f9fa;
    color: #495057;
    border-color: #dee2e6;
    cursor: default;
}

.main-app-lesson-form input[type="text"][readonly]:focus {
    border-color: #dee2e6;
    box-shadow: none;
}

.main-app-lesson-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.main-app-lesson-form .help-text {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

/* Exercise type checkboxes */
.main-app-lesson-form .exercise-types-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.main-app-lesson-form .checkbox-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.main-app-lesson-form .checkbox-option:hover {
    background: #e9ecef;
    border-color: #1565c0;
}

.main-app-lesson-form .checkbox-option input[type="checkbox"] {
    margin-right: 8px;
}

.main-app-lesson-form .checkbox-option .checkbox-label {
    font-size: 0.85rem;
    color: #333;
    user-select: none;
}

.main-app-lesson-form .checkbox-option:has(input:checked) {
    background: #e3f2fd;
    border-color: #1565c0;
}

.main-app-lesson-form .optional {
    font-size: 0.8rem;
    color: #999;
    font-weight: normal;
}

.main-app-lesson-form .difficulty-selector,
.main-app-lesson-form .length-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.main-app-lesson-form .difficulty-option,
.main-app-lesson-form .length-option {
    position: relative;
}

.main-app-lesson-form .difficulty-option input[type="radio"],
.main-app-lesson-form .length-option input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.main-app-lesson-form .difficulty-option label,
.main-app-lesson-form .length-option label {
    display: block;
    padding: 10px 8px;
    text-align: center;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 0;
    font-size: 0.85rem;
}

.main-app-lesson-form .difficulty-option input[type="radio"]:checked + label,
.main-app-lesson-form .length-option input[type="radio"]:checked + label {
    background: #1565c0;
    color: white;
    border-color: #1565c0;
}

.main-app-lesson-form .difficulty-option label:hover,
.main-app-lesson-form .length-option label:hover {
    border-color: #1565c0;
    background: #f5f5f5;
}

.main-app-lesson-form .difficulty-option input[type="radio"]:checked + label:hover,
.main-app-lesson-form .length-option input[type="radio"]:checked + label:hover {
    background: #0d47a1;
}

.main-app-lesson-form .difficulty-label {
    font-weight: bold;
    font-size: 0.8em;
    display: block;
}

.main-app-lesson-form .difficulty-desc {
    font-size: 0.7em;
    opacity: 0.8;
    margin-top: 2px;
    display: block;
}

.main-app-lesson-form .form-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.main-app-lesson-form .generate-btn {
    background: #1565c0;
    color: white;
    border: none;
    padding: 10px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.main-app-lesson-form .generate-btn:hover {
    background: #0d47a1;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.3);
}

.main-app-lesson-form .generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.main-app-lesson-form .cancel-btn {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e0e0e0;
    padding: 8px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.main-app-lesson-form .cancel-btn:hover {
    border-color: #999;
    background: #e9ecef;
    color: #333;
}

.lesson-loading {
    text-align: center;
    padding: 40px;
}

.lesson-loading p {
    margin-top: 15px;
    color: #333;
}

.loading-subtitle {
    font-size: 0.9em;
    color: #666;
    margin-top: 10px;
}

.main-lesson-result {
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Responsive adjustments for lesson form */
@media (max-width: 768px) {
    .main-app-lesson-form .form-row {
        grid-template-columns: 1fr;
    }

    .main-app-lesson-form .difficulty-selector,
    .main-app-lesson-form .length-selector {
        grid-template-columns: 1fr;
    }

    .main-app-lesson-form .exercise-types-container {
        grid-template-columns: 1fr;
    }

    .main-app-lesson-form .form-actions {
        flex-direction: column;
    }

    .main-app-lesson-form .generate-btn,
    .main-app-lesson-form .cancel-btn {
        width: 100%;
    }
}

/* Word Order Exercise Styles */
.word-order-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    min-height: 60px;
    border: 2px dashed #dee2e6;
}

.word-chip {
    padding: 8px 16px;
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    cursor: move;
    transition: all 0.3s;
    font-size: 16px;
    font-weight: 500;
    user-select: none;
}

.word-chip.draggable:hover {
    border-color: #1565c0;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.word-chip.dragging {
    opacity: 0.5;
}

.word-chip.selected {
    background: #1565c0;
    color: white;
    border-color: #1565c0;
}

.word-order-text-input {
    margin-top: 20px;
}

.word-order-text-input label {
    display: block;
    margin-bottom: 8px;
    color: #666;
    font-size: 14px;
}

.word-order-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 16px;
}

.word-order-input:focus {
    outline: none;
    border-color: #1565c0;
}

/* Matching Exercise Styles */
.matching-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.matching-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.matching-column h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.matching-item {
    padding: 12px 16px;
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.matching-item:hover {
    border-color: #1565c0;
    transform: translateX(4px);
}

.matching-item.selected {
    background: #e3f2fd;
    border-color: #1565c0;
}

.matching-item.matched {
    background: #e8f5e9;
    border-color: #4caf50;
    cursor: default;
}

.matching-item.incorrect {
    background: #ffebee;
    border-color: #f44336;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.matching-line {
    position: absolute;
    background: #4caf50;
    height: 2px;
    pointer-events: none;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .activity-container {
        color: #e0e0e0;
    }

    .activity-header {
        border-bottom-color: #444;
    }

    .activity-title {
        color: #e0e0e0;
    }

    .activity-section {
        background: #2a2a2a;
        border-color: #444;
    }

    .text-section {
        color: #e0e0e0;
    }

    .example-section {
        background: #1e1e1e;
        border-color: #444;
    }

    .example-text {
        color: #e0e0e0;
    }

    .option-label {
        background: #2a2a2a;
        color: #e0e0e0;
    }

    .option-label:hover {
        background: #3a3a3a;
    }
}

/* No Activities Message */
.no-activities {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px;
}

.no-activities::before {
    content: "📚";
    display: block;
    font-size: 48px;
    margin-bottom: 16px;
}

/* Activity Title Container with Link and Copy Button */
.activity-title-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.activity-title-link {
    color: #1565c0;
    text-decoration: none;
    font-size: 26px;
    font-weight: 700;
    transition: color 0.2s;
}

.activity-title-link:hover {
    color: #0d47a1;
    text-decoration: underline;
}

.copy-lesson-link-btn {
    background: transparent;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-lesson-link-btn:hover {
    background: #e3f2fd;
    border-color: #1565c0;
    transform: scale(1.1);
}

.copy-lesson-link-btn:active {
    transform: scale(0.95);
}