/* 佛经注疏可视化系统 - 古典东方风格 */
/* Inspired by ancient Buddhist manuscripts and temple aesthetics */

/* ===== CSS Variables ===== */
:root {
    /* Primary Colors - Sandalwood & Gold */
    --primary: #8B4513;
    --primary-hover: #A0522D;
    --primary-light: rgba(139, 69, 19, 0.1);
    --primary-gradient: linear-gradient(135deg, #8B4513 0%, #A0522D 50%, #B8860B 100%);

    /* Accent - Antique Gold */
    --accent: #B8860B;
    --accent-light: rgba(184, 134, 11, 0.15);
    --accent-glow: rgba(184, 134, 11, 0.4);

    /* Status Colors */
    --success: #2E8B57;
    --success-light: rgba(46, 139, 87, 0.12);
    --warning: #DAA520;
    --warning-light: rgba(218, 165, 32, 0.12);
    --muted: #5D5D5D;
    --muted-light: rgba(93, 93, 93, 0.1);

    /* Three Layers Colors */
    --layer-evidence: #4B6587;
    --layer-paraphrase: #3D7068;
    --layer-commentary: #7B506F;

    /* Background Colors */
    --bg-page: #FDFBF7;
    --bg-card: #FFFFF0;
    --bg-card-hover: #FFFEF5;
    --bg-dark: #2C2C2C;
    --bg-paper: linear-gradient(180deg, #FDFBF7 0%, #F8F4EC 100%);

    /* Text Colors */
    --text-primary: #2C2C2C;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --text-gold: #8B6914;

    /* Borders */
    --border-color: #E8E0D0;
    --border-hover: #D4C9B8;
    --border-gold: rgba(184, 134, 11, 0.3);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(139, 69, 19, 0.06);
    --shadow-md: 0 4px 16px rgba(139, 69, 19, 0.1);
    --shadow-lg: 0 8px 32px rgba(139, 69, 19, 0.12);
    --shadow-gold: 0 4px 20px rgba(184, 134, 11, 0.15);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Fonts */
    --font-serif: 'Noto Serif SC', 'Source Han Serif CN', 'STSong', 'SimSun', serif;
    --font-display: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Base Styles ===== */
body {
    font-family: var(--font-sans);
    background: var(--bg-paper);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
}

/* Subtle paper texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5 {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--text-primary);
}

.display-5 {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 0.05em;
}

/* ===== Navigation Bar ===== */
.navbar {
    background: var(--primary-gradient) !important;
    box-shadow: 0 2px 20px rgba(139, 69, 19, 0.25);
    padding: 0.75rem 0;
    position: relative;
}

.navbar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--accent) 20%,
        var(--accent) 80%,
        transparent 100%
    );
    opacity: 0.6;
}

.navbar-brand {
    font-family: var(--font-display);
    font-size: 1.35rem;
    letter-spacing: 0.08em;
    color: #fff !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand i {
    font-size: 1.5rem;
    color: var(--accent);
    filter: drop-shadow(0 0 8px rgba(184, 134, 11, 0.4));
}

.nav-link {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 0.5rem 1rem !important;
    transition: var(--transition-fast);
    position: relative;
}

.nav-link:hover {
    color: #fff !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: var(--transition-normal);
    transform: translateX(-50%);
}

.nav-link:hover::after {
    width: 60%;
}

/* Search form in navbar */
.navbar .form-control {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.navbar .form-control::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.navbar .form-control:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.2);
    color: #fff;
}

.navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: var(--radius-md);
}

.navbar .btn-outline-light:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ===== Main Container ===== */
main.container {
    max-width: 1200px;
}

/* ===== Hero Title ===== */
.text-primary {
    color: var(--primary) !important;
}

.lead {
    font-family: var(--font-serif);
    color: var(--text-secondary);
}

