/* ======================== 心理咨询工具 - 主题色：治愈绿 + 薰衣草紫 ======================== */
:root {
    --psy-primary: #5b9a8b;
    --psy-primary-light: #7ec8b6;
    --psy-primary-dark: #3d7a6c;
    --psy-accent: #9b8ec4;
    --psy-accent-light: #c4b8e8;
    --psy-warm: #e8b86d;
    --psy-bg: #f5f0eb;
    --psy-card-bg: #ffffff;
    --psy-text: #3a3a3a;
    --psy-text-secondary: #7a7a7a;
    --psy-border: #e2ddd8;
    --psy-hover: #eee8e0;
    --psy-shadow: rgba(91, 154, 139, 0.08);
    --psy-radius: 12px;
    --psy-radius-sm: 8px;
}

/* ======================== 暗黑模式 ======================== */
body.dark {
    --psy-primary: #7ec8b6;
    --psy-primary-light: #5b9a8b;
    --psy-primary-dark: #a3e0d0;
    --psy-accent: #c4b8e8;
    --psy-accent-light: #9b8ec4;
    --psy-warm: #e8b86d;
    --psy-bg: #1a1e24;
    --psy-card-bg: #242830;
    --psy-text: #e0dcd8;
    --psy-text-secondary: #9a968f;
    --psy-border: #363a42;
    --psy-hover: #2e3238;
    --psy-shadow: rgba(0, 0, 0, 0.3);
}

/* ======================== 主容器 ======================== */
.psy-container {
    background: var(--psy-bg);
    border-radius: var(--psy-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 12px var(--psy-shadow);
}

.psy-container.fullscreen {
    position: fixed;
    top: 0; left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
}

/* ======================== 工具栏 ======================== */
.psy-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--psy-primary) 0%, var(--psy-accent) 100%);
    border-bottom: none;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(91, 154, 139, 0.25);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.toolbar-title {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    margin-right: 8px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.toolbar-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.9);
    color: var(--psy-primary-dark);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.toolbar-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar-btn-primary {
    background: #fff;
    color: var(--psy-primary-dark);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.toolbar-btn-primary:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toolbar-btn-active {
    background: rgba(255,255,255,0.25);
    color: #fff;
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.4);
}

.toolbar-btn-active:hover {
    background: rgba(255,255,255,0.35);
    color: #fff;
    transform: translateY(-1px);
}

/* ======================== 三栏布局 ======================== */
.psy-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* 左栏 - 历史记录 */
.psy-history-panel {
    width: 220px;
    min-width: 220px;
    background: var(--psy-card-bg);
    border-right: 1px solid var(--psy-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--psy-border);
    background: linear-gradient(to bottom, var(--psy-card-bg), var(--psy-bg));
}

.history-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--psy-text);
}

.history-count {
    font-size: 11px;
    color: var(--psy-text-secondary);
    margin-left: 4px;
}

.history-clear-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.history-clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.history-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--psy-border);
}

.history-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--psy-border);
    border-radius: 6px;
    font-size: 12px;
    background: var(--psy-bg);
    color: var(--psy-text);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.history-search input:focus {
    border-color: var(--psy-primary);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.history-empty {
    text-align: center;
    color: var(--psy-text-secondary);
    font-size: 12px;
    padding: 30px 10px;
    line-height: 1.8;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--psy-radius-sm);
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.history-item:hover {
    background: var(--psy-hover);
    border-color: var(--psy-border);
}

.history-item.active {
    background: rgba(91, 154, 139, 0.1);
    border-color: var(--psy-primary);
    border-left: 3px solid var(--psy-primary);
}

.history-item.active .history-item-title {
    color: var(--psy-primary);
    font-weight: 600;
}

.history-item-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--psy-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.history-item-meta {
    font-size: 10px;
    color: var(--psy-text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item-category {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--psy-primary);
    color: #fff;
    opacity: 0.8;
}

.history-item-delete {
    display: none;
    background: none;
    border: none;
    color: #ef4444;
    font-size: 12px;
    cursor: pointer;
    padding: 0 4px;
}

.history-item:hover .history-item-delete {
    display: inline-block;
}

/* 中栏 - 输入面板 */
.psy-input-panel {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--psy-border);
}

.panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--psy-border);
    background: linear-gradient(to bottom, var(--psy-card-bg), var(--psy-bg));
}

