/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Upload Section */
.upload-section {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    text-align: center;
}

.file-input-container {
    position: relative;
    display: inline-block;
}

#fileInput {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 30px;
    background: #667eea;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px dashed transparent;
}

.file-input-label:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.file-input-icon {
    font-size: 1.3rem;
}

.file-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #666;
    border-left: 4px solid #667eea;
}

/* Results Section */
.results-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Tabs */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:hover {
    background: #e9ecef;
    color: #333;
}

.tab-button.active {
    color: #667eea;
    background: white;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #667eea;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Story Info */
.story-info {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.story-info h3 {
    margin-bottom: 20px;
    color: #333;
    font-weight: 600;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span {
    color: #333;
    font-size: 1rem;
    word-break: break-all;
}

/* Passages */
.passages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.passages-header h3 {
    color: #333;
    font-weight: 600;
}

.search-container input {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    width: 250px;
    transition: border-color 0.3s ease;
}

.search-container input:focus {
    outline: none;
    border-color: #667eea;
}

.passages-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.passage-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.passage-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.1);
}

.passage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.passage-name {
    color: #333;
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
}

.passage-stats {
    display: flex;
    gap: 15px;
}

.passage-stats .stat {
    font-size: 0.9rem;
    color: #666;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.passage-tags {
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.no-tags {
    color: #999;
    font-style: italic;
    font-size: 0.9rem;
}

.passage-preview {
    color: #555;
    line-height: 1.5;
    font-size: 0.95rem;
}

/* Tags */
.tags-header {
    margin-bottom: 25px;
}

.tags-header h3 {
    color: #333;
    font-weight: 600;
}

.tags-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tag-stat {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
}

.tag-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
    padding-left: 10px;
    border-left: 4px solid #667eea;
}

.tag-count {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.tag-passages {
    color: #666;
    line-height: 1.5;
}

.passage-link {
    color: #667eea;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.3s ease;
}

.passage-link:hover {
    color: #5a67d8;
    text-decoration: underline;
}

/* Metadata */
.metadata-container h3 {
    margin-bottom: 25px;
    color: #333;
    font-weight: 600;
}

.metadata-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.metadata-section h4 {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 1.1rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 8px;
}

.metadata-list {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 10px 20px;
    align-items: start;
}

.metadata-list dt {
    font-weight: 600;
    color: #555;
    text-align: right;
    padding-top: 5px;
}

.metadata-list dd {
    color: #333;
    padding: 5px 0;
    word-break: break-word;
}

/* Error Section */
.error-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    padding: 40px;
    text-align: center;
}

.error-message {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    padding: 25px;
    border-left: 4px solid #e53e3e;
}

.error-message h3 {
    color: #e53e3e;
    margin-bottom: 10px;
    font-weight: 600;
}

.error-message p {
    color: #c53030;
    font-size: 1rem;
}

/* No Data */
.no-data {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 40px;
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .upload-section {
        padding: 25px;
    }
    
    .tab-content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .metadata-list {
        grid-template-columns: 1fr;
        gap: 5px 0;
    }
    
    .metadata-list dt {
        text-align: left;
        font-weight: 600;
        color: #667eea;
    }
    
    .passages-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container input {
        width: 100%;
    }
    
    .passage-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: none;
        min-width: 25%;
    }
}

@media (max-width: 480px) {
    header {
        padding: 20px 15px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .upload-section {
        padding: 20px;
    }
    
    .file-input-label {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .tab-button {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
}
