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

:root {
    --color-primary: #1a365d;
    --color-primary-light: #2a5298;
    --color-accent: #e8a317;
    --color-highlight: #fff3b0;
    --color-highlight-strong: #ffe066;
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-text: #1a202c;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-success: #16a34a;
    --color-error: #dc2626;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Source Serif 4', 'Georgia', serif;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* === Header === */
.site-header {
    background: var(--color-primary);
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo h1 a {
    color: white;
    text-decoration: none;
}

.logo .subtitle {
    font-size: 0.85rem;
    opacity: 0.75;
    font-weight: 400;
}

/* === Search Section === */
.search-section {
    padding: 48px 0 32px;
}

.search-intro {
    text-align: center;
    margin-bottom: 24px;
}

.search-intro p {
    font-size: 1.1rem;
    color: var(--color-text-muted);
}

.search-form {
    max-width: 700px;
    margin: 0 auto;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 4px 4px 4px 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrapper:focus-within {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.15);
}

.search-icon {
    color: var(--color-text-muted);
    flex-shrink: 0;
    margin-right: 12px;
}

#search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: transparent;
    padding: 12px 0;
    min-width: 0;
}

#search-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

#search-button {
    flex-shrink: 0;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#search-button:hover {
    background: var(--color-primary-light);
}

#search-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.spinner {
    animation: spin 0.8s linear infinite;
}

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

/* === Hint Chips === */
.search-hints {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    justify-content: center;
}

.hint-chip {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-family: var(--font-sans);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.hint-chip:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary);
    background: #f0f4ff;
}

/* === Results === */
.results-section {
    padding: 0 0 48px;
}

.results-header {
    margin-bottom: 20px;
}

.results-header h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.results-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* === AI Answer === */
.ai-answer-card {
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4f8 100%);
    border: 1px solid #bdd8f0;
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 24px;
    position: relative;
}

.ai-answer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ai-answer-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.ai-answer-body {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--color-text);
}

.ai-answer-body p {
    margin-bottom: 8px;
}

.ai-answer-body p:last-child {
    margin-bottom: 0;
}

.ai-answer-disclaimer {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-style: italic;
    border-top: 1px solid #d0e3f0;
    padding-top: 10px;
}

/* === Result Card === */
.result-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
}

.result-card-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.result-article-info {
    flex: 1;
}

.result-article-number {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary);
}

.result-breadcrumb {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.result-score {
    flex-shrink: 0;
    background: var(--color-highlight);
    color: var(--color-text);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.result-score.high {
    background: var(--color-highlight-strong);
}

.result-card-body {
    padding: 16px 20px 20px;
}

.result-law-text {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--color-text);
    max-height: 400px;
    overflow-y: auto;
    position: relative;
}

.result-law-text.collapsed {
    max-height: 200px;
    overflow: hidden;
}

.result-law-text.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--color-surface));
    pointer-events: none;
}

/* Highlighting within law text */
.result-law-text mark.chunk-highlight {
    background-color: var(--color-highlight);
    border-radius: 2px;
    padding: 0 1px;
}

.result-law-text strong {
    font-weight: 600;
    background-color: var(--color-highlight-strong);
    border-radius: 2px;
    padding: 0 2px;
}

.result-card-footer {
    padding: 0 20px 16px;
}

.toggle-expand {
    background: none;
    border: none;
    color: var(--color-primary-light);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 500;
}

.toggle-expand:hover {
    text-decoration: underline;
}

/* === No Results === */
.no-results {
    text-align: center;
    padding: 48px 24px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.no-results-message {
    font-size: 1.1rem;
    color: var(--color-text);
    font-weight: 500;
    margin-bottom: 12px;
}

.no-results-hint {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.no-results-hint a {
    color: var(--color-primary-light);
}

/* === Error === */
.error-section {
    padding: 24px 0;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    color: var(--color-error);
    font-size: 0.95rem;
}

/* === Footer === */
.site-footer {
    margin-top: auto;
    padding: 24px 0;
    border-top: 1px solid var(--color-border);
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.site-footer a {
    color: var(--color-primary-light);
}

.disclaimer {
    margin-top: 8px;
    font-size: 0.78rem;
    font-style: italic;
}

/* === Responsive === */
@media (max-width: 640px) {
    .search-section {
        padding: 32px 0 24px;
    }

    .search-intro p {
        font-size: 1rem;
    }

    #search-input {
        font-size: 0.95rem;
    }

    #search-button {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .hint-chip {
        font-size: 0.78rem;
        padding: 5px 12px;
    }

    .result-card-header {
        flex-direction: column;
        gap: 8px;
    }

    .result-card-body {
        padding: 12px 16px 16px;
    }

    .result-law-text {
        font-size: 0.9rem;
    }

    .logo h1 {
        font-size: 1.2rem;
    }
}

/* === Loading shimmer === */
.loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.skeleton-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    padding: 20px;
    animation: shimmer 1.5s infinite;
}

.skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-line.short {
    width: 40%;
}

.skeleton-line.medium {
    width: 70%;
}

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