/**
 * AI Dashboard — unified dark theme (slate)
 * ใช้กับ AIPA, DRAI และหน้าที่ embed ใน iframe
 */
:root {
    --d-bg: #020617;
    --d-bg-header: rgba(15, 23, 42, 0.92);
    --d-surface: #0f172a;
    --d-surface-2: #1e293b;
    --d-surface-3: #334155;
    --d-border: #334155;
    --d-border-soft: #1e293b;
    --d-text: #f1f5f9;
    --d-text-muted: #94a3b8;
    --d-text-dim: #64748b;
    --d-heading: #e2e8f0;
    --d-positive: #34d399;
    --d-negative: #f87171;
    --d-warn: #fbbf24;
    --d-focus: #64748b;
}

body.ai-dash-theme,
body.drai-theme {
    background-color: var(--d-bg);
    color: var(--d-text);
}

/* ── Forms ── */
.filter-input {
    width: 100%;
    background: var(--d-surface-2);
    border: 1px solid var(--d-border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--d-text);
    font-size: 0.875rem;
}
.filter-input:focus {
    outline: none;
    border-color: var(--d-focus);
}
.filter-input::placeholder {
    color: var(--d-text-dim);
}

/* ── Buttons ── */
.drai-btn,
.ai-dash-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.5rem;
    background: var(--d-surface-3);
    color: var(--d-text);
    border: 1px solid var(--d-border);
    transition: background-color 0.15s, border-color 0.15s;
    text-decoration: none;
}
.drai-btn:hover,
.ai-dash-btn:hover {
    background: #475569;
    border-color: #475569;
    color: var(--d-text);
}

/* ── Shared nav (AIPA / DRAI / THAISTOCKAI) ── */
.ai-dash-nav {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.125rem;
    padding: 0.2rem;
    background: var(--d-surface-2);
    border: 1px solid var(--d-border);
    border-radius: 0.5rem;
}
.ai-dash-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--d-text-muted);
    text-decoration: none;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.ai-dash-nav-link:hover {
    color: var(--d-text);
    background: var(--d-surface-3);
}
.ai-dash-nav-link.is-active {
    color: var(--d-text);
    background: var(--d-surface-3);
    border-color: var(--d-border);
    font-weight: 600;
}

.drai-btn-action,
.ai-dash-btn-action {
    background: var(--d-surface-3);
    border: 1px solid #475569;
    color: var(--d-text);
}
.drai-btn-action:hover,
.ai-dash-btn-action:hover {
    background: #475569;
}

/* ── Panels / Tailwind overrides ── */
.ai-dash-theme .drai-panel,
.ai-dash-theme .bg-slate-900,
.drai-theme .drai-panel,
.drai-theme .bg-slate-900 {
    background-color: var(--d-surface) !important;
}

.ai-dash-theme .border-slate-800,
.ai-dash-theme .border-purple-900\/40,
.drai-theme .border-slate-800,
.drai-theme .border-purple-900\/40 {
    border-color: var(--d-border-soft) !important;
}

.ai-dash-theme .bg-slate-800\/50,
.ai-dash-theme .bg-slate-800,
.ai-dash-theme thead.bg-slate-800\/50 th,
.drai-theme .bg-slate-800\/50,
.drai-theme .bg-slate-800,
.drai-theme thead.bg-slate-800\/50 th {
    background-color: var(--d-surface-2) !important;
}

.ai-dash-theme .text-emerald-400,
.ai-dash-theme .text-emerald-300,
.ai-dash-theme .text-purple-300,
.ai-dash-theme .text-blue-300,
.ai-dash-theme .text-blue-400,
.ai-dash-theme .text-indigo-300,
.ai-dash-theme .text-amber-400,
.drai-theme .text-emerald-400,
.drai-theme .text-emerald-300,
.drai-theme .text-purple-300,
.drai-theme .text-blue-300,
.drai-theme .text-blue-400,
.drai-theme .text-indigo-300,
.drai-theme .text-amber-400 {
    color: var(--d-heading) !important;
}

.ai-dash-theme a.text-blue-400,
.ai-dash-theme .text-blue-400.underline,
.drai-theme a.text-blue-400 {
    color: var(--d-text-muted) !important;
}
.ai-dash-theme a.text-blue-400:hover,
.drai-theme a.text-blue-400:hover {
    color: var(--d-text) !important;
}

