/* ==========================================================================
   Admin UI Overhaul (Dark Tech Theme) - v2.3
   Multi-dimensional Dark Hierarchy
   ========================================================================== */

:root {
    --bg-page: #030303;
    --bg-panel: #111118;
    --bg-input: #050505;
    --bg-sidebar: #0E0E15;
    --text-main: #f4f4f5; /* zinc-100 */
    --text-muted: #a1a1aa; /* zinc-400 */
    --text-placeholder: #71717a; /* zinc-500 */
    --border-panel: rgba(255, 255, 255, 0.05);
    --border-input: rgba(255, 255, 255, 0.1);
    --primary-blue: #8b5cf6;
}

/* 1. Global Backgrounds & Text */
body, #app, .page {
    background-color: var(--bg-page) !important;
    color: var(--text-main) !important;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-main) !important;
}

p, span, div, li {
    color: var(--text-muted);
}

/* Global Text Overrides - Force zinc-100 for all main text */
.text-gray-900, .text-slate-900, .text-zinc-900, .text-black {
    color: var(--text-main) !important;
}

.user-info {
    overflow: visible !important;
    z-index: 30;
}

.user-badge,
#username {
    color: #e4e4e7 !important;
}

/* 2. Panel Layer (Content Containers) - Deep Blue-Black #111118 */
.input-panel, .output-panel, .card, .panel, .form-section, 
.agent-chat-card, .login-card, 
.agent-card-v2, .admin-content, .agent-workspace, .admin-card-wide, 
.query-section {
    background-color: var(--bg-panel) !important;
    border: 1px solid var(--border-panel) !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border-radius: 10px !important;
}

/* 3. Input Layer - Pure Ink Black #050505 */
input[type="text"], input[type="password"], input[type="email"], 
input[type="number"], input[type="tel"], input[type="date"], 
textarea, select {
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-input) !important;
    color: var(--text-main) !important;
    border-radius: 8px !important;
    transition: all 0.2s ease;
}

input::placeholder, textarea::placeholder {
    color: var(--text-placeholder) !important;
}

/* Focus State - Soft Violet Glow */
input:focus, textarea:focus, select:focus {
    border-color: rgba(139, 92, 246, 0.5) !important; /* violet-500/50 */
    background-color: var(--bg-input) !important;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2) !important; /* ring-2 violet-500/20 */
    outline: none !important;
}

/* Labels & Descriptions */
label, .form-text, .hint, .description, .help-text {
    color: var(--text-muted) !important;
}

/* 4. Agent Tuning Page Specifics */
/* Sidebar Background */
.sidebar, .admin-sidebar, #agent-tuning-sidebar {
    background-color: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-panel) !important;
}

/* Selected Item Style */
.sidebar-item.active, .nav-item.active, .agent-tune-item.active {
    background-color: rgba(139, 92, 246, 0.2) !important; /* bg-violet-600/20 */
    color: #e5deff !important; /* text-violet-100/200 */
    border: 1px solid rgba(139, 92, 246, 0.3) !important; /* border-violet-500/30 */
    box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.1) !important; /* 内发光 */
}

/* 5. Customer Management Page Specifics */
/* Table Header */
thead, th, .table-header {
    background-color: transparent !important;
    color: var(--text-placeholder) !important; /* text-zinc-500 */
    text-transform: uppercase !important;
    font-size: 0.75rem !important; /* text-xs */
    font-weight: 600 !important;
    letter-spacing: 0.05em !important;
    border-bottom: 1px solid var(--border-panel) !important;
}

td {
    border-bottom: 1px solid var(--border-panel) !important;
    color: var(--text-muted) !important;
}

.admin-content tr:hover,
.admin-table-row:hover,
.datatable-row:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
    transition: background-color 0.2s ease !important;
}