.panel-header h3 {
    margin: 0 0 2px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--psy-text);
}

.panel-tip {
    font-size: 11px;
    color: var(--psy-accent);
    font-style: italic;
}

.psy-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--psy-bg);
}

/* 困扰类型选择 */
.psy-category-group {
    margin-bottom: 16px;
}

.psy-category-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--psy-text-secondary);
    display: block;
    margin-bottom: 8px;
}

.psy-category-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.psy-category-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--psy-border);
    background: var(--psy-card-bg);
    color: var(--psy-text);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.psy-category-option:hover {
    border-color: var(--psy-primary);
    background: rgba(91, 154, 139, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(91, 154, 139, 0.12);
}

.psy-category-option.selected {
    background: var(--psy-primary);
    color: #fff;
    border-color: var(--psy-primary);
}

.psy-category-icon {
    font-size: 14px;
}

/* 输入框 */
.psy-textarea-box {
    margin-bottom: 6px;
}

.psy-textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--psy-border);
    border-radius: var(--psy-radius);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    background: var(--psy-card-bg);
    color: var(--psy-text);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    min-height: 120px;
}

.psy-textarea:focus {
    border-color: var(--psy-primary);
    box-shadow: 0 0 0 3px rgba(91, 154, 139, 0.15);
}

.psy-textarea::placeholder {
    color: var(--psy-text-secondary);
    opacity: 0.7;
}

.psy-char-counter {
    text-align: right;
    font-size: 11px;
    color: var(--psy-text-secondary);
    margin-bottom: 14px;
}

/* 咨询模式 */
.psy-mode-group {
    margin-bottom: 10px;
}

.psy-mode-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--psy-text-secondary);
    display: block;
    margin-bottom: 8px;
}

.psy-mode-options {
    display: flex;
    gap: 8px;
}

.psy-mode-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--psy-radius-sm);
    border: 2px solid var(--psy-border);
    background: var(--psy-card-bg);
    color: var(--psy-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.psy-mode-option:hover {
    border-color: var(--psy-accent);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(155, 142, 196, 0.12);
}

.psy-mode-option.selected {
    border-color: var(--psy-primary);
    background: linear-gradient(135deg, rgba(91,154,139,0.08), rgba(155,142,196,0.06));
    color: var(--psy-primary);
    box-shadow: 0 2px 8px rgba(91, 154, 139, 0.12);
}

.psy-mode-icon {
    font-size: 16px;
}

.psy-mode-hint {
    display: block;
    font-size: 11px;
    color: var(--psy-accent);
    margin: 6px 0 14px 0;
    font-style: italic;
}

/* 使用提示 */
.psy-tips-box {
    background: var(--psy-card-bg);
    border: 1px solid var(--psy-border);
    border-radius: var(--psy-radius-sm);
    padding: 12px 14px;
    margin-top: 8px;
}

.psy-tips-box p {
    margin: 0 0 6px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--psy-warm);
}

.psy-tips-box ul {
    margin: 0;
    padding-left: 18px;
}

.psy-tips-box li {
    font-size: 11px;
    color: var(--psy-text-secondary);
    line-height: 1.7;
}

/* 右栏 - 结果面板 */
.psy-result-panel {
    flex: 1.2;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--psy-card-bg);
}

.psy-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--psy-border);
    background: linear-gradient(to bottom, var(--psy-card-bg), var(--psy-bg));
}

.psy-result-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--psy-text);
}

.result-mode-badge {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    background: var(--psy-primary);
    color: #fff;
}

.psy-result-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--psy-bg);
}

/* 占位提示 */
.result-placeholder {
    text-align: center;
    padding: 60px 20px;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: gentlePulse 3s ease-in-out infinite;
}

