/* Custom styles for Folklore Texts Archive */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
}

/* ============================================
   BASE STYLES
   ============================================ */

/* Typography */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-size: 1.3rem;
    font-weight: 700;
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */

/* Filter sidebar */
.filter-sidebar {
    position: sticky;
    top: 20px;
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 80px;  /* Увеличено чтобы кнопка "Добавить текст" помещалась */
}

.filter-sidebar .form-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

/* Text preview */
.text-preview {
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer */
footer {
    margin-top: 50px;
    padding: 20px 0;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* ============================================
   TEXT DISPLAY
   ============================================ */

/* Mongolian text specific styles */
.text-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 17px;
    line-height: 1.9;
    white-space: pre-wrap;
}

/* Parallel view */
.parallel-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.parallel-view .text-column {
    height: 70vh;
    overflow-y: auto;
    padding: 25px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background-color: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    scroll-behavior: smooth;
}

.parallel-view .text-column h4 {
    position: sticky;
    top: 0;
    background-color: #ffffff;
    padding: 15px 0;
    border-bottom: 3px solid var(--primary-color);
    margin-bottom: 20px;
    z-index: 10;
    font-size: 1.2rem;
}

/* ============================================
   BADGES AND TAGS
   ============================================ */

/* Metadata badges */
.metadata-badge {
    font-size: 0.9rem;
    padding: 0.4em 0.8em;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
}

/* Informant photo */
.informant-photo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.informant-photo-large {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    border: 3px solid #dee2e6;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.informant-photo-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid #dee2e6;
}

/* Tag badges */
.tag-badge {
    font-size: 0.85rem;
    padding: 0.3em 0.7em;
    margin: 3px;
    font-weight: 500;
}

/* Fragment cards */
.fragment-card {
    border-left: 4px solid #dee2e6;
    transition: all 0.3s ease;
}

.fragment-card:hover {
    border-left-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.fragment-preview {
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9rem;
}

.fragment-card .card-body {
    padding: 1.25rem;
}

.fragment-card h5 {
    color: var(--primary-color);
    font-weight: 600;
}

/* Fragment status colors */
.fragment-card[data-status="draft"] {
    border-left-color: #6c757d;
}

.fragment-card[data-status="marked"] {
    border-left-color: #0d6efd;
}

.fragment-card[data-status="verified"] {
    border-left-color: #198754;
}

/* Fragment search results */
.fragment-search-result {
    border-left: 4px solid #0d6efd;
    transition: all 0.3s ease;
}

.fragment-search-result:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.fragment-search-result .card-title a {
    color: var(--primary-color);
}

.fragment-search-result .card-title a:hover {
    color: #0a58ca;
}

/* Tag filters in two columns */
.tags-filter-container {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background-color: white;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    column-gap: 20px;
    margin-bottom: 10px;
}

.tags-filter-container .form-check {
    padding: 3px 0;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tags-filter-container .form-check-input {
    flex-shrink: 0;
    margin-top: 0;
    margin-left: 0;
}

.tags-filter-container .form-check-label {
    font-size: 0.9rem;
    cursor: pointer;
    word-wrap: break-word;
    flex: 1;
    margin-bottom: 0;
}

/* ============================================
   AUDIO PLAYER
   ============================================ */

.audio-player {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    padding: 15px;
    margin: 12px 0;
}

.audio-player .btn-outline-primary {
    background-color: white;
    color: #667eea;
    border: none;
}

.audio-player .btn-outline-primary:hover {
    background-color: #f0f0f0;
}

/* ============================================
   TABLES
   ============================================ */

/* Table hover effect */
.table-hover tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: #f0f7ff !important;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 10px;
    margin-bottom: 20px;
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    border-radius: 10px 10px 0 0 !important;
    padding: 15px 20px;
    font-weight: 600;
}

/* ============================================
   BREADCRUMBS
   ============================================ */

.breadcrumb {
    background-color: transparent;
    padding: 15px 0;
}

/* ============================================
   SCROLLBARS
   ============================================ */

/* Scrollbar for parallel view */
.parallel-view .text-column::-webkit-scrollbar {
    width: 8px;
}

.parallel-view .text-column::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.parallel-view .text-column::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.parallel-view .text-column::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Scrollbar for tag filters */
.tags-filter-container::-webkit-scrollbar {
    width: 6px;
}

.tags-filter-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.tags-filter-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.tags-filter-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .parallel-view {
        grid-template-columns: 1fr;
    }
    
    .parallel-view .text-column {
        height: 50vh;
    }
    
    .filter-sidebar {
        position: static;
        margin-bottom: 20px;
    }
    
    .tags-filter-container {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .navbar, .filter-sidebar, .btn, .breadcrumb {
        display: none !important;
    }
    
    .parallel-view {
        display: block;
    }
    
    .parallel-view .text-column {
        height: auto;
        overflow: visible;
        page-break-inside: avoid;
        margin-bottom: 30px;
    }
}

/* ============================================
   FRAGMENT PREVIEW
   ============================================ */

/* Fragment content preview - text truncation */
.fragment-content-preview {
    font-size: 0.85rem;
    max-height: 46px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    word-wrap: break-word;
    margin-top: 0.25rem;
}

.fragment-content-preview.small {
    font-size: 0.75rem;
    max-height: 36px;
    line-height: 1.5;
    margin-top: 0.25rem;
}

.fragment-preview {
    font-size: 0.9rem;
    color: #6c757d;
    max-height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.5;
    word-wrap: break-word;
}

/* Fragment sidebar in text view */
.fragment-sidebar {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.fragment-item {
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    padding: 2px !important;  /* Минимальный отступ 2px */
}

.fragment-item:hover {
    background-color: #f8f9fa !important;  /* Светло-серый вместо синего */
    border-left-color: #0d6efd;
}

/* Override Bootstrap .list-group-item-action hover */
.list-group-item.fragment-item:hover {
    background-color: #f8f9fa !important;
    color: inherit !important;
}

/* Override Bootstrap .list-group-item.active - make text white and bg less bright */
.list-group-item.fragment-item.active {
    background-color: #0d6efd !important;  /* Синий но не яркий */
    color: white !important;  /* Белый текст */
    border-color: #0d6efd !important;
}

.list-group-item.fragment-item.active .badge,
.list-group-item.fragment-item.active small,
.list-group-item.fragment-item.active .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;  /* Светлый текст */
}

.fragment-item.draft {
    border-left-color: #6c757d;
}

.fragment-item.marked {
    border-left-color: #0d6efd;
}

.fragment-item.verified {
    border-left-color: #198754;
}

/* Highlighted text in main view */
.highlighted-fragment {
    background-color: #fff3cd;
    padding: 2px 0;
    transition: background-color 0.3s;
}

.highlighted-fragment.active {
    background-color: #ffc107;
    font-weight: 500;
}
