/* Antimony – App Styles */

/* Chart dimension variables (overridden by .pdf-export-active in ResultRenderer.js) */
:root {
    --chart-pie-height: 420px;
    --chart-canvas-max: 200px;
    --chart-keyword-height: 350px;
    --chart-large-height: 350px;
}

/* Theme Custom Properties */
[data-bs-theme="light"] {
    --app-bg: #f5f7fa;
    --app-card-bg: #fff;
    --app-card-hover-shadow: rgba(0, 0, 0, 0.1);
    --app-text: #2d3748;
    --app-text-muted: #718096;
    --app-text-secondary: #4a5568;
    --app-border: #e2e8f0;
    --app-border-hover: #a0aec0;
    --app-input-focus-bg: #edf2f7;
    --app-hover-bg: #f8fafc;
    --app-keyword-bg: #edf2f7;
    --app-keyword-text: #2d3748;
    --app-mention-bg: #fefcbf;
    --app-code-bg: #e9ecef;
    --app-code-color: #d63384;
    --app-nav-bg: #fff;
    --app-slide-tab-bg: #fff;
    --app-slide-tab-hover-bg: #f7fafc;
    --app-active-bg: #ebf8ff;
    --app-active-border: #3182ce;
    --app-active-text: #2b6cb0;
    --app-domain-header-gradient: linear-gradient(135deg, #ebf8ff, #e2e8f0);
    --app-competitor-header-bg: #f7fafc;
    --app-competitor-header-hover: #edf2f7;
    --app-known-yes-bg: #f0fff4;
    --app-known-no-bg: #fff5f5;
    --app-main-domain-row-bg: #ebf8ff;
    --app-rank-other-bg: #e2e8f0;
    --app-rank-other-color: #4a5568;
    --app-log-border: #edf2f7;
    --app-table-odd-bg: #f8f9fa;
    --app-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

[data-bs-theme="dark"] {
    --app-bg: #1a202c;
    --app-card-bg: #2d3748;
    --app-card-hover-shadow: rgba(0, 0, 0, 0.3);
    --app-text: #e2e8f0;
    --app-text-muted: #a0aec0;
    --app-text-secondary: #cbd5e0;
    --app-border: #4a5568;
    --app-border-hover: #718096;
    --app-input-focus-bg: #4a5568;
    --app-hover-bg: #374151;
    --app-keyword-bg: #4a5568;
    --app-keyword-text: #e2e8f0;
    --app-mention-bg: #744210;
    --app-code-bg: #4a5568;
    --app-code-color: #f687b3;
    --app-nav-bg: #2d3748;
    --app-slide-tab-bg: #2d3748;
    --app-slide-tab-hover-bg: #4a5568;
    --app-active-bg: #2a4365;
    --app-active-border: #63b3ed;
    --app-active-text: #90cdf4;
    --app-domain-header-gradient: linear-gradient(135deg, #2a4365, #4a5568);
    --app-competitor-header-bg: #2d3748;
    --app-competitor-header-hover: #4a5568;
    --app-known-yes-bg: #22543d;
    --app-known-no-bg: #742a2a;
    --app-main-domain-row-bg: #2a4365;
    --app-rank-other-bg: #4a5568;
    --app-rank-other-color: #e2e8f0;
    --app-log-border: #4a5568;
    --app-table-odd-bg: #2d3748;
    --app-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
}

body {
    background-color: var(--app-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--app-text);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.3rem;
}

.navbar-brand small {
    font-size: 0.7rem;
    font-weight: 400;
}

/* Theme Toggle */
#btnThemeToggle {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

#btnThemeToggle:hover {
    color: #fff;
}

/* Cards */
.card {
    border: none;
    border-radius: 0.75rem;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem var(--app-card-hover-shadow) !important;
}

.card-header {
    border-radius: 0.75rem 0.75rem 0 0 !important;
    font-weight: 600;
}

/* Question Items */
.question-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--app-border);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--app-card-bg);
    transition: background 0.15s;
}

.question-item:hover {
    background: var(--app-hover-bg);
}

.question-item .question-text {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    padding: 0.25rem;
    width: 100%;
    color: var(--app-text);
}

.question-item .question-text:focus {
    outline: none;
    background: var(--app-input-focus-bg);
    border-radius: 0.25rem;
}

