.pandorace-app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Language Selector */
.language-selector {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    z-index: 100;
}

.language-selector label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-right: 8px;
}

#languageSelect {
    background: white;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

#languageSelect:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#languageSelect:hover {
    border-color: #667eea;
}

/* Header */
.pandorace-app .feature-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.pandorace-app .feature-header h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Input section */
.input-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.2);
}

.page-input {
    margin-bottom: 20px;
}

.page-input label,
.search-container label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.95rem;
}

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

.page-input div {
    display: flex;
    gap: 10px;
}

#pageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

#pageInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#loadPageBtn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#loadPageBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#loadPageBtn:active {
    transform: translateY(0);
}

.search-container {
    position: relative;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#searchInput {
    width: 100%;
    padding: 12px 50px 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.regex-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-family: monospace;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    z-index: 10;
}

.regex-toggle:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.regex-toggle.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.search-count {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

/* Main content */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 25px;
    flex: 1;
}

.history-section,
.links-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    height: fit-content;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Reserve space for scrollbar to prevent layout shift */
    scrollbar-gutter: stable both-edges;
}

.history-section h3,
.links-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.3rem;
    font-weight: 600;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.link-stats {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 0.9rem;
    color: #666;
}

.open-wiki-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.open-wiki-btn:hover {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.open-wiki-btn:active {
    transform: translateY(0);
}

.history-list,
.links-list {
    overflow-y: scroll; /* Always show vertical scrollbar when needed */
    overflow-x: hidden;
    flex: 1;
    scrollbar-gutter: stable; /* Prevents content jump when scrollbar appears */
    /* Force scrollbar to always be visible space, preventing layout shift */
    scrollbar-width: thin; /* For Firefox */
}

.history-list {
    max-height: 400px;
}

/* History items */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 8px;
    margin-right: 4px; /* Add margin to prevent overlap with scrollbar */
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.history-item:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.history-item.current {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.history-item.current:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.history-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 1.1rem;
    line-height: 1;
}

.history-remove:hover {
    background: rgba(255,255,255,0.2);
    color: #666;
}

.history-item.current .history-remove:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Link items */
.link-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 6px;
    margin-right: 4px; /* Add margin to prevent overlap with scrollbar */
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.link-item:hover {
    background: #e9ecef;
    transform: translateX(3px);
    border-left-color: #667eea;
    text-decoration: none;
    color: #333;
}

.link-item:hover .link-text {
    color: #374151;
    font-weight: 600;
}

.link-item:active {
    transform: translateX(1px);
}

.link-anchor-text {
    color: #888;
    font-size: 0.9em;
    font-style: italic;
    margin-left: 8px;
}

/* Highlighted search results */
.highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Empty states */
.empty-state {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
}

.empty-state .tip {
    font-size: 0.9rem;
    margin-top: 10px;
    color: #888;
}

/* Loading spinner */
.spinner {
    color: #667eea;
    font-weight: 500;
}

.spinner::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #667eea;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error message */
.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff4757;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
    z-index: 1000;
}

.error-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .pandorace-app {
        padding: 15px;
    }
    
    .pandorace-app .feature-header h2 {
        font-size: 2rem;
    }
    
    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .history-section {
        order: 2;
        max-height: 300px;
    }
    
    .links-section {
        order: 1;
        max-height: 60vh;
    }
    
    .page-input div {
        flex-direction: column;
    }
    
    #loadPageBtn {
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .input-section {
        padding: 20px;
    }
    
    .history-section,
    .links-section {
        padding: 20px;
    }
    
    .pandorace-app .feature-header h2 {
        font-size: 1.8rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .open-wiki-btn {
        font-size: 0.8rem;
        padding: 5px 10px;
    }
    
    .language-selector {
        position: relative;
        top: 0;
        left: 0;
        margin-bottom: 15px;
        text-align: center;
    }
    
    .language-selector label {
        display: block;
        margin-bottom: 5px;
    }
    
    #languageSelect {
        width: 100%;
        max-width: 200px;
    }
}

/* Scrollbar styling */
.history-list::-webkit-scrollbar,
.links-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track,
.links-list::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
    margin: 2px;
}

.history-list::-webkit-scrollbar-thumb,
.links-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.history-list::-webkit-scrollbar-thumb:hover,
.links-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Firefox scrollbar styling */
.history-list,
.links-list {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f8f9fa;
}

/* Ensure scrollbar space is always reserved */
.history-list {
    min-height: 200px;
}

.links-list {
    min-height: 300px;
}

/* Preview Modal */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.preview-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    max-height: 80vh;
    width: 90%;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px 15px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.preview-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: #111827;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.preview-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.preview-body {
    display: flex;
    max-height: calc(80vh - 120px);
    overflow: hidden;
}

.preview-image {
    flex-shrink: 0;
    width: 200px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.9rem;
}

.preview-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-image.no-image {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.preview-text {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.preview-extract {
    flex: 1;
    line-height: 1.6;
    color: #374151;
    font-size: 0.95rem;
    margin-bottom: 20px;
    overflow-y: auto;
}

.preview-extract p {
    margin-bottom: 12px;
}

.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.preview-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.preview-btn.primary:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.preview-btn.secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.preview-btn.secondary:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

/* Link text and preview button styling */
.link-text {
    flex: 1;
    margin-right: 10px;
    font-weight: 500;
    color: #111827;
}

.link-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.link-preview-btn,
.link-wiki-btn {
    border: 1px solid #d1d5db;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    font-weight: 400;
    background: #f9fafb;
}

.link-preview-btn {
    color: #6b7280;
}

.link-preview-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.link-wiki-btn {
    color: #6b7280;
}

.link-wiki-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Mobile responsive for preview */
@media (max-width: 768px) {
    .preview-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .preview-body {
        flex-direction: column;
    }
    
    .preview-image {
        width: 100%;
        height: 180px;
    }
    
    .preview-actions {
        flex-direction: column;
    }
    
    .link-preview-btn,
    .link-wiki-btn {
        font-size: 0.7rem;
        padding: 4px 6px;
        gap: 2px;
    }
    
    .link-buttons {
        gap: 3px;
    }
} 