/* Entry Detail Page Styles */

/* Modern Card Styling */
.entry-card {
    background: var(--bg-surface);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-gray-200);
    overflow: hidden;
    margin-bottom: 2rem;
}

.entry-header {
    background: var(--bg-surface);
    color: var(--color-gray-800);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--color-gray-200);
    position: relative;
}

.word-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.word-text {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--color-gray-800);
    font-family: 'Charis SIL', 'Georgia', serif;
    letter-spacing: -0.02em;
}

.transcription-badge,
.romanization-badge {
    background: transparent;
    color: var(--color-gray-500);
    padding: 0;
    border-radius: 0;
    font-size: 1.1rem;
    font-style: normal;
    backdrop-filter: none;
    /* Noto Sans + Charis SIL for IPA / Cyrillic + Latin diacritics */
    font-family: "Noto Sans", "Charis SIL", "Doulos SIL", "Gentium Plus", "DejaVu Sans", serif;
    margin-top: 0.1rem;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.audio-btn {
    background: var(--color-gray-100);
    border: 1px solid var(--color-gray-300);
    color: var(--color-gray-600);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.audio-btn:hover {
    background: var(--color-gray-200);
    color: var(--color-gray-800);
    text-decoration: none;
    border-color: var(--color-gray-400);
}

.entry-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

.meta-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.meta-badge {
    background: var(--color-gray-100);
    color: var(--color-gray-600);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    backdrop-filter: none;
    border: 1px solid var(--color-gray-200);
}

/* Content Sections */
.content-section {
    padding: 2rem;
}

/* Grid Layout System */
.entry-grid-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

.entry-main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 0; /* Prevent grid blowout */
}

.entry-sidebar {
    position: relative;
    min-width: 0;
    min-height: 300px; /* Ensure space is reserved */
    background: var(--color-gray-100);
    border-radius: 12px;
    border: 2px dashed var(--color-gray-200);
    display: flex; /* Fix for sticky child */
    flex-direction: column; 
}

/* Remove background/border if we want it invisible but taking space, 
   but user requested "show that this space ... is for that" */
.entry-sidebar:has(.card) {
    background: transparent;
    border: none;
    min-height: 0;
}

.sidebar-sticky {
    position: sticky;
    top: 2rem; /* Stick 2rem from top of viewport */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 10;
}

/* Section Title Refinement */
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-gray-800);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-family-sans, 'Inter', sans-serif);
    border-bottom: 1px solid var(--color-gray-200);
    padding-bottom: 0.5rem;
}

.translations-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.translation-card {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
}

.translation-title {
    font-weight: 600;
    color: var(--color-info);
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--color-gray-200);
    padding-bottom: 0.5rem;
}

.translation-text {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    line-height: 1.6;
}

.translation-value {
    display: inline-block;
    color: var(--color-gray-800);
    font-size: 1.05rem;
}

.translation-value:not(:last-child)::after {
    content: ",";
    color: var(--color-gray-300);
    margin-right: 4px;
}



/* Grammar Information */
.grammar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.grammar-item {
    background: var(--bg-surface);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    border-left: 3px solid #667eea;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
    border: 1px solid var(--color-gray-200);
    border-left-width: 3px;
}