.ai-dash-theme .bg-gray-900,
.ai-dash-theme .bg-gray-800 {
    background-color: var(--d-surface) !important;
}
.ai-dash-theme .border-gray-800,
.ai-dash-theme .border-gray-700 {
    border-color: var(--d-border-soft) !important;
}
.ai-dash-theme .text-gray-300,
.ai-dash-theme .text-gray-400 {
    color: var(--d-text-muted) !important;
}

/* ── Light Tailwind → dark (paport, dailynews, aiadvisepa) ── */
.ai-dash-theme .bg-white {
    background-color: var(--d-surface) !important;
}
.ai-dash-theme .bg-gray-50,
.ai-dash-theme .bg-slate-50 {
    background-color: var(--d-surface-2) !important;
}
.ai-dash-theme .bg-slate-100,
.ai-dash-theme .bg-gray-100 {
    background-color: var(--d-surface-2) !important;
}
.ai-dash-theme .bg-amber-50,
.ai-dash-theme .bg-amber-100 {
    background-color: rgba(30, 41, 59, 0.85) !important;
}
.ai-dash-theme .bg-blue-50,
.ai-dash-theme .bg-indigo-50,
.ai-dash-theme .bg-indigo-50\/50 {
    background-color: var(--d-surface-2) !important;
}
.ai-dash-theme .bg-red-50 {
    background-color: rgba(127, 29, 29, 0.25) !important;
}
.ai-dash-theme .bg-indigo-100 {
    background-color: var(--d-surface-2) !important;
}

.ai-dash-theme .text-slate-800,
.ai-dash-theme .text-slate-700,
.ai-dash-theme .text-slate-900,
.ai-dash-theme .text-gray-800 {
    color: var(--d-text) !important;
}
.ai-dash-theme .text-slate-600,
.ai-dash-theme .text-slate-500,
.ai-dash-theme .text-slate-400 {
    color: var(--d-text-muted) !important;
}
.ai-dash-theme .text-blue-800,
.ai-dash-theme .text-blue-600,
.ai-dash-theme .text-indigo-900,
.ai-dash-theme .text-indigo-600,
.ai-dash-theme .text-indigo-300 {
    color: var(--d-text-muted) !important;
}

.ai-dash-theme .border-gray-100,
.ai-dash-theme .border-slate-100,
.ai-dash-theme .border-slate-200,
.ai-dash-theme .border-gray-200,
.ai-dash-theme .border-amber-200,
.ai-dash-theme .border-indigo-100,
.ai-dash-theme .border-blue-200,
.ai-dash-theme .border-indigo-200 {
    border-color: var(--d-border) !important;
}

.ai-dash-theme .bg-blue-600,
.ai-dash-theme .bg-indigo-600 {
    background-color: var(--d-surface-3) !important;
    color: var(--d-text) !important;
    box-shadow: none !important;
}
.ai-dash-theme .hover\:bg-blue-500:hover,
.ai-dash-theme .hover\:bg-indigo-500:hover,
.ai-dash-theme .hover\:bg-indigo-700:hover {
    background-color: #475569 !important;
}

.ai-dash-theme .shadow-blue-200,
.ai-dash-theme .shadow-indigo-200,
.ai-dash-theme .ring-blue-600 {
    box-shadow: none !important;
    --tw-ring-color: var(--d-border) !important;
}

.ai-dash-theme tr.hover\:bg-slate-50:hover,
.ai-dash-theme .hover\:bg-slate-50:hover {
    background-color: rgba(51, 65, 85, 0.45) !important;
}

.ai-dash-theme .text-emerald-600,
.ai-dash-theme .text-emerald-700 {
    color: var(--d-positive) !important;
}
.ai-dash-theme .bg-emerald-100 {
    background-color: rgba(6, 78, 59, 0.35) !important;
}
.ai-dash-theme .text-red-500,
.ai-dash-theme .text-red-600,
.ai-dash-theme .text-red-800 {
    color: var(--d-negative) !important;
}
.ai-dash-theme .bg-red-100 {
    background-color: rgba(127, 29, 29, 0.3) !important;
}

