/* RDR2 Horse Advisor - Dark Frontier Theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark backgrounds */
    --bg-black: #0d0d0d;
    --bg-dark: #141414;
    --bg-card: #1a1a1a;
    --bg-elevated: #222222;

    /* Text */
    --text-cream: #e8e4dc;
    --text-muted: #9a958c;
    --text-dark: #1a1a1a;

    /* Accents */
    --red-primary: #c41e3a;
    --red-dark: #8b1528;
    --red-glow: rgba(196, 30, 58, 0.4);
    --rust: #d4652a;
    --gold: #c9a227;

    /* Borders */
    --border-subtle: #2a2a2a;
    --border-medium: #3a3a3a;
}

body {
    font-family: 'Crimson Text', Georgia, serif;
    background: var(--bg-black);
    color: var(--text-cream);
    min-height: 100vh;
    line-height: 1.7;
    font-size: 1.05rem;
    /* Subtle vignette effect */
    background-image: radial-gradient(ellipse at center, var(--bg-dark) 0%, var(--bg-black) 100%);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== HEADER ========== */
header {
    text-align: center;
    padding: 50px 20px 40px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

header h1 {
    font-family: 'Rye', cursive;
    font-size: 2.6rem;
    color: var(--text-cream);
    text-transform: uppercase;
    letter-spacing: 6px;
    margin-bottom: 12px;
    text-shadow: 0 0 40px var(--red-glow);
}

.subtitle {
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.1rem;
}

/* ========== CARDS & PANELS ========== */
.api-config,
.question-card,
.result-card,
.your-answers {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    margin-bottom: 20px;
}

.config-header {
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elevated);
    color: var(--text-cream);
    font-family: 'Rye', cursive;
    letter-spacing: 1px;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.2s;
}

.config-header:hover {
    background: #2a2a2a;
}

.toggle-icon {
    font-size: 1.5rem;
    color: var(--red-primary);
}

.config-body {
    padding: 25px;
    display: none;
}

.config-body.show {
    display: block;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    background: var(--bg-dark);
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    color: var(--text-cream);
    font-size: 1rem;
    font-family: 'Crimson Text', Georgia, serif;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--red-primary);
}

.save-btn {
    background: var(--red-primary);
    color: var(--text-cream);
    border: none;
    padding: 12px 30px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Rye', cursive;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.2s;
}

.save-btn:hover {
    background: #d42945;
    box-shadow: 0 0 20px var(--red-glow);
}

/* ========== MAIN CHAT AREA ========== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    min-height: 400px;
}

.welcome-message {
    text-align: center;
    padding: 20px;
}

.welcome-message h2 {
    font-family: 'Rye', cursive;
    color: var(--text-cream);
    margin-bottom: 8px;
    font-size: 1.4rem;
    font-weight: normal;
}

.welcome-message h3 {
    font-family: 'Rye', cursive;
    color: var(--text-muted);
    margin: 25px 0 15px;
    font-size: 1rem;
    font-weight: normal;
}

.welcome-hint {
    color: var(--text-muted);
    font-style: italic;
    font-size: 1rem;
}

.example-queries {
    list-style: none;
    margin-top: 10px;
    display: grid;
    gap: 10px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.example-queries li {
    background: var(--bg-card);
    padding: 14px 22px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-style: italic;
}

.example-queries li:hover {
    border-color: var(--red-primary);
    color: var(--text-cream);
    background: var(--bg-elevated);
    transform: translateX(5px);
}

/* ========== MESSAGES ========== */
.message {
    padding: 18px 22px;
    margin: 12px 0;
    border-radius: 4px;
    max-width: 90%;
}

.message.user {
    background: var(--red-dark);
    color: var(--text-cream);
    margin-left: auto;
    border: 1px solid var(--red-primary);
}

.message.assistant {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
}

.message.assistant h3,
.message.assistant h4 {
    font-family: 'Rye', cursive;
    color: var(--rust);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.message.assistant ul {
    margin: 12px 0;
    padding-left: 25px;
}

.message.assistant li {
    margin: 6px 0;
}

.message.assistant strong {
    color: var(--rust);
}

.message.assistant code {
    background: var(--bg-dark);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.9em;
    border: 1px solid var(--border-subtle);
}

.message.error {
    background: var(--red-dark);
    color: var(--text-cream);
    border: 1px solid var(--red-primary);
}

/* ========== HORSE CARDS ========== */
.horse-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 18px;
    margin: 12px 0;
}

.horse-card h4 {
    font-family: 'Rye', cursive;
    color: var(--rust);
    margin-bottom: 12px;
}

.horse-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 12px 0;
}

.stat {
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--red-primary);
    font-family: 'Rye', cursive;
}

.stat-bar {
    height: 4px;
    background: var(--bg-dark);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--red-dark), var(--red-primary));
    border-radius: 2px;
}

/* ========== LOADING ========== */
.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    margin: 12px 0;
    color: var(--text-muted);
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--red-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ========== INPUT AREA ========== */
.input-container {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 25px 0;
    border-top: 1px solid var(--border-subtle);
}

