/* CSS Variables */
:root {
    --gold: #9B8B5E;
    --gold-hover: #8A7A50;
    --gold-dark: #857550;
    --teal: #008B8B;
    --teal-light: rgba(0, 139, 139, 0.1);
    --white: #ffffff;
    --cream: #FDF8E8;
    --cream-light: #FFFBF0;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-500: #737373;
    --gray-600: #525252;
    --gray-700: #404040;
    --gray-800: #262626;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 200ms ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Tahoma, sans-serif;
    background: #f0f0f0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--gray-700);
}

/* Main Card Container */
.search-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 800px;
    padding: 28px 32px;
    position: relative;
}

/* Close Button */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
    transition: color var(--transition);
    padding: 0;
}

.close-btn:hover {
    color: var(--gray-600);
}

/* Card Header */
.card-header {
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.3;
    margin-bottom: 4px;
}

.card-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--teal);
    font-weight: 500;
}

.card-subtitle .ai-icon {
    width: 14px;
    height: 14px;
    fill: var(--teal);
}

/* Search Section */
.search-section {
    margin-bottom: 24px;
}

.search-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.search-input-container {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    transition: all var(--transition);
    padding-right: 8px;
}

.search-input-container:focus-within {
    border-color: var(--gray-300);
}

.search-input {
    flex: 1;
    padding: 14px 16px;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--gray-700);
    outline: none;
    line-height: 1.5;
}

.search-input::placeholder {
    color: var(--gray-400);
}

.clear-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    transition: all var(--transition);
    flex-shrink: 0;
    padding: 0;
    font-size: 18px;
    font-weight: 300;
}

.clear-btn.visible {
    display: flex;
}

.clear-btn:hover {
    color: var(--gray-600);
}

.clear-btn svg {
    width: 12px;
    height: 12px;
}

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--gold);
    color: var(--white);
    border: 1px solid var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.search-btn:hover:not(:disabled) {
    background: var(--gold-hover);
    border-color: var(--gold-hover);
}

.search-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.search-btn .ai-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Results Section */
.results-section {
    display: none;
}

.results-section.visible {
    display: block;
}

.results-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.results-content {
    background: var(--cream);
    border-left: 4px solid var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.results-main {
    padding: 20px 24px;
}

.results-text {
    font-size: 0.9375rem;
    line-height: 1.75;
    color: var(--gray-700);
}

.results-text > p:first-child {
    margin-top: 0;
}

.results-text > p:last-child {
    margin-bottom: 0;
}

.results-text a {
    color: var(--teal);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.results-text a:hover {
    color: var(--gold-dark);
}

/* Sources Section */
.results-text .sources-label {
    display: block;
    margin-top: 16px;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--gray-600);
    font-size: 0.875rem;
}

.results-text .source-link {
    display: block;
    color: var(--teal);
    text-decoration: underline;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Markdown Content Styling */
.results-text h1,
.results-text h2,
.results-text h3,
.results-text h4,
.results-text h5,
.results-text h6 {
    color: var(--gray-800);
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
}

.results-text h1 { font-size: 1.25rem; }
.results-text h2 { font-size: 1.125rem; }
.results-text h3 { font-size: 1rem; }
.results-text h4,
.results-text h5,
.results-text h6 { font-size: 0.9375rem; }

.results-text p {
    margin-bottom: 0.75em;
}

.results-text ul,
.results-text ol {
    margin: 0.75em 0;
    padding-left: 1.25em;
}

.results-text li {
    margin-bottom: 0.35em;
    line-height: 1.6;
}

.results-text ul li { list-style-type: disc; }
.results-text ol li { list-style-type: decimal; }

.results-text strong {
    font-weight: 600;
    color: var(--gray-800);
}

.results-text em {
    font-style: italic;
}

/* Error styling */
.results-text .error {
    color: #dc2626;
}

.results-text .error-details {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 8px;
}

/* Loading State */
.loading-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px;
    color: var(--gray-500);
    font-size: 0.875rem;
}

.loading-indicator.visible {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 600px) {
    .search-card {
        padding: 20px;
    }

    .close-btn {
        top: 16px;
        right: 16px;
    }

    .search-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .search-input-container {
        border-right: 1px solid var(--gray-200);
        border-radius: var(--radius);
    }

    .search-btn {
        width: 100%;
        border-radius: var(--radius);
    }

    .card-title {
        font-size: 1.25rem;
        padding-right: 40px;
    }

    .results-main {
        padding: 16px 20px;
    }
}