/* ===== Demo Card ===== */
.demo-card,
.card[style*="linear-gradient"] {
    background: var(--primary-gradient) !important;
    border: none !important;
    border-radius: var(--radius-xl) !important;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.demo-card::before,
.card[style*="linear-gradient"]::before {
    content: '☸';
    position: absolute;
    right: -30px;
    bottom: -30px;
    font-size: 180px;
    opacity: 0.08;
    color: #fff;
}

/* ===== Statistics Cards ===== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.stat-card .card-body {
    padding: 1.75rem 1.5rem;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 400;
    color: var(--primary);
    letter-spacing: 0.02em;
}

.stat-value.text-success { color: var(--success) !important; }
.stat-value.text-warning { color: var(--warning) !important; }
.stat-value.text-secondary { color: var(--muted) !important; }

.stat-label {
    font-family: var(--font-serif);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: 0.02em;
    margin-top: 0.5rem;
}

/* ===== Card Base Styles ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.card-header h5,
.card-header h6 {
    font-family: var(--font-serif);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header i {
    color: var(--primary);
}

.card-body {
    padding: 1.5rem;
}

/* ===== Sutra Text (Scripture Display) ===== */
.sutra-text {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 2.1;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-card) 0%, #FFFEF8 100%);
    padding: 1.75rem 2rem;
    border-radius: var(--radius-md);
    border-left: 5px solid var(--primary);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.sutra-text::before {
    content: '❝';
    position: absolute;
    top: 0.5rem;
    left: 1rem;
    font-size: 2.5rem;
    color: var(--accent);
    opacity: 0.25;
    font-family: serif;
}

/* ===== Three Layer Annotation Cards ===== */
.layer-card {
    border-left: 5px solid;
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    position: relative;
}

.layer-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.layer-evidence {
    border-color: var(--layer-evidence);
    background: linear-gradient(90deg, rgba(75, 101, 135, 0.06) 0%, var(--bg-card) 100%);
}

.layer-paraphrase {
    border-color: var(--layer-paraphrase);
    background: linear-gradient(90deg, rgba(61, 112, 104, 0.06) 0%, var(--bg-card) 100%);
}

.layer-commentary {
    border-color: var(--layer-commentary);
    background: linear-gradient(90deg, rgba(123, 80, 111, 0.06) 0%, var(--bg-card) 100%);
}

.layer-title {
    font-family: var(--font-serif);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.layer-evidence .layer-title { color: var(--layer-evidence); }
.layer-paraphrase .layer-title { color: var(--layer-paraphrase); }
.layer-commentary .layer-title { color: var(--layer-commentary); }

.layer-card p {
    font-family: var(--font-serif);
    line-height: 1.9;
}

/* ===== Status Badges ===== */
.badge {
    font-family: var(--font-sans);
    font-weight: 500;
    padding: 0.4em 0.8em;
    border-radius: 50px;
    font-size: 0.8rem;
}

.badge-success-custom,
.bg-success {
    background: var(--success) !important;
}

.badge-partial-custom,
.bg-warning {
    background: var(--warning) !important;
    color: #fff !important;
}

.badge-null-custom,
.bg-secondary {
    background: var(--muted) !important;
}

.bg-primary {
    background: var(--primary) !important;
}

.bg-danger {
    background: #C94A4A !important;
}

/* ===== Chapter Cards ===== */
.chapter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1rem;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.chapter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
    opacity: 0;
    transition: var(--transition-normal);
}

.chapter-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.chapter-card:hover::before {
    opacity: 1;
}

.chapter-name {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Coverage Progress Bar ===== */
.coverage-bar,
.progress {
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    overflow: hidden;
}

.coverage-bar .progress-bar,
.progress-bar {
    border-radius: 4px;
    transition: width 0.6s ease;
}

.progress-bar.bg-success { background: var(--success) !important; }
.progress-bar.bg-warning { background: var(--warning) !important; }
.progress-bar.bg-secondary { background: var(--muted) !important; }
.progress-bar.bg-primary { background: var(--primary) !important; }
.progress-bar.bg-info { background: var(--accent) !important; }

/* ===== Confidence Bar ===== */
.confidence-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
}

.confidence-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--warning), var(--success));
}