.ai-dash-theme .from-indigo-50 {
    --tw-gradient-from: var(--d-surface) var(--tw-gradient-from-position) !important;
}
.ai-dash-theme .to-white {
    --tw-gradient-to: var(--d-surface-2) var(--tw-gradient-to-position) !important;
}
.ai-dash-theme .from-slate-50 {
    --tw-gradient-from: var(--d-surface-2) var(--tw-gradient-from-position) !important;
}

.ai-dash-theme #searchInput {
    background-color: var(--d-surface-2) !important;
    color: var(--d-text) !important;
    border-color: var(--d-border) !important;
}
.ai-dash-theme #searchInput::placeholder {
    color: var(--d-text-dim) !important;
}
.ai-dash-theme #searchBtn {
    background-color: var(--d-surface-3) !important;
    border: 1px solid var(--d-border);
}
.ai-dash-theme #searchBtn:hover {
    background-color: #475569 !important;
}

/* ── Markdown ── */
.ai-dash-theme .ai-markdown,
.ai-dash-theme .markdown-content {
    line-height: 1.65;
    color: var(--d-text-muted);
}
.ai-dash-theme .ai-markdown h3,
.ai-dash-theme .ai-markdown h4,
.ai-dash-theme .markdown-content strong {
    color: var(--d-heading);
    font-weight: 600;
}
.ai-dash-theme .ai-markdown strong {
    color: var(--d-text);
}
.ai-dash-theme .ai-markdown blockquote,
.ai-dash-theme .markdown-content blockquote {
    border-left-color: var(--d-border);
    color: var(--d-text-dim);
}

/* ── Table / UI bits ── */
.drai-symbol,
.ai-dash-symbol {
    color: var(--d-heading);
    font-weight: 500;
}
.drai-mono-muted,
.ai-dash-mono {
    color: var(--d-text-muted);
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
}

.drai-ai-btn,
.ai-dash-ai-btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background: var(--d-surface-3);
    color: var(--d-text);
    border: 1px solid var(--d-border);
}
.drai-ai-btn:hover,
.ai-dash-ai-btn:hover {
    background: #475569;
}

.ai-dash-theme input[type="checkbox"],
.ai-dash-theme .accent-purple-500,
.ai-dash-theme .accent-emerald-500,
.ai-dash-theme .accent-blue-500,
.drai-theme input[type="checkbox"],
.drai-theme .accent-purple-500 {
    accent-color: var(--d-focus);
}

.ai-dash-theme .view-tab-active,
.drai-theme .view-tab-active {
    color: var(--d-text) !important;
    border-bottom-color: var(--d-text-muted) !important;
}

.ai-dash-theme .ajax-status,
.drai-theme .ajax-status {
    color: var(--d-positive);
}

.ai-dash-theme .bb-gear-btn:hover,
.drai-theme .bb-gear-btn:hover {
    background: var(--d-surface-3);
    border-color: var(--d-border);
    color: var(--d-text);
}

.ai-dash-theme .bb-cat-title,
.drai-theme .bb-cat-title {
    color: var(--d-text-muted);
}

.ai-dash-theme .bb-modal-header,
.ai-dash-theme .bb-modal-footer,
.drai-theme .bb-modal-header,
.drai-theme .bb-modal-footer {
    background: var(--d-surface-2);
}

/* Scrollbar */
.ai-dash-theme ::-webkit-scrollbar,
.drai-theme ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.ai-dash-theme ::-webkit-scrollbar-track,
.drai-theme ::-webkit-scrollbar-track {
    background: var(--d-bg);
}
.ai-dash-theme ::-webkit-scrollbar-thumb,
.drai-theme ::-webkit-scrollbar-thumb {
    background: var(--d-surface-3);
    border-radius: 4px;
}
.ai-dash-theme ::-webkit-scrollbar-thumb:hover,
.drai-theme ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ── Embed ใน AIPA index (ข่าว / iframe) ── */
.ai-dash-embed,
.ai-dash-embed .dailynews-root,
#news-content {
    background-color: var(--d-bg) !important;
    color: var(--d-text);
}

.ai-dash-embed .bg-white,
#news-content .bg-white,
.ai-dash-embed .bg-slate-50,
.ai-dash-embed .bg-orange-50,
.ai-dash-embed .bg-indigo-50,
.ai-dash-embed .bg-emerald-50,
#news-content .bg-slate-50,
#news-content .bg-slate-100,
#news-content .bg-indigo-50,
#news-content .bg-indigo-50\/50,
#news-content .bg-orange-50,
#news-content .bg-emerald-50 {
    background-color: var(--d-surface) !important;
}