.question-item .badge {
    font-size: 0.7rem;
    font-weight: 500;
}

.question-item .btn-remove {
    color: #e53e3e;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0.25rem;
    font-size: 1.1rem;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.question-item .btn-remove:hover {
    opacity: 1;
}

/* Provider Checkboxes */
.provider-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 2px solid var(--app-border);
    border-radius: 0.5rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.provider-check:hover {
    border-color: var(--app-border-hover);
}

.provider-check.active {
    border-color: var(--app-active-border);
    background: var(--app-active-bg);
}

.provider-check.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.provider-check input[type="checkbox"] {
    display: none;
}

.provider-item .model-select {
    border-color: var(--app-border);
    font-size: 0.8rem;
    transition: all 0.2s;
}

.provider-item .model-select:focus {
    border-color: var(--app-active-border);
    box-shadow: 0 0 0 0.15rem rgba(49, 130, 206, 0.25);
}

/* Progress Log */
#progressLog .log-entry {
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--app-log-border);
}

#progressLog .log-entry:last-child {
    border-bottom: none;
}

#progressLog .log-entry .badge {
    font-size: 0.7rem;
    min-width: 60px;
    text-align: center;
}

/* Keyword Cloud */
.keyword-tag {
    padding: 0.35rem 0.75rem;
    border-radius: 2rem;
    background: var(--app-keyword-bg);
    color: var(--app-keyword-text);
    font-size: 0.85rem;
    transition: all 0.15s;
    display: flex;
    align-items: center;
}

.keyword-tag:hover {
    background: #3182ce;
    color: #fff;
}

.keyword-tag.size-lg {
    font-size: 1.1rem;
    padding: 0.4rem 1rem;
    font-weight: 600;
}

.keyword-tag.size-md {
    font-size: 0.95rem;
    padding: 0.35rem 0.85rem;
}

/* Removable Keyword Tags */
.keyword-tag.removable {
    cursor: pointer;
    padding-right: 0.4rem;
    position: relative;
}

.keyword-tag.removable:hover {
    padding-right: 0.4rem;
}

.keyword-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.3rem;
    font-size: 0.85em;
    opacity: 0.4;
    transition: opacity 0.15s;
    line-height: 1;
    vertical-align: middle;
}

.keyword-tag.removable:hover .keyword-remove {
    opacity: 1;
}

.competitor-card .comp-keywords .keyword-tag .keyword-remove {
    font-size: 0.75em;
    margin-left: 0.2rem;
}

/* Mention Highlight */
.mention-highlight {
    background: var(--app-mention-bg);
    padding: 0.1rem 0.25rem;
    border-radius: 0.2rem;
    font-weight: 600;
}

/* AI Answer Markdown Rendering */
.ai-answer-rendered a {
    color: #0d6efd;
    text-decoration: underline;
    word-break: break-all;
}

.ai-answer-rendered a:hover {
    color: #0a58ca;
}

.ai-answer-rendered ol,
.ai-answer-rendered ul {
    margin-bottom: 0.5rem;
}

.ai-answer-rendered li {
    margin-bottom: 0.15rem;
}

.ai-answer-rendered h5,
.ai-answer-rendered h6 {
    font-size: 1rem;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.ai-answer-rendered code.md-code {
    background: var(--app-code-bg);
    padding: 0.1rem 0.35rem;
    border-radius: 0.2rem;
    font-size: 0.875em;
    color: var(--app-code-color);
}

.pdf-answer-content a {
    color: #0d6efd;
    text-decoration: underline;
}

.pdf-answer-content ol,
.pdf-answer-content ul {
    margin-bottom: 0.25rem;
    padding-left: 1.25rem;
}

/* Sentiment Badges */
.sentiment-positive {
    color: #38a169;
}

.sentiment-neutral {
    color: var(--app-text-muted);
}

.sentiment-negative {
    color: #e53e3e;
}

/* Slideshow */
.slide-panel {
    display: none;
}

.slide-panel.active {
    display: block;
    animation: slideFadeIn 0.3s ease-out;
}

@keyframes slideFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#slideshowNav {
    background: var(--app-nav-bg);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    box-shadow: var(--app-shadow-sm);
}