/* ===== Match Cards (A-text matches) ===== */
.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 0.875rem;
    transition: var(--transition-normal);
}

.match-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.match-score {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    background: var(--accent-light);
    color: var(--text-gold);
    border-radius: var(--radius-sm);
}

/* ===== Annotation List Items ===== */
.annotation-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: var(--transition-normal);
}

.annotation-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

/* ===== Filter Buttons ===== */
.filter-btn {
    font-family: var(--font-serif);
    border-radius: 50px;
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    transition: var(--transition-fast);
    border-width: 2px;
}

.filter-btn.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: var(--shadow-sm);
}

.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-outline-success {
    border-color: var(--success);
    color: var(--success);
}

.btn-outline-success:hover {
    background: var(--success);
    color: #fff;
}

.btn-outline-warning {
    border-color: var(--warning);
    color: var(--warning);
}

.btn-outline-warning:hover {
    background: var(--warning);
    color: #fff;
}

/* ===== Primary Buttons ===== */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    font-weight: 500;
    padding: 0.625rem 1.5rem;
    border-radius: var(--radius-md);
    transition: var(--transition-normal);
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #A0522D 0%, #B8860B 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-light {
    background: #fff;
    color: var(--primary);
    font-weight: 600;
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn-light:hover {
    background: var(--bg-card);
    color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== Search Highlight ===== */
.search-highlight {
    background: var(--accent-light);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: var(--text-gold);
}

/* ===== Chart Container ===== */
.chart-container {
    position: relative;
    height: 300px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.chart-container h5 {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-container h5 i {
    color: var(--primary);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    background: transparent;
    padding: 0;
    font-family: var(--font-serif);
    font-size: 0.9rem;
}

.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.breadcrumb-item a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

.breadcrumb-item + .breadcrumb-item::before {
    content: '›';
    color: var(--text-light);
}

/* ===== Alerts ===== */
.alert-warning {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.alert-heading {
    font-family: var(--font-serif);
    color: var(--warning);
}

/* ===== Tables ===== */
.table {
    font-size: 0.9rem;
}

.table td {
    padding: 0.75rem 0.5rem;
    border-color: var(--border-color);
}

code {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: 1.5rem;
    display: block;
}

.empty-state h5 {
    font-family: var(--font-serif);
    color: var(--text-secondary);
}

/* ===== Footer ===== */
footer {
    background: linear-gradient(180deg, var(--bg-page) 0%, #F5EFE5 100%) !important;
    border-top: 1px solid var(--border-color) !important;
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

footer strong {
    font-family: var(--font-display);
    color: var(--primary);
    letter-spacing: 0.05em;
}

footer .text-primary {
    color: var(--accent) !important;
    font-weight: 600;
}

/* ===== Form Controls ===== */
.form-control {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-group-lg .form-control {
    font-family: var(--font-serif);
    padding: 1rem 1.25rem;
    font-size: 1rem;
}

/* ===== Utility Classes ===== */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-secondary, .text-muted { color: var(--text-secondary) !important; }

.fw-bold { font-weight: 600; }

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.1rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .sutra-text {
        font-size: 1rem;
        padding: 1.25rem 1.5rem;
        line-height: 1.9;
    }

    .chapter-card {
        padding: 1.25rem;
    }

    .chapter-name {
        font-size: 1.1rem;
    }

    .display-5 {
        font-size: 1.75rem;
    }

    .layer-card {
        padding: 1rem 1.25rem;
    }

    .filter-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* ===== Animation Keyframes ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Page load animation */
main.container {
    animation: fadeInUp 0.5s ease-out;
}

/* Shimmer effect for loading states */
.loading-shimmer {
    background: linear-gradient(90deg,
        var(--border-color) 25%,
        var(--bg-card) 50%,
        var(--border-color) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ===== Print Styles ===== */
@media print {
    .navbar, footer, .btn {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
