/* ═══════════════════════════════════════════════════════════════════════════════
   Context Learn Page Styles
   Learn words in context with AI-powered analysis
   ═══════════════════════════════════════════════════════════════════════════════ */

.app-layout {
    min-height: 100vh;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.context-learn-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10vh 2vw !important;
    /* 5% (10vh) padding on top and bottom */
    max-width: 100% !important;
    /* Stretch from left edge of content */
    width: 100% !important;
    margin: 0;
    font-family: 'Goldman', 'Inter', -apple-system, sans-serif;
    color: var(--text-primary);
    box-sizing: border-box;
}

.context-learn-screen.hidden {
    display: none;
}

.context-learn-layout {
    display: grid;
    grid-template-columns: 6.5fr 3.5fr;
    /* 65% width for input/left, 35% for definition/right */
    gap: 24px;
    width: 100%;
    align-items: start;
}

.context-learn-top {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Mode Switcher - Standalone (Outside input wrapper) */
.mode-switcher-standalone {
    position: sticky;
    top: 0;
    z-index: 50;
    margin-bottom: 0;
    margin-top: -44px;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    background: var(--bg-primary);
    padding: 12px 0;
}

.mode-switcher-standalone.hidden {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: 44px !important;
    overflow: visible !important;
}

/* Form Styles - FIXED CONTAINER */
.sentence-form-styled {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    border: none;
    border-radius: clamp(12px, 1.5vw, 20px);
    padding: 0;
    box-shadow: none;
    height: auto;
    flex-shrink: 0;
}

.sentence-form-styled.hidden {
    display: none;
}

/* Beautiful Spacious Input Wrapper - FIXED HEIGHT, NO RESIZE */
.sentence-input-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    height: 60vh;
    overflow: hidden;
    flex-shrink: 0;
}

.sentence-input-wrapper:focus-within {
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Large and Spacious Textarea - RESPONSIVE SIZE */
.sentence-input-wrapper textarea {
    width: 100%;
    height: calc(60vh - 32px);
    background: transparent;
    border: none;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-primary);
    outline: none;
    resize: none;
    font-family: 'Goldman', 'Inter', sans-serif;
    overflow-y: auto;
}

.sentence-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

/* Actions Row */
.form-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.language-picker-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lang-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.language-picker-inline select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.language-picker-inline select:hover {
    border-color: var(--accent-primary, #6366f1);
}

/* Submit Button */
.submit-btn.styled-submit {
    padding: 10px 24px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.submit-btn.styled-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Sentence Display - FIXED HEIGHT CONTAINER */
.sentence-display {
    min-height: 220px;
    display: flex;
    flex-direction: column;
}

.sentence-display.hidden {
    display: none;
}

/* Sentence Display Card */
.sentence-card {
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    position: relative;
    box-shadow: none;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sentence-tokens {
    font-size: 1.35rem;
    line-height: 1.8;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-top: 12px;
}

.edit-sentence-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.edit-sentence-btn:hover {
    border-color: var(--accent-primary, #6366f1);
    color: var(--text-primary);
}

.selection-toggle-container {
    display: inline-flex;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: var(--radius-sm);
    gap: 4px;
    margin-bottom: 12px;
}

.selection-mode-btn {
    background: transparent;
    border: none;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.selection-mode-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Word Tokens */
.word-token {
    display: inline-block;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.word-token:hover {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.word-token.highlighted {
    color: #6366f1;
    font-weight: 700;
    background: rgba(99, 102, 241, 0.15);
    border-bottom: 2px solid #6366f1;
}

/* Bottom Split Layout */
.context-learn-bottom {
    width: 100%;
}

.vocab-card-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.definition-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: clamp(12px, 1.5vw, 20px);
    color: var(--text-muted);
    text-align: center;
}

.placeholder-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
}

/* Definition Panel */
.definition-panel {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: clamp(12px, 1.5vw, 20px);
    padding: clamp(16px, 2vw, 28px);
    box-shadow: none;
    display: flex;
    flex-direction: column;
}

.definition-panel.hidden {
    display: none;
}

/* Panel Styling */
.panel-header-row {
    margin-bottom: 12px;
}

.phrase-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 4px;
}

.phrase-badge.phrasal-verb {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.phrase-badge.idiom {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.phrase-badge.collocation {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.phrase-badge.single-word {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.phrase-badge.compound {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.phrase-badge.expression {
    background: rgba(236, 72, 153, 0.15);
    color: #f472b6;
}

.panel-phrase h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 8px 0 4px;
}

.phrase-translation {
    font-size: 1.1rem;
    font-weight: 600;
    color: #6366f1;
}

.panel-divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

.panel-section {
    margin-bottom: 16px;
}

.section-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.section-content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.examples-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.examples-list li {
    font-size: 0.95rem;
    line-height: 1.5;
    padding-left: 12px;
    border-left: 3px solid #6366f1;
}

.panel-footer {
    margin-top: 16px;
}

.panel-footer.hidden {
    display: none;
}

.save-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.save-btn:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.save-btn.saved {
    background: #10b981;
}

/* Notebook Panel */
.vocab-notebook {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.vocab-notebook.hidden {
    display: none;
}

.notebook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.notebook-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}

.close-notebook-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.vocab-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.vocab-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    position: relative;
}

.vocab-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vocab-phrase {
    font-weight: 700;
    font-size: 1rem;
}

.vocab-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

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

.vocab-translation {
    font-size: 0.9rem;
    font-weight: 600;
    color: #6366f1;
    margin-top: 4px;
}

.vocab-meaning {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

.vocab-sentence {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 6px;
    line-height: 1.3;
}

.vocab-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}

/* Notebook toggle button */
.notebook-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 90;
}

.notebook-toggle:hover {
    border-color: var(--accent-primary, #6366f1);
}

.notebook-toggle .vocab-count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--accent-gradient);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.notebook-toggle .vocab-count.hidden {
    display: none;
}

/* Skeleton Loaders */
.definition-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-line {
    height: 14px;
    background: var(--bg-primary);
    border-radius: 4px;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

@media (max-width: 900px) {
    .context-learn-layout {
        grid-template-columns: 1fr;
    }
}

/* ── Segmented Picker Component from myspace.html ── */
.ms-view-switcher {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 8px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, opacity 0.18s;
    font-family: inherit;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-sizing: border-box;
    width: auto;
    margin: 0;
    user-select: none;
    position: relative;
}

.menu__item {
    all: unset;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    color: var(--text-muted);
    border-radius: 8px;
}

.menu__item.active {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.menu__icon {
    font-size: 16px;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu__icon i {
    font-size: 16px;
}

.menu__item.active .menu__icon {
    animation: iconBounce 0.6s ease-out;
}

.menu__text {
    font-size: 14px;
    font-weight: 800;
    text-transform: capitalize;
    letter-spacing: -0.2px;
    transition: all 0.3s ease;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    20% { transform: translateY(-0.25em); }
    40% { transform: translateY(0); }
    60% { transform: translateY(-0.1em); }
    80% { transform: translateY(0); }
}

/* Responsive Styles */
@media (max-width: 768px) {
    .context-learn-layout {
        grid-template-columns: 1fr;
    }

    .vocab-notebook {
        width: 100%;
    }

    .sentence-input-wrapper {
        height: 50vh;
        flex-shrink: 0;
    }

    .sentence-input-wrapper textarea {
        height: calc(50vh - 32px);
        resize: none;
    }
}