#queryInput {
    flex: 1;
    padding: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    color: var(--text-cream);
    font-size: 1.1rem;
    resize: none;
    font-family: 'Crimson Text', Georgia, serif;
    transition: border-color 0.2s;
    min-height: 52px;
}

#queryInput:focus {
    outline: none;
    border-color: var(--red-primary);
}

#queryInput::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

#sendBtn {
    width: 52px;
    min-height: 52px;
    background: var(--red-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#sendBtn:hover {
    background: #d42945;
    box-shadow: 0 0 20px var(--red-glow);
}

#sendBtn:disabled {
    background: var(--bg-elevated);
    cursor: not-allowed;
    box-shadow: none;
}

#sendBtn svg {
    width: 22px;
    height: 22px;
    color: var(--text-cream);
}

#newChatBtn {
    width: 52px;
    min-height: 52px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#newChatBtn:hover {
    background: var(--bg-card);
    border-color: var(--rust);
}

#newChatBtn svg {
    width: 22px;
    height: 22px;
    color: var(--text-muted);
}

#newChatBtn:hover svg {
    color: var(--rust);
}

/* ========== FOOTER ========== */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    border-top: 1px solid var(--border-subtle);
}

/* ========== MARKDOWN FORMATTING ========== */
.message.assistant p {
    margin: 10px 0;
}

.message.assistant table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
}

.message.assistant th,
.message.assistant td {
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    text-align: left;
}

.message.assistant th {
    background: var(--bg-elevated);
    color: var(--rust);
    font-family: 'Rye', cursive;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.message.assistant tr:nth-child(even) {
    background: var(--bg-dark);
}

/* ========== HORSE LINKS ========== */
.horse-name-link {
    color: var(--rust);
    text-decoration: none;
    transition: color 0.2s;
}

.horse-name-link:hover {
    color: var(--red-primary);
    text-decoration: underline;
}

.horse-name-link strong {
    color: inherit;
}

.horse-image-link {
    display: inline-block;
    transition: transform 0.2s, box-shadow 0.2s;
}

.horse-image-link:hover {
    transform: scale(1.03);
}

.horse-image-link:hover .horse-image,
.horse-image-link:hover .horse-image-large {
    border-color: var(--red-primary);
    box-shadow: 0 6px 20px rgba(196, 30, 58, 0.4);
}

/* ========== HORSE IMAGES ========== */
.horse-image {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid var(--border-medium);
    background: var(--bg-dark);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.horse-image-large {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid var(--border-medium);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.horse-card-with-image {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.horse-card-with-image .horse-image {
    flex-shrink: 0;
}

.horse-card-info {
    flex: 1;
}

/* ========== RESULT CARDS ========== */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 25px;
    margin: 18px 0;
}

.result-card.top-pick,
.result-card.rank-1 {
    border-color: var(--red-primary);
    box-shadow: 0 0 30px rgba(196, 30, 58, 0.15);
}

.result-card-header {
    display: flex;
    gap: 20px;
    margin-bottom: 18px;
}

.result-card-header .horse-image-large {
    flex-shrink: 0;
}

.result-card-content {
    flex: 1;
}

.result-card h3 {
    font-family: 'Rye', cursive;
    color: var(--text-cream);
    font-size: 1.3rem;
    margin-bottom: 6px;
}

.result-card .coat-name {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-style: italic;
    margin-bottom: 12px;
}

.result-rank {
    display: inline-block;
    background: var(--red-primary);
    color: var(--text-cream);
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Rye', cursive;
    margin-bottom: 12px;
}

.result-reason {
    background: var(--bg-dark);
    padding: 14px 18px;
    border-radius: 4px;
    border-left: 3px solid var(--rust);
    font-style: italic;
    color: var(--text-muted);
}

/* Stats grid for results */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 18px 0;
}

.stats-grid .stat-item {
    text-align: center;
    padding: 12px 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
}

.stats-grid .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-grid .stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--red-primary);
    font-family: 'Rye', cursive;
}

/* ========== RANK BADGES ========== */
.rank-badge {
    background: var(--red-primary);
    color: var(--text-cream);
    padding: 6px 14px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
    font-family: 'Rye', cursive;
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
    color: var(--text-dark);
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #808080 100%);
    color: var(--text-dark);
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #8b4513 100%);
    color: var(--text-cream);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
        letter-spacing: 3px;
    }

    .horse-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .message {
        max-width: 95%;
    }

    .horse-card-with-image {
        flex-direction: column;
    }

    .horse-image {
        width: 120px;
        height: 120px;
    }

    .result-card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .horse-image-large {
        width: 150px;
        height: 150px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Citation links from web search */
.citation-link {
    color: #6ba3d6;
    text-decoration: none;
    border-bottom: 1px dotted #6ba3d6;
    transition: color 0.2s, border-color 0.2s;
}

.citation-link:hover {
    color: #8bc4f0;
    border-bottom-color: #8bc4f0;
    text-decoration: none;
}

.citation-link::after {
    content: '↗';
    font-size: 0.7em;
    margin-left: 2px;
    vertical-align: super;
}
