/* ===== CSS Variables & Theme ===== */
:root {
    --primary-color: #4a90a4;
    --primary-light: #6bb3c9;
    --primary-dark: #3d7a8c;
    --accent-color: #e07c5a;
    --accent-light: #f4a88a;
    --background: #fafbfc;
    --surface: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #5a6778;
    --text-muted: #8a95a5;
    --border-color: #e8ecf1;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
    --max-width: 900px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica,
        Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-light);
}

/* ===== Header & Navigation ===== */
.search-header {
    background: linear-gradient(135deg, #ffffff 0%, #f0f5f7 100%);
    color: var(--text-primary);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-nav {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 0 2rem;
}

.search-nav > a {
    flex-shrink: 0;
}

/* ===== Search Bar ===== */
#search {
    flex: 1;
    min-width: 280px;
}

.searchbar {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--primary-light);
}

.searchbar:focus-within {
    box-shadow:
        0 0 0 3px rgba(74, 144, 164, 0.2),
        var(--shadow-lg);
    transform: translateY(-1px);
}

.search-input {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    font-size: 1rem;
    background: transparent;
    color: var(--text-primary);
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-button {
    padding: 0.875rem 1.25rem;
    border: none;
    background: linear-gradient(var(--primary-light) 0%);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
}

.search-button:hover {
    background: linear-gradient(
        135deg,
        var(--primary-light) 0%,
        var(--primary-color) 100%
    );
}

.search-button:active {
    transform: scale(0.95);
}

.suggest_vsearch {
    background: linear-gradient(90deg, #e0f7fa 0%, #f1f8e9 100%);
    border-radius: 6px;
    padding: 0.7em 1.2em;
    margin: 1.2em auto 1.5em auto;
    font-size: 1.05rem;
}

.search-type-select {
    background: var(--surface);
    border: none;
    border-left: 1px solid var(--primary-light);
    padding: 0 0.8rem;
    font-size: 1rem;
}

/* ===== Secondary Navigation ===== */
.search-second-nav {
    max-width: var(--max-width);
    margin: 1rem auto 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    padding: 0 2rem;
}

.search-second-nav a {
    color: var(--primary-color);
    padding: 0.4rem 0.8rem;
    transition: var(--transition);
}

.search-second-nav a:hover {
    color: var(--primary-dark);
    background: rgba(74, 144, 164, 0.1);
}

.search-type a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.search-second-nav p {
    color: var(--text-secondary);
}

.noline {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== Main Content ===== */
main.search-results {
    flex: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    padding: 2rem;
}

/* ===== Search Result Cards ===== */
.search-result-text {
    background: var(--surface);
    padding: 1.5rem 2rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.search-result-text:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.search-result-text h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.underlineonhover {
    position: relative;
    display: inline-block;
}

.underlineonhover::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

.search-result-text:hover .underlineonhover::after,
a:hover .underlineonhover::after {
    width: 100%;
}

.search-result-text p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.search-result-text .info {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-result-text > a:last-child {
    display: inline-block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.3rem 0;
    border-top: 1px dashed var(--border-color);
    width: 100%;
}

.search-result-text > a:last-child:hover {
    color: var(--primary-color);
}

.nounderline {
    text-decoration: none;
}

/* ===== Case Detail Page ===== */
.search-result-text b {
    color: var(--primary-dark);
    font-weight: 600;
    min-width: 80px;
    display: inline-block;
}

.full_text,
#\32,
.full_text p {
    line-height: 25pt;
    text-indent: 30pt;
    margin: 0.5pt 0cm;
    font-family: 宋体;
    font-size: 15pt;
    text-align: justify;
    text-justify: inter-character;
}

#\32 ~ div {
    line-height: 25pt;
    text-indent: 30pt;
    margin: 0.5pt 0cm;
    font-family: 宋体;
    font-size: 15pt;
}

.home_link {
    font-size: 20pt;
}

.print_button {
    text-align: right;
}

/* id="1" */
#\31,
.c_right {
    text-align: right;
    font-size: 15pt;
}

.full_text > div:not(.c_right):nth-child(-n + 3) {
    font-family: 黑体;
    font-size: 18pt;
}

.c_header {
    font-family: 黑体;
    font-size: 18pt;
    text-align: center;
}

p {
    text-align: justify;
    text-justify: inter-character;
}

/* ===== Pagination ===== */
.pagination {
    max-width: var(--max-width);
    margin: 0 auto 2rem;
    padding: 0 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 50px;
    font-weight: 500;
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pagination a:active {
    transform: translateY(0);
}

/* ===== Footer ===== */
footer {
    background: #f5f7f9;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem 2rem;
    margin-top: auto;
}

footer a {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 3px;
}

footer a:hover {
    color: var(--primary-dark);
}

footer p {
    font-size: 0.9rem;
    text-align: center;
}

/* ===== Highlight for Search Results ===== */
mark,
b.highlight {
    background: linear-gradient(120deg, #fff3e0 0%, #ffe0b2 100%);
    color: var(--text-primary);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-weight: 500;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .search-header {
        padding: 1rem;
    }

    .search-nav {
        gap: 1rem;
        padding: 0;
    }

    #search {
        width: 100%;
        min-width: unset;
    }

    .search-input {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    main.search-results {
        padding: 1rem;
    }

    .search-result-text {
        padding: 1rem 1.25rem;
    }

    .search-result-text h3 {
        font-size: 1.1rem;
    }

    .pagination {
        padding: 0 1rem;
    }

    .pagination a {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-result-text {
    animation: fadeIn 0.3s ease forwards;
}

.search-result-text:nth-child(1) {
    animation-delay: 0.05s;
}
.search-result-text:nth-child(2) {
    animation-delay: 0.1s;
}
.search-result-text:nth-child(3) {
    animation-delay: 0.15s;
}
.search-result-text:nth-child(4) {
    animation-delay: 0.2s;
}
.search-result-text:nth-child(5) {
    animation-delay: 0.25s;
}

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

::-webkit-scrollbar-track {
    background: #f0f3f5;
}

::-webkit-scrollbar-thumb {
    background: #c5d0d8;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8b5c0;
}

/* ===== Selection Styling ===== */
::selection {
    background: rgba(74, 144, 164, 0.3);
    color: var(--text-primary);
}

/* ===== Print Styles ===== */
@media print {
    /* Reset for print */
    *,
    *::before,
    *::after {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* Page setup */
    @page {
        size: A4;
        margin: 2cm 1.5cm;
    }

    @page :first {
        margin-top: 1.5cm;
    }

    html {
        font-size: 12pt;
    }

    body {
        font-family:
            -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
            "SimSun", "宋体", serif;
        line-height: 1.5;
        min-height: auto;
        background: white !important;
    }

    /* Hide non-essential elements */
    .search-header,
    .search-nav,
    .search-second-nav,
    .pagination,
    .similar-cases,
    .print_button,
    .home_link,
    footer {
        display: none !important;
    }

    /* Main content adjustments */
    main.search-results {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    .search-result-text {
        border: none !important;
        border-radius: 0;
        padding: 0;
        margin: 0;
        box-shadow: none !important;
        animation: none !important;
        background: transparent !important;
    }

    .search-result-text:hover {
        transform: none;
    }

    /* Title styling for print */
    .search-result-text h3 {
        font-size: 16pt;
        font-family:
            "PingFang SC", "Microsoft YaHei", "SimHei", "黑体", sans-serif;
        color: #3d7a8c !important;
        margin-bottom: 0.8cm;
        padding-bottom: 0.3cm;
        border-bottom: 2px solid #4a90a4;
        page-break-after: avoid;
    }

    /* Meta info styling - preserve some site style */
    .search-result-text > p {
        font-size: 10.5pt;
        margin-bottom: 0.4em;
        text-indent: 0;
        color: #333 !important;
        line-height: 1.8;
    }

    .search-result-text b {
        font-weight: 600;
        min-width: 5em;
        color: #3d7a8c !important;
    }

    .full_text {
        page-break-before: always;
    }

    .full_text,
    #\32,
    #\32 ~ div {
        font-family: "SimSun", "宋体", serif;
        font-size: 14pt;
        line-height: 2;
        text-indent: 2em;
        text-align: justify;
        margin-top: 0;
        color: #000 !important;
    }

    .full_text > div:not(.c_right):nth-child(-n + 3),
    .c_header {
        font-family: "SimHei", "黑体", sans-serif;
        font-size: 16pt;
        text-align: center;
        text-indent: 0;
    }

    .c_right {
        text-align: right !important;
        text-indent: 0 !important;
    }

    /* Prevent page breaks in awkward places */
    h3,
    p,
    div {
        orphans: 3;
        widows: 3;
    }
}