.grammar-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.grammar-label {
    font-weight: 600;
    color: var(--color-gray-500);
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.grammar-value {
    color: var(--color-gray-800);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Charis SIL', serif;
}

/* Compact Buttons */
.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

.action-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Forms Tables */
.forms-section {
    margin-top: 2rem;
}

.forms-table {
    background: var(--bg-surface);
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-gray-200);
    width: 100% !important;
    max-width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.forms-table .table {
    margin-bottom: 0 !important;
    table-layout: auto !important;
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.forms-table th {
    background: var(--color-primary-500) !important;
    border: 1px solid var(--color-gray-200) !important;
    font-weight: 600;
    color: white;
    padding: 1.2rem 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
    width: 20% !important;
    min-width: 0 !important;
    max-width: 20% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* For non-class-based verbs with only 2 columns */
.forms-table.non-class-based th:first-child {
    width: 33.33% !important;
}

.forms-table.non-class-based th:not(:first-child) {
    width: 33.33% !important;
}

.forms-table.non-class-based td:first-child {
    width: 33.33% !important;
}

.forms-table.non-class-based td:not(:first-child) {
    width: 33.33% !important;
}

.forms-table th:first-child {
    width: 20% !important;
}

.forms-table th:not(:first-child) {
    width: 20% !important;
}

.forms-table td {
    padding: 0.8rem 0.6rem;
    border: 1px solid var(--color-gray-200) !important;
    border-bottom: 1px solid var(--color-gray-200) !important;
    vertical-align: top;
    background: var(--bg-surface);
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 120px;
    box-sizing: border-box !important;
    overflow: visible !important;
    position: relative !important;
}

.forms-table tr:last-child td {
    border-bottom: none !important;
}

/* Ensure consistent table behavior */
.forms-table table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
}

.forms-table table * {
    box-sizing: border-box !important;
}

/* Remove rigid width-based nth-child selectors */

/* Ensure content is visible */
.forms-table .table tbody tr td {
    overflow: visible !important;
    position: relative !important;
    min-height: 60px !important;
    padding: 8px !important;
    vertical-align: top !important;
}

/* Force table borders to be visible */
.forms-table .table,
.forms-table .table th,
.forms-table .table td {
    border: 1px solid #e9ecef !important;
    border-collapse: collapse !important;
}

.forms-table .word-form-row {
    position: relative !important;
}

/* Examples sections should expand naturally below the content */
.forms-table .examples-section {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    margin: 8px 0 !important;
    padding: 12px !important;
    background-color: #f8f9fa !important;
    border-left: 3px solid #007bff !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    box-sizing: border-box !important;
    clear: both !important;
    /* Force visibility */
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
}

/* Ensure example content is visible */
.forms-table .examples-section .example-item {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-bottom: 12px !important;
    padding: 8px !important;
    background: white !important;
    border-radius: 4px !important;
    border: 1px solid #e9ecef !important;
}

.forms-table .examples-section .example-text {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-style: italic !important;
    color: #495057 !important;
    margin-bottom: 4px !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

.forms-table .examples-section .example-number {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #007bff !important;
    color: white !important;
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    text-align: center !important;
    font-size: 12px !important;
    font-weight: bold !important;
    margin-right: 8px !important;
    line-height: 20px !important;
}

.forms-table .examples-section .examples-header {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 8px !important;
    padding-bottom: 4px !important;
    border-bottom: 1px solid #dee2e6 !important;
}

/* When examples section is inserted as a table row, style the wrapper cell */
.forms-table tbody tr td .examples-section {
    width: 100% !important;
    margin: 8px 0 !important;
    padding: 12px !important;
    background-color: #f8f9fa !important;
    border-left: 3px solid #007bff !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    box-sizing: border-box !important;
}

/* Form Badge Styling */
.form-badge-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5em;
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px 12px;
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    background-color: #fafafa;
    border-radius: 8px;
    min-height: 40px;
    overflow: visible !important;
    position: relative !important;
}

.form-badge-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 2.2em;
}

.form-lock-badge {
    font-size: 0.6em;
    padding: 0.05em 0.3em;
    border-radius: 0.5em;
    background-color: #198754;
    color: white;
    display: inline-block;
    white-space: nowrap;
    line-height: 1;
}

.form-text {
    flex: 1 1 auto;
    text-align: left;
    white-space: normal;
    overflow: visible !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-right: 0.5em;
    min-width: 0;
    display: inline-block;
    line-height: 1.4;
}

.attest-success {
    background-color: #198754 !important;
}

.attest-warning {
    background-color: #fd7e14 !important;
}

.attest-secondary {
    background-color: #6c757d !important;
}

/* Feedback Section */
.feedback-section {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.feedback-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    border: 2px solid var(--color-gray-200);
    background: var(--bg-surface);
    color: var(--color-gray-600);
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.feedback-btn:hover {
    background: var(--color-gray-100);
    color: var(--color-gray-600);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.feedback-btn.like {
    border-color: #198754;
    color: #198754;
}

.feedback-btn.like:hover {
    background: #198754;
    color: white;
}

.feedback-btn.flag {
    border-color: #dc3545;
    color: #dc3545;
}

.feedback-btn.flag:hover {
    background: #dc3545;
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .word-text {
        font-size: 2rem;
    }

    .translations-grid {
        grid-template-columns: 1fr;
    }

    .grammar-grid {
        grid-template-columns: 1fr;
    }

    .entry-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

@media (max-width: 991.98px) {
    .entry-grid-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar-sticky {
        position: static;
    }
}

/* POS-specific styling */
.pos-noun {
    border-left-color: #28a745;
}

.pos-verb {
    border-left-color: #dc3545;
}

.pos-adj {
    border-left-color: #ffc107;
}

.pos-pron {
    border-left-color: #17a2b8;
}

.pos-adv {
    border-left-color: #6f42c1;
}

.pos-conj {
    border-left-color: #fd7e14;
}

.pos-post {
    border-left-color: #20c997;
}

.pos-interj {
    border-left-color: #e83e8c;
}

.pos-num {
    border-left-color: #6c757d;
}

.pos-part {
    border-left-color: #495057;
}

.pos-phrase {
    border-left-color: #6610f2;
}

/* Masdar-specific styling */
.masdar-info {
    border-left-color: #8e44ad !important;
    background: linear-gradient(135deg, #f8f4ff 0%, #ffffff 100%) !important;
    border: 1px solid #e1bee7 !important;
}

.masdar-info .grammar-label {
    color: #8e44ad !important;
    font-weight: 700 !important;
}

.masdar-info .grammar-value a {
    color: #8e44ad !important;
    font-weight: 600 !important;
}

.masdar-info .grammar-value a:hover {
    color: #6a1b9a !important;
    text-decoration: underline !important;
}

/* Masdar Nouns Grid */
.masdar-nouns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.masdar-noun-card {
    background: linear-gradient(135deg, #f8f4ff 0%, #ffffff 100%);
    border: 2px solid #e1bee7;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(142, 68, 173, 0.1);
    transition: all 0.3s ease;
}

.masdar-noun-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(142, 68, 173, 0.2);
    border-color: #8e44ad;
}

.masdar-noun-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.masdar-noun-link {
    font-size: 1.3rem;
    font-weight: 700;
    color: #8e44ad;
    text-decoration: none;
    font-family: 'Georgia', serif;
}

.masdar-noun-link:hover {
    color: #6a1b9a;
    text-decoration: underline;
}

.masdar-noun-id {
    font-size: 0.8rem;
    color: #8e44ad;
    background: rgba(142, 68, 173, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 15px;
    font-weight: 500;
}

.masdar-noun-type {
    color: #8e44ad;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.masdar-noun-translations {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.translation-badge {
    background: rgba(142, 68, 173, 0.1);
    color: #8e44ad;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid rgba(142, 68, 173, 0.2);
}

/* Audio Visualizer */
/* .audio-btn { display: none; } */ /* Hide old btn if present elsewhere */

#audio-visualizer .bar { transition: height 0.1s; }
#audio-visualizer.playing .bar {
    animation: bounce 0.5s infinite ease-in-out alternate;
}
#audio-visualizer.playing .bar:nth-child(1) { animation-delay: 0s; }
#audio-visualizer.playing .bar:nth-child(2) { animation-delay: 0.1s; }
#audio-visualizer.playing .bar:nth-child(3) { animation-delay: 0.2s; }
#audio-visualizer.playing .bar:nth-child(4) { animation-delay: 0.3s; }
#audio-visualizer.playing .bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes bounce {
    to { transform: scaleY(1.5); }
}

/* ========================================================================
   MORPHOLOGY COLOR-CODING
   ======================================================================== */

/* Morpheme color scheme for linguistic analysis */
.morpheme-stem {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 1px;
    border: 1px solid #90caf9;
}

.morpheme-suffix {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: #e65100;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 1px;
    border: 1px solid #ffcc80;
}

.morpheme-prefix {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    color: #6a1b9a;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 1px;
    border: 1px solid #ce93d8;
}

.morpheme-infix {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2e7d32;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 1px;
    border: 1px solid #a5d6a7;
}

.morpheme-epenthetic {
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 100%);
    color: #c2185b;
    font-weight: 500;
    font-style: italic;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 1px;
    border: 1px solid #f48fb1;
}

/* ========================================================================
   EMPTY FIELD STYLING
   ======================================================================== */

/* Style for grammar items with missing data */
.grammar-item.empty-field {
    opacity: 0.7;
    background: var(--color-gray-100);
}

.grammar-item.empty-field .grammar-value {
    color: var(--color-gray-500);
    font-style: italic;
    background: var(--color-gray-100);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px dashed var(--color-gray-300);
}

.grammar-item.empty-field .grammar-value::before {
    content: "—";
    margin-right: 4px;
    color: var(--color-gray-300);
}

/* Hover effect for empty fields to indicate they're editable */
.grammar-item.empty-field:hover {
    opacity: 1;
    background: var(--bg-surface);
    cursor: help;
}

.grammar-item.empty-field:hover .grammar-value {
    border-color: var(--color-gray-400);
    background: var(--bg-surface);
}

/* ========================================================================
   Dark mode: nested Bootstrap cards + form tables (after global search.css scope fix)
   ======================================================================== */
[data-theme="dark"] .entry-card .card {
    background-color: var(--bg-surface);
    border-color: #3f3f46;
}

[data-theme="dark"] .entry-card .card .text-muted {
    color: var(--color-gray-500) !important;
}

[data-theme="dark"] .forms-table td,
[data-theme="dark"] .forms-table .table td {
    background: var(--bg-surface) !important;
    color: var(--color-gray-800) !important;
    border-color: #3f3f46 !important;
}

[data-theme="dark"] .forms-table .table,
[data-theme="dark"] .forms-table .table th,
[data-theme="dark"] .forms-table .table td {
    border-color: #3f3f46 !important;
}

[data-theme="dark"] .forms-table .examples-section {
    background-color: var(--color-gray-100) !important;
}

[data-theme="dark"] .forms-table .examples-section .example-item {
    background: var(--bg-surface) !important;
    border-color: #3f3f46 !important;
}

[data-theme="dark"] .forms-table .examples-section .example-text {
    color: var(--color-gray-800) !important;
}

.generated-form-mark {
    font-size: 0.65rem;
    margin-left: 0.25rem;
    white-space: nowrap;
    vertical-align: middle;
}

/* In-page navigation (long entry pages) */
.entry-page-nav__list {
    background: var(--color-gray-50, #f8f9fa);
    border: 1px solid var(--color-gray-200, #e9ecef);
    border-radius: 0.75rem;
    padding: 0.35rem 0.5rem;
}

.entry-page-nav .nav-link {
    color: var(--color-gray-700, #495057);
}

.entry-page-nav .nav-link:hover,
.entry-page-nav .nav-link:focus-visible {
    background: var(--color-primary-100, #e7f1ff);
    color: var(--color-primary-700, #0d47a1);
}

.entry-anchor-target {
    scroll-margin-top: 5.5rem;
}

[data-theme="dark"] .entry-page-nav__list {
    background: var(--color-gray-100, #18181b);
    border-color: #3f3f46;
}

[data-theme="dark"] .entry-page-nav .nav-link {
    color: var(--color-gray-300, #d4d4d8);
}

/* Mobile Bottom Bar for Actions (UX-10) */
@media (max-width: 767.98px) {
    .entry-actions-mobile-bottom {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-surface);
        padding: 0.75rem 1rem;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
        z-index: 1040;
        justify-content: space-evenly !important;
        border-top: 1px solid var(--color-gray-200);
        margin: 0 !important;
        flex-wrap: nowrap !important;
    }
    
    .entry-actions-mobile-bottom .btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border: none;
        background: transparent;
        border-radius: 8px;
        gap: 0.25rem;
        padding: 0.5rem;
        color: var(--color-gray-700);
        height: auto;
        width: auto;
    }
    
    .entry-actions-mobile-bottom .btn i {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }
    
    .entry-actions-mobile-bottom .btn:hover,
    .entry-actions-mobile-bottom .btn:active {
        background: var(--color-gray-100);
        color: var(--color-primary-700);
    }
    
    [data-theme="dark"] .entry-actions-mobile-bottom {
        box-shadow: 0 -4px 12px rgba(0,0,0,0.5);
    }
    
    /* Ensure body has padding so content isn't hidden behind the bar */
    body {
        padding-bottom: 80px;
    }
}