.admin-content tr:hover td,
.admin-table-row:hover td,
.datatable-row:hover td {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

.admin-content tr.selected,
.admin-content tr.active {
    background-color: rgba(139, 92, 246, 0.15) !important;
    border-left: 2px solid #8b5cf6 !important;
}

.admin-content tr.selected td,
.admin-content tr.active td {
    background-color: rgba(139, 92, 246, 0.15) !important;
    color: #ffffff !important;
}

/* Ghost Buttons (Semi-transparent bg + bright text) */
.btn-secondary, .btn-action, .btn-ghost {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-main) !important;
    border-radius: 8px !important;
    transition: all 0.2s ease !important;
}

.btn-secondary:hover, .btn-action:hover, .btn-ghost:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* 6. Modals & Dialogs - Deep Dark Glass */
.modal-content, .dialog, .popup, .modal-dialog {
    background-color: rgba(18, 18, 26, 0.9) !important; /* #12121A/90 */
    backdrop-filter: blur(40px) !important; /* backdrop-blur-2xl */
    -webkit-backdrop-filter: blur(40px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5) !important;
    border-radius: 16px !important;
}

/* 7. Back Button - Minimal Text Link */
.btn-back, .back-link {
    background: transparent !important;
    border: none !important;
    color: var(--text-placeholder) !important; /* text-zinc-500 */
    padding: 8px 0 !important;
    box-shadow: none !important;
    transition: color 0.2s ease !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-back:hover, .back-link:hover {
    color: #ffffff !important;
    background: transparent !important;
}

/* 8. Toast UI Editor Overrides & Agent Tuning Fixes */
#tui-editor-container {
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-panel) !important;
    border-radius: 12px;
    overflow: visible;
}

.toastui-editor-defaultUI {
    background-color: var(--bg-panel) !important;
    border: none !important;
}

/* Toolbar - Dark Glass */
.toastui-editor-defaultUI-toolbar,
.toastui-editor-defaultUI .toastui-editor-toolbar {
    background-color: rgba(24, 24, 27, 0.88) !important; /* bg-[#18181B]/90 */
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 10px 10px 0 0 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    padding: 4px 8px 6px !important;
    min-height: 36px !important;
    align-items: flex-start !important;
}

.toastui-editor-defaultUI .te-toolbar-section {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 4px !important;
}

@media (max-width: 768px) {
    .toastui-editor-defaultUI-toolbar,
    .toastui-editor-defaultUI .toastui-editor-toolbar {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
    }
}

.toastui-editor-toolbar-icons {
    border-color: transparent !important;
    background-color: transparent !important;
    color: #a1a1aa !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 4px 6px !important;
    margin: 0 2px !important;
    height: 24px !important;
    border-radius: 0.375rem !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease, color 0.15s ease !important;
}

.toastui-editor-toolbar-icons:hover {
    background-color: rgba(139, 92, 246, 0.15) !important;
    color: #d8b4fe !important;
    border-color: transparent !important;
}

.toastui-editor-toolbar-icons[aria-pressed="true"] {
    background-color: rgba(139, 92, 246, 0.2) !important;
    color: #e5deff !important;
    border-color: transparent !important;
}

.toastui-editor-toolbar-icons:focus-visible {
    outline: none !important;
}

.toastui-editor-defaultUI .te-toolbar-section .active .toastui-editor-toolbar-icons {
    background-color: rgba(139, 92, 246, 0.18) !important;
    color: #e5deff !important;
}

.toastui-editor-defaultUI .toastui-editor-popup,
.toastui-editor-defaultUI .tui-popup,
.toastui-editor-popup,
.tui-popup {
    z-index: 120 !important;
    margin-top: 4px !important;
    overflow: visible !important;
}

/* Toolbar dividers */
.toastui-editor-defaultUI .te-toolbar-divider,
.toastui-editor-toolbar-divider,
.tui-toolbar-divider {
    width: 1px !important;
    height: 16px !important;
    margin: 0 6px !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
}