#news-content .border-slate-100,
#news-content .border-slate-200,
#news-content .border-indigo-100 {
    border-color: var(--d-border) !important;
}

#news-content .text-slate-800,
#news-content .text-slate-700,
#news-content .text-slate-900 {
    color: var(--d-text) !important;
}

/* สีข่าวแต่ละส่วน — ไม่ให้ override รวมเป็นสีเดียว */
.dailynews-root .news-sec-market .text-sky-100,
.dailynews-root .news-sec-market .text-sky-200,
.dailynews-root .news-sec-market .text-sky-300,
#news-content .news-sec-market .text-sky-100,
#news-content .news-sec-market .text-sky-200,
#news-content .news-sec-market .text-sky-300 {
    color: #7dd3fc !important;
}
.dailynews-root .news-sec-market .text-sky-50,
#news-content .news-sec-market .text-sky-50,
.dailynews-root .news-sec-market .text-sky-100 {
    color: #e0f2fe !important;
}
.dailynews-root .news-sec-highlight .text-amber-100,
.dailynews-root .news-sec-highlight .text-amber-200,
.dailynews-root .news-sec-highlight .text-amber-50,
#news-content .news-sec-highlight .text-amber-100,
#news-content .news-sec-highlight .text-amber-200 {
    color: #fde68a !important;
}
.dailynews-root .news-sec-stock .text-violet-100,
.dailynews-root .news-sec-stock .text-violet-300,
#news-content .news-sec-stock .text-violet-100,
#news-content .news-sec-stock .text-violet-300 {
    color: #c4b5fd !important;
}
.dailynews-root .news-sec-stock .text-emerald-300,
#news-content .news-sec-stock .text-emerald-300 {
    color: #6ee7b7 !important;
}
.dailynews-root .news-sec-intro .text-slate-200,
#news-content .news-sec-intro .text-slate-200 {
    color: #e2e8f0 !important;
}

.ai-dash-theme .bg-orange-50,
.ai-dash-theme .bg-orange-100,
.ai-dash-theme .bg-emerald-50,
.ai-dash-theme .border-orange-100,
.ai-dash-theme .border-red-100 {
    background-color: var(--d-surface-2) !important;
    border-color: var(--d-border) !important;
}

.ai-dash-theme .text-orange-600,
.ai-dash-theme .text-orange-700,
.ai-dash-theme .text-amber-700,
.ai-dash-theme .text-amber-900 {
    color: var(--d-text-muted) !important;
}

.ai-dash-theme .ring-offset-2,
.ai-dash-theme .ring-offset-slate-950 {
    --tw-ring-offset-color: var(--d-bg) !important;
}

.ai-dash-theme .focus\:bg-white:focus,
.ai-dash-theme .focus\:ring-indigo-500:focus {
    background-color: var(--d-surface-2) !important;
    --tw-ring-color: var(--d-focus) !important;
}

.ai-dash-theme #root {
    background-color: var(--d-bg);
    min-height: 100%;
}

.ai-dash-theme p:not(.news-line):not(.news-stock-desc),
.ai-dash-theme li,
.ai-dash-theme .markdown-content p,
.ai-dash-theme .markdown-render p {
    color: inherit;
}

.ai-dash-theme .ai-markdown,
.ai-dash-theme .ai-markdown p,
.ai-dash-theme .ai-markdown li,
.ai-dash-theme .ai-markdown ul,
.ai-dash-theme .ai-markdown ol {
    background-color: transparent !important;
    color: var(--d-text-muted);
}
.ai-dash-theme .ai-markdown strong {
    color: var(--d-heading);
}
.ai-dash-theme .ai-markdown pre,
.ai-dash-theme .ai-markdown code {
    background-color: var(--d-surface-2) !important;
    color: var(--d-text);
    border: 1px solid var(--d-border);
}
.ai-dash-theme .ai-markdown table,
.ai-dash-theme .ai-markdown th,
.ai-dash-theme .ai-markdown td {
    background-color: var(--d-surface) !important;
    border-color: var(--d-border) !important;
    color: var(--d-text-muted);
}