.slide-tab {
    padding: 0.4rem 1rem;
    border: 2px solid var(--app-border);
    border-radius: 0.5rem;
    background: var(--app-slide-tab-bg);
    color: var(--app-text);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}

.slide-tab:hover {
    border-color: var(--app-border-hover);
    background: var(--app-slide-tab-hover-bg);
}

.slide-tab.active {
    border-color: var(--app-active-border);
    background: var(--app-active-bg);
    color: var(--app-active-text);
}

/* Recognition cards (generic selectors for all slides) */
.recognition-card {
    transition: all 0.4s ease;
}

.recognition-card.known-yes {
    background: var(--app-known-yes-bg);
    border-left: 4px solid #38a169 !important;
}

.recognition-card.known-no {
    background: var(--app-known-no-bg);
    border-left: 4px solid #e53e3e !important;
}

/* Stat cards */
.card-title {
    color: var(--app-text);
}

/* Detail table */
#detailTable td {
    vertical-align: middle;
}

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Fixed-height chart body for side-by-side doughnut charts */
.chart-body-fixed {
    height: var(--chart-pie-height);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-body-fixed canvas {
    max-height: 100%;
    max-width: 100%;
}

/* GEO Score Gauge */
.geo-gauge-wrapper {
    position: relative;
    width: 200px;
    height: 120px;
}

.geo-gauge-svg {
    width: 100%;
    height: 100%;
}

.geo-gauge-arc {
    transition: stroke-dasharray 1s ease-out, stroke 0.5s ease;
}

.geo-gauge-value {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

.geo-score-number {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1;
}

.geo-grade-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    background: #a0aec0;
    margin-top: 0.25rem;
}

.geo-grade-badge.grade-A {
    background: #38a169;
}

.geo-grade-badge.grade-B {
    background: #3182ce;
}

.geo-grade-badge.grade-C {
    background: #d69e2e;
}

.geo-grade-badge.grade-D {
    background: #dd6b20;
}

.geo-grade-badge.grade-F {
    background: #e53e3e;
}

.geo-breakdown-item {
    margin-bottom: 0.75rem;
}

.geo-breakdown-item .d-flex {
    font-size: 0.85rem;
}

.geo-breakdown-item .progress {
    height: 8px;
    border-radius: 4px;
}

.geo-composition-table {
    font-size: 0.82rem;
}

.geo-composition-table th,
.geo-composition-table td {
    padding: 0.35rem 0.5rem;
}

/* Info Tooltips */
.info-tooltip {
    font-size: 0.7em;
    opacity: 0.5;
    cursor: help;
    vertical-align: middle;
    transition: opacity 0.15s;
}

.info-tooltip:hover {
    opacity: 1;
}

/* Domain Navigation Tabs */
#domainNav {
    background: var(--app-nav-bg);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    box-shadow: var(--app-shadow-sm);
}

#domainTabs .nav-link {
    padding: 0.4rem 1rem;
    border: 2px solid var(--app-border);
    border-radius: 0.5rem;
    background: var(--app-slide-tab-bg);
    color: var(--app-text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 0.35rem;
    transition: all 0.15s;
}

#domainTabs .nav-link:hover {
    border-color: var(--app-border-hover);
    background: var(--app-slide-tab-hover-bg);
}

#domainTabs .nav-link.active {
    border-color: var(--app-active-border);
    background: var(--app-active-bg);
    color: var(--app-active-text);
}

#domainTabs .nav-link .badge {
    font-size: 0.65rem;
}

/* Domain Group Headers in Question List */
.domain-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    margin-top: 0.75rem;
    background: var(--app-domain-header-gradient);
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--app-text);
    border-left: 4px solid #3182ce;
}

.domain-group-header:first-child {
    margin-top: 0;
}

.domain-group-header .badge {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Domain Comparison Table */
#domainComparisonTable .rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}

#domainComparisonTable .rank-1 {
    background: linear-gradient(135deg, #f6e05e, #d69e2e);
}

#domainComparisonTable .rank-2 {
    background: linear-gradient(135deg, #cbd5e0, #a0aec0);
}

#domainComparisonTable .rank-3 {
    background: linear-gradient(135deg, #ed8936, #c05621);
}

#domainComparisonTable .rank-other {
    background: var(--app-rank-other-bg);
    color: var(--app-rank-other-color);
}

#domainComparisonTable .main-domain-row {
    background: var(--app-main-domain-row-bg);
}