@keyframes gentlePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.placeholder-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--psy-primary);
    margin: 0 0 12px 0;
}

.placeholder-desc {
    font-size: 12px;
    color: var(--psy-text-secondary);
    margin: 4px 0;
    line-height: 1.6;
}

/* 加载动画 - 呼吸效果 */
.result-loading {
    text-align: center;
    padding: 60px 20px;
}

.loading-breath {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.breath-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--psy-primary-light), var(--psy-primary));
    animation: breathe 4s ease-in-out infinite;
    opacity: 0.7;
}

@keyframes breathe {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.9; }
}

.loading-text {
    font-size: 14px;
    color: var(--psy-primary);
    margin: 0 0 6px 0;
    font-weight: 500;
}

.loading-sub {
    font-size: 12px;
    color: var(--psy-text-secondary);
    margin: 0;
}

/* 结果内容样式 */
.result-content {
    line-height: 1.7;
    color: var(--psy-text);
    font-size: 14px;
}

.result-content .consult-result {
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-content .consult-section {
    margin-bottom: 16px;
    padding: 16px 18px;
    background: var(--psy-card-bg);
    border-radius: var(--psy-radius);
    border-left: 4px solid var(--psy-primary);
    box-shadow: 0 1px 4px var(--psy-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-content .consult-section:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px var(--psy-shadow);
}

.result-content .consult-section h4 {
    margin: 0 0 10px 0;
    font-size: 15px;
    color: var(--psy-primary);
}

.result-content .consult-section h5 {
    margin: 10px 0 6px 0;
    font-size: 13px;
    color: var(--psy-accent);
}

.result-content .consult-section p {
    margin: 6px 0;
    line-height: 1.8;
}

.result-content .consult-section ul {
    padding-left: 20px;
    margin: 6px 0;
}

.result-content .consult-section li {
    margin-bottom: 6px;
    line-height: 1.7;
}

.result-content .emotion-section {
    border-left-color: var(--psy-warm);
}

.result-content .comfort-section {
    border-left-color: #e8918b;
}

.result-content .suggest-section {
    border-left-color: #6bc5a0;
}

.result-content .exercise-section {
    border-left-color: #7db8d8;
}

.result-content .cognition-section {
    border-left-color: var(--psy-accent);
}

.result-content .root-section {
    border-left-color: #d4956b;
}

.result-content .strategy-section {
    border-left-color: #5ba3c9;
}

.result-content .resource-section {
    border-left-color: #c4986b;
}

.result-content .closing-section {
    border-left-color: var(--psy-primary);
    background: rgba(91, 154, 139, 0.05);
}

.result-content .consult-closing {
    font-style: italic;
    color: var(--psy-primary);
    font-weight: 500;
}

.result-content .consult-disclaimer {
    font-size: 11px;
    color: var(--psy-text-secondary);
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--psy-bg);
    border-radius: 6px;
}

.result-content .emotion-tag {
    display: inline-block;
    padding: 3px 10px;
    margin: 2px 4px;
    border-radius: 14px;
    background: var(--psy-accent-light);
    color: #fff;
    font-size: 12px;
}

body.dark .result-content .emotion-tag {
    background: var(--psy-accent);
    color: #1a1e24;
}

/* 错误提示 */
#psyResultError {
    text-align: center;
    padding: 20px;
    color: #ef4444;
    font-size: 13px;
}

.psy-error-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 32px;
    background: var(--psy-card-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--psy-radius);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.08);
}

.psy-error-card .error-icon {
    font-size: 28px;
}

.psy-error-card .error-msg {
    font-size: 13px;
    color: #ef4444;
    font-weight: 500;
}

.psy-error-card .error-hint {
    font-size: 11px;
    color: var(--psy-text-secondary);
}

/* Toast 通知 */
.psy-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 99999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.psy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.psy-toast.success {
    background: var(--psy-primary);
    color: #fff;
}

.psy-toast.error {
    background: #ef4444;
    color: #fff;
}