/* Editor Content Area - Deep Black #050505 & Monospace */
.toastui-editor-main, .toastui-editor-ww-container, .toastui-editor-md-container, 
.toastui-editor-main .toastui-editor-content {
    background-color: #050505 !important;
}

.ProseMirror, .toastui-editor-contents, .toastui-editor-md-preview {
    color: #e4e4e7 !important; /* zinc-200 */
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace !important;
    background-color: #050505 !important; 
}

/* Bottom Mode Switch Tabs */
.toastui-editor-mode-switch {
    background-color: #111118 !important;
    border-top: 1px solid var(--border-panel) !important;
}

.toastui-editor-mode-switch .tab-item {
    color: #71717a !important; /* zinc-500 */
    background: transparent !important;
    border: none !important;
}

.toastui-editor-mode-switch .tab-item.active {
    background-color: rgba(139, 92, 246, 0.25) !important; /* violet glass */
    color: #e5deff !important; /* soft violet text */
}

/* Agent Tuning Sidebar Items */
.agent-tune-item:hover {
    border-color: rgba(255, 255, 255, 0.12) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.agent-tune-item.active {
    background-color: rgba(139, 92, 246, 0.2) !important; /* 与顶部选中态保持一致 */
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.1) !important;
}

/* 9. RenderDynamicIcon Compatibility */
.ph {
    vertical-align: middle;
    color: inherit; /* Ensure icons take parent text color */
}

/* Specific fix for primary buttons to keep them popping */
.btn-primary, #generate-btn, .btn-submit {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.25), rgba(79, 70, 229, 0.25)) !important;
    color: #e5deff !important;
    border: 1px solid rgba(139, 92, 246, 0.4) !important;
    border-radius: 9999px !important;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.2) !important;
    font-weight: 600 !important;
    letter-spacing: 1px !important;
    transition: all 0.3s ease !important;
}

.btn-primary:hover, #generate-btn:hover, .btn-submit:hover {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.4), rgba(79, 70, 229, 0.4)) !important;
    color: #ffffff !important;
    border-color: rgba(167, 139, 250, 0.8) !important;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.4) !important;
    transform: translateY(-2px) !important;
}

/* 10. Chat UI Overhaul (Dark Tech Theme) */
.agent-chat-card {
    background-color: #111118 !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5) !important;
    border-radius: 16px !important; /* rounded-2xl */
}

/* Toast UI Editor: 隐藏底部自带模式切换条 */
.tui-editor-defaultUI .te-mode-switch,
.toastui-editor-defaultUI .te-mode-switch,
.te-mode-switch,
.toastui-editor-defaultUI .toastui-editor-mode-switch,
.toastui-editor-mode-switch {
    display: none !important;
}

/* Header Text */
.agent-chat-title {
    color: #e4e4e7 !important; /* text-zinc-100 */
}

.agent-chat-subtitle {
    color: #71717a !important; /* text-zinc-500 */
}

/* Status Badge */
.agent-chat-status {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: #71717a !important; /* text-zinc-500 */
}

/* Clear History Button - Minimal Style */
.agent-chat-clear-btn {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: #71717a !important; /* text-zinc-500 */
    box-shadow: none !important;
    transition: all 0.2s ease !important;
}

.agent-chat-clear-btn:hover {
    color: #f87171 !important; /* text-red-400 */
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(248, 113, 113, 0.2) !important;
}

/* Message Area - Transparent to show container bg */
.agent-chat-messages {
    background-color: transparent !important;
    border: none !important;
}

/* AI Message / Tip */
.agent-chat-tip, .agent-chat-msg.ai {
    background-color: rgba(59, 130, 246, 0.1) !important; /* bg-blue-500/10 */
    border: 1px solid rgba(59, 130, 246, 0.2) !important; /* border-blue-500/20 */
    color: #e4e4e7 !important; /* text-zinc-200 */
    border-radius: 12px !important;
}