#domainComparisonTable .main-domain-row td {
    font-weight: 600;
}

/* Domain Section Container */
.domain-section {
    display: none;
}

.domain-section.active {
    display: block;
    animation: slideFadeIn 0.3s ease-out;
}

/* Competitor Cards */
.competitor-card {
    border: 1px solid var(--app-border);
    border-radius: 0.5rem;
}

.competitor-card .card-header {
    background: var(--app-competitor-header-bg);
    border-radius: 0.5rem 0.5rem 0 0 !important;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.competitor-card .card-header:hover {
    background: var(--app-competitor-header-hover);
}

.competitor-card .card-body {
    padding: 0.75rem;
    font-size: 0.85rem;
}

.competitor-card .form-label {
    font-size: 0.75rem;
    color: var(--app-text-muted);
}

.competitor-card .form-control-sm {
    font-size: 0.8rem;
}

.competitor-card .comp-keywords .keyword-tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
}

.competitor-card .comp-keywords .keyword-tag.size-lg {
    font-size: 0.85rem;
    padding: 0.25rem 0.65rem;
}

.competitor-card .comp-keywords .keyword-tag.size-md {
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #slideshowNav .d-flex {
        flex-direction: column;
        gap: 0.5rem;
    }

    #slideshowNav #slideTabs {
        order: -1;
    }

    .slide-tab {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    #btnPrevSlide,
    #btnNextSlide {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

/* Recommendation Cards */
.recommendation-card {
    border-left: 4px solid var(--bs-info);
    transition: all 0.2s ease;
}

.recommendation-card:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
}

.recommendation-card[data-category="content"] {
    border-left-color: var(--bs-primary);
}

.recommendation-card[data-category="technical"] {
    border-left-color: var(--bs-success);
}

.recommendation-card[data-category="strategy"] {
    border-left-color: var(--bs-warning);
}

.recommendation-card[data-category="monitoring"] {
    border-left-color: var(--bs-info);
}

#recommendationsFilterBar .btn.active {
    font-weight: 600;
}

#recommendationsList ol {
    margin-bottom: 0;
}

#recommendationsList ol li {
    line-height: 1.6;
}

/* --- Prompt Editor Modal --- */
#promptEditorModal .modal-dialog {
    max-width: 800px;
}

#promptEditorModal .prompt-textarea {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    min-height: 400px;
    resize: vertical;
    white-space: pre-wrap;
    tab-size: 2;
}

#promptEditorModal .prompt-meta {
    font-size: 0.8rem;
}

.btn-prompt-editor {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1;
    border-radius: 0.25rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-prompt-editor:hover {
    opacity: 1;
}

/* --- User Guide Modal --- */
#userGuideModal .modal-dialog {
    max-width: 820px;
}

#userGuideModal .modal-body {
    max-height: 75vh;
    overflow-y: auto;
    padding: 1.5rem 2rem;
}

.guide-nav {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-card-bg, #fff);
}

.guide-nav .btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
}

.guide-nav .btn.active {
    font-weight: 600;
}

.guide-section {
    display: none;
}

.guide-section.active {
    display: block;
}

.guide-section h5 {
    color: var(--app-active-border, #3182ce);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--app-active-border, #3182ce);
}

.guide-section h6 {
    margin-top: 1.2rem;
    margin-bottom: 0.5rem;
}

.guide-step {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--app-hover-bg, #f8fafc);
    border-left: 3px solid var(--app-active-border, #3182ce);
}

.guide-step-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--app-active-border, #3182ce);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.guide-step-content {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.6;
}

.guide-step-content strong {
    color: var(--app-text, #2d3748);
}

.guide-tip {
    padding: 0.6rem 0.8rem;
    border-radius: 0.4rem;
    background: #ebf8ff;
    border-left: 3px solid #3182ce;
    font-size: 0.85rem;
    margin: 0.75rem 0;
}

[data-bs-theme="dark"] .guide-tip {
    background: #1a365d;
}

.guide-kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.78rem;
    border-radius: 3px;
    border: 1px solid var(--app-border, #e2e8f0);
    background: var(--app-keyword-bg, #edf2f7);
    font-family: monospace;
}

#btnUserGuide {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

#btnUserGuide:hover {
    color: #fff;
}