.psy-toast.info {
    background: var(--psy-accent);
    color: #fff;
}

/* ======================== 模态框 ======================== */
.psy-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
}

.psy-modal {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--psy-card-bg);
    border-radius: var(--psy-radius);
    box-shadow: 0 20px 60px var(--psy-shadow);
    z-index: 10001;
    width: 90%;
    max-width: 640px;
    max-height: 80vh;
    overflow: hidden;
    flex-direction: column;
}

.psy-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--psy-border);
}

.psy-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--psy-text);
}

.psy-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--psy-text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.psy-modal-close:hover {
    background: var(--psy-hover);
    color: var(--psy-text);
}

.psy-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.example-card {
    padding: 14px;
    border: 1px solid var(--psy-border);
    border-radius: var(--psy-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--psy-bg);
}

.example-card:hover {
    border-color: var(--psy-primary);
    box-shadow: 0 4px 16px var(--psy-shadow);
    transform: translateY(-2px);
    background: var(--psy-card-bg);
}

.example-card-category {
    display: inline-block;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--psy-primary);
    color: #fff;
    margin-bottom: 8px;
}

.example-card-message {
    font-size: 13px;
    color: var(--psy-text);
    line-height: 1.5;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.example-card-desc {
    font-size: 11px;
    color: var(--psy-text-secondary);
}

body.dark .psy-toolbar {
    background: linear-gradient(135deg, #3d6b60 0%, #5c5280 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

body.dark .psy-container.fullscreen {
    background: var(--psy-bg);
}

body.dark .toolbar-btn {
    background: rgba(255,255,255,0.12);
    color: #e0dcd8;
}

body.dark .toolbar-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

body.dark .toolbar-btn-primary {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

body.dark .toolbar-title {
    color: #fff;
}

body.dark .history-item.active {
    background: rgba(126, 200, 182, 0.12);
    border-color: var(--psy-primary);
}

body.dark .psy-error-card {
    border-color: rgba(239, 68, 68, 0.3);
}

body.dark .psy-category-option:hover {
    background: rgba(126, 200, 182, 0.1);
}

body.dark .toolbar-btn-active {
    background: rgba(255,255,255,0.2);
    box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.3);
}

/* ======================== 响应式设计 ======================== */
@media (max-width: 1024px) {
    .psy-history-panel {
        width: 180px;
        min-width: 180px;
    }
}

@media (max-width: 768px) {
    .psy-main-content {
        flex-direction: column;
    }
    .psy-history-panel {
        width: 100%;
        min-width: 100%;
        max-height: 150px;
        border-right: none;
        border-bottom: 1px solid var(--psy-border);
    }
    .psy-input-panel {
        border-right: none;
        border-bottom: 1px solid var(--psy-border);
        min-width: auto;
    }
    .psy-result-panel {
        min-width: auto;
    }
    .toolbar-group {
        flex-wrap: wrap;
    }
    .example-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .psy-toolbar {
        padding: 8px 10px;
    }
    .toolbar-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    .psy-category-options {
        gap: 4px;
    }
    .psy-category-option {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* ======================== 滚动条美化 ======================== */
.psy-history-panel ::-webkit-scrollbar,
.psy-input-body::-webkit-scrollbar,
.psy-result-body::-webkit-scrollbar {
    width: 5px;
}

.psy-history-panel ::-webkit-scrollbar-track,
.psy-input-body::-webkit-scrollbar-track,
.psy-result-body::-webkit-scrollbar-track {
    background: transparent;
}

.psy-history-panel ::-webkit-scrollbar-thumb,
.psy-input-body::-webkit-scrollbar-thumb,
.psy-result-body::-webkit-scrollbar-thumb {
    background: var(--psy-border);
    border-radius: 3px;
}

.psy-history-panel ::-webkit-scrollbar-thumb:hover,
.psy-input-body::-webkit-scrollbar-thumb:hover,
.psy-result-body::-webkit-scrollbar-thumb:hover {
    background: var(--psy-text-secondary);
}