/* User Message */
.agent-chat-msg.user {
    background-color: rgba(39, 39, 42, 0.5) !important; /* bg-zinc-800/50 */
    color: #f4f4f5 !important; /* text-zinc-100 */
    border: none !important;
    border-radius: 12px !important;
}

/* Input Area Container - Match Chat Tone */
.agent-chat-input-bar {
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important; 
}

/* Input Box */
#agent-chat-input {
    background-color: #050505 !important; /* Input Layer */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #e4e4e7 !important; /* text-zinc-200 */
    border-radius: 12px !important;
}

#agent-chat-input:focus {
    border-color: rgba(59, 130, 246, 0.5) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
}

/* Send Button - Enhanced Hover */
#agent-chat-send {
    background: linear-gradient(to right, #3b82f6, #4f46e5) !important;
    color: white !important;
    border: none !important;
    border-radius: 9999px !important;
    transition: all 0.2s ease !important;
}

#agent-chat-send:hover {
    filter: brightness(1.1) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}

/* Icon Visibility in Chat */
.agent-chat-messages .ph, .agent-chat-header .ph {
    color: inherit !important;
}

/* 11. Admin Navigation Tabs - Dark Tech Overhaul */
/* Wrapper - Dark & Bordered */
.admin-tabs-wrapper {
    background-color: transparent !important;
    border-bottom: none !important;
    padding: 4px 0 !important;
}

/* Tabs Container - Transparent (remove capsule if desired, or keep as wrapper) */
/* User asked for "entire navigation container background... deep bg-[#09090B]" which applies to wrapper. */
/* The buttons themselves sit inside .admin-tabs. */
.admin-tabs {
    background: rgba(9, 9, 11, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35) !important;
    border-radius: 10px !important;
    padding: 6px 10px !important;
    gap: 6px !important;
}

/* Tab Button - Default Inactive State */
.tab-btn {
    background-color: transparent !important;
    color: #71717a !important; /* text-zinc-500 */
    border: none !important;
    border-radius: 9999px !important;
    font-weight: 500 !important;
    transition: all 0.3s ease !important;
    padding: 6px 14px !important;
}

.tab-btn:hover {
    color: #e4e4e7 !important; /* text-zinc-200 */
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Tab Button - Active State (Soft Violet Glow) */
.tab-btn.active {
    background-color: rgba(139, 92, 246, 0.18) !important; /* bg-violet-600/20 */
    color: #c4b5fd !important; /* text-violet-300 */
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35) !important; /* ring-1 ring-violet-500/30 */
}

/* === Global Editor Overrides from UX Spec === */
/* 强制修复编辑器提示框遮挡 */
.editor-toolbar,
.editor-toolbar-container {
    overflow: visible !important;
    z-index: 50 !important;
}

.tippy-box,
[role="tooltip"],
.tooltip {
    z-index: 99999 !important;
}

/* 强制抹杀编辑器默认的蓝色选中态和蓝光边框 */
.editor-toolbar button.active,
.editor-toolbar button.is-active,
input:focus,
textarea:focus {
    background-color: rgba(139, 92, 246, 0.15) !important;
    border-color: rgba(139, 92, 246, 0.4) !important;
    color: #d8b4fe !important;
    outline: none !important;
    box-shadow: none !important;
}

#agent-modal input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 4px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

#agent-modal input[type="checkbox"]:hover {
    border-color: rgba(139, 92, 246, 0.5) !important;
    background-color: rgba(255, 255, 255, 0.08);
}

#agent-modal input[type="checkbox"]:checked {
    background-color: rgba(139, 92, 246, 0.8);
    border-color: rgba(167, 139, 250, 0.8) !important;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

#agent-modal input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

#agent-modal select option {
    background-color: #111118;
    color: #f4f4f5;
    padding: 8px;
}

#ui-config-section input[type="text"] {
    font-size: 14px !important;
    min-height: 44px !important;
    padding: 8px 12px !important;
}
