/* Language Modal Styles */
.language-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.language-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.language-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.language-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s ease;
    z-index: 10;
}

.language-modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

.language-modal-header {
    padding: 24px 24px 16px;
    text-align: center;
    border-bottom: 1px solid #eee;
}

.language-modal-header i {
    font-size: 36px;
    color: #ba8666;
    margin-bottom: 8px;
}

.language-modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
    font-weight: 600;
}

.language-modal-content {
    padding: 16px;
    max-height: calc(90vh - 160px);
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

@media (min-width: 768px) {
    .language-modal-content {
        grid-template-columns: repeat(4, 1fr);
    }
}

.language-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #444;
}

.language-option:hover {
    border-color: #ba8666;
}

.language-option.active {
    border-color: #ba8666;
    background: linear-gradient(135deg, #fff8f4, #fff);
    color: #ba8666;
    font-weight: 600;
}

.language-option .fa-check {
    color: #ba8666;
    font-size: 14px;
}

.language-modal-hint {
    padding: 12px 24px 16px;
    margin: 0;
    text-align: center;
    font-size: 12px;
    color: #999;
    border-top: 1px solid #eee;
}

@media (max-width: 600px) {
    .language-modal-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .language-modal-content {
        grid-template-columns: 1fr;
    }
    
    .language-modal {
        width: 95%;
        max-height: 85vh;
    }
}

/* Translation Loading Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.15); }
}

@keyframes loading {
    0% { width: 0%; margin-left: 0%; }
    50% { width: 60%; margin-left: 20%; }
    100% { width: 0%; margin-left: 100%; }
}

/* Toggle Buttons Container */
#toggleButtonsContainer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

#toggleButtonsContainer > div {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    padding: 6px 12px;
    color: #ba8666;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

#toggleButtonsContainer > div:hover {
    background: #f4ebe5;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

#toggleButtonsContainer i {
    color: #ba8666;
    font-size: 14px;
}

/* Footnote Styles */
.notes-empty {
    margin: 0;
    font-size: 14px;
    color: #666;
}

#notes-pane {
    font-size: 13px;
    color: #333;
    line-height: 1.4;
}

#notes-pane .note-location {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

#notes-pane .notes-table {
    width: 100%;
    border-collapse: collapse;
}

#notes-pane .notes-table td:first-child {
    width: 40px;
    vertical-align: top;
    padding-top: 8px;
}

#notes-pane .notes-table td:last-child {
    padding: 8px 0;
}

#notes-pane .notes-table .footnote-excerpt {
    max-height: 4.2em;
    overflow: hidden;
    position: relative;
    line-height: 1.4;
}

#notes-pane .notes-table .footnote-excerpt::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.4em;
    background: linear-gradient(transparent, #fff);
    pointer-events: none;
}

#notes-pane .notes-table .footnote-excerpt.short::after {
    display: none;
}

#notes-pane .notes-table .read-more-hint {
    font-size: 11px;
    color: #b78550;
    margin-top: 4px;
    font-style: italic;
}

a[href*="footnote="] {
    color: #b78550;
    text-decoration: none;
    cursor: pointer;
}

a[href*="footnote="] sup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    font-style: normal;
    color: #a26b24;
    background: #e8e8e8;
    padding: 1px 4px;
    border-radius: 3px;
    margin: 0 1px;
    vertical-align: super;
    position: relative;
    top: -4px;
    min-width: 14px;
    text-align: center;
    transition: all 0.2s ease;
    line-height: 1.2;
}

a[href*="footnote="]:hover sup {
    background: #d0d0d0;
    color: #333;
}

/* Footnote Popup */
.footnote-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.footnote-popup-overlay.active {
    display: block;
    opacity: 1;
}

.footnote-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 0;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.footnote-popup.active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.footnote-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #b78550, #d4a574);
    color: #fff;
}

.footnote-popup-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.footnote-popup-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    transition: background 0.2s ease;
}

.footnote-popup-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.footnote-popup-content {
    padding: 20px;
    font-size: 16px;
    line-height: 1.7;
    color: #333;
    overflow-y: auto;
    max-height: calc(80vh - 100px);
}

.footnote-popup-hint {
    padding: 10px 20px;
    background: #f8f8f8;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #999;
    text-align: center;
}

/* Footnote Zoom */
.footnote-zoom-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.footnote-zoom-overlay.active {
    display: block;
    opacity: 1;
}

.footnote-zoom-container {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    padding: 24px 28px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 9999;
    font-size: 18px;
    line-height: 1.7;
    color: #333;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.footnote-zoom-container.active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.footnote-zoom-container .zoom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #b78550;
}

.footnote-zoom-container .zoom-location {
    font-size: 14px;
    font-weight: 600;
    color: #b78550;
}

.footnote-zoom-container .zoom-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #666;
    transition: all 0.2s ease;
}

.footnote-zoom-container .zoom-close:hover {
    background: #e0e0e0;
    color: #333;
}

.footnote-zoom-container .zoom-hint {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #999;
    text-align: center;
}

#notes-pane .notes-table tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
}

#notes-pane .notes-table tr:hover {
    background-color: #f8f4f0;
}

/* Mobile Styles */
@media (max-width: 768px) {
    #toggleButtonsContainer {
        justify-content: center !important;
        gap: 5px;
    }
    
    #toggleButtonsContainer > div {
        font-size: 12px !important;
        padding: 4px 6px !important;
    }

    .footnote-popup {
        width: 94%;
        max-height: 85vh;
    }
    
    .footnote-popup-content {
        font-size: 15px;
        max-height: calc(85vh - 100px);
    }
    
    .footnote-popup-hint {
        display: none;
    }

    .footnote-zoom-container {
        width: 92vw;
        padding: 20px;
        max-width: 95vw;
        max-height: 85vh;
        font-size: 17px;
    }

    #notes-pane .notes-table tr::after {
        display: none;
    }
}
