/* ===================================================================
   K8s配置生成器 - 样式文件
   参考 svg_editor.css 布局范式，采用蓝/青技术风格
=================================================================== */

/* --- 主容器 --- */
.k8s-editor-container {
    display: flex;
    flex-direction: column;
    background: #f0f4f8;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0,0,0,0.10);
    min-height: 660px;
    margin: 0 0 18px 0;
    transition: all 0.3s ease;
}

/* 全屏模式 */
.k8s-editor-container.fullscreen-mode {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9000;
    border-radius: 0;
    margin: 0;
    min-height: 100vh;
}

/* --- 工具栏 --- */
.k8s-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #1e3a5f 0%, #0d2b4a 100%);
    border-bottom: 2px solid #326fa8;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.toolbar-group {
    display: flex;
    gap: 4px;
    align-items: center;
}

.toolbar-group + .toolbar-group {
    border-left: 1px solid rgba(255,255,255,0.15);
    padding-left: 8px;
    margin-left: 2px;
}

.toolbar-btn {
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.20);
    color: #e2edf7;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
    letter-spacing: 0.2px;
}

.toolbar-btn:hover {
    background: rgba(74, 144, 226, 0.45);
    border-color: #4a90e2;
    color: #fff;
    transform: translateY(-1px);
}

.toolbar-btn:active {
    transform: translateY(0);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

/* 主操作按钮 - 金色高亮 */
.toolbar-btn-primary {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    border-color: #f59e0b !important;
    color: #fff !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(245,158,11,0.40);
}

.toolbar-btn-primary:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    border-color: #fbbf24 !important;
    box-shadow: 0 4px 14px rgba(245,158,11,0.55) !important;
    transform: translateY(-1px);
}

/* --- 主内容三栏 --- */
.k8s-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* --- 左侧历史面板 --- */
.k8s-history-panel {
    width: 200px;
    min-width: 160px;
    background: #fafbfc;
    border-right: 1px solid #dce6f0;
    border-left: 4px solid #3b82f6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #f5f8fc, #eef3f9);
    border-bottom: 1px solid #dce6f0;
    flex-shrink: 0;
}

.history-title {
    font-size: 12px;
    font-weight: 600;
    color: #3a5a80;
}

.history-clear-btn {
    background: none;
    border: none;
    color: #e05c5c;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.2s;
    line-height: 1;
}

.history-clear-btn:hover {
    background: #fee2e2;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.history-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
    color: #94a3b8;
    font-size: 12px;
}

.history-item {
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all 0.18s;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    position: relative;
}

.history-item:hover {
    background: #e8f0fe;
    border-color: #4a90e2;
    transform: translateX(2px);
}

.history-item:hover .history-item-del {
    display: flex;
}

.history-item-del {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    border: none;
    border-radius: 3px;
    color: #dc2626;
    font-size: 10px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: background 0.15s;
    z-index: 1;
}

.history-item-del:hover {
    background: #fecaca;
}

.history-item-name {
    font-size: 12px;
    font-weight: 600;
    color: #2c4a6e;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-type {
    font-size: 10px;
    color: #64748b;
    background: #e8f4fd;
    border-radius: 3px;
    padding: 1px 5px;
    display: inline-block;
    margin-bottom: 3px;
}

.history-item-time {
    font-size: 10px;
    color: #94a3b8;
}

/* --- 中间配置面板 --- */
.k8s-config-panel {
    flex: 0 0 380px;
    min-width: 300px;
    background: #fff;
    border-right: 1px solid #dce6f0;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 资源类型选择器 */
.resource-type-selector {
    background: #f8fafc;
    border: 1px solid #e2eaf3;
    border-radius: 8px;
    padding: 10px 12px;
}

.section-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #3a5a80;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.resource-type-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.type-tab {
    padding: 5px 10px;
    border: 1px solid #c5d8ee;
    background: #fff;
    color: #3a6fa8;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s;
}

.type-tab:hover {
    background: #e8f0fe;
    border-color: #4a90e2;
}

.type-tab.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37,99,235,0.30);
}

/* 配置区段 */
.config-section {
    background: #fafbfc;
    border: 1px solid #e2eaf3;
    border-radius: 8px;
    padding: 12px;
}

/* 各区段左侧彩色语义边框 */
#sectionBase        { border-left: 3px solid #3b82f6; }
#sectionContainer   { border-left: 3px solid #8b5cf6; }
#sectionResources   { border-left: 3px solid #06b6d4; }
#sectionService     { border-left: 3px solid #10b981; }
#sectionIngress     { border-left: 3px solid #f59e0b; }
#sectionPvc         { border-left: 3px solid #f97316; }
#sectionEnv         { border-left: 3px solid #6366f1; }
#sectionLabels      { border-left: 3px solid #94a3b8; }

.section-title {
    font-size: 12px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2eaf3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-hint {
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
}

.required {
    color: #e05c5c;
}

.form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group-wide {
    flex: 2;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: #475569;
}

.form-input,
.form-select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #c5d8ee;
    border-radius: 5px;
    font-size: 12px;
    color: #1e3a5f;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* 校验失败状态 */
.form-input.is-error,
.form-select.is-error {
    border-color: #ef4444 !important;
    background: #fff5f5 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.12) !important;
    transition: border-color 0.2s, background-color 0.2s;
}

.form-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #c5d8ee;
    border-radius: 5px;
    font-size: 12px;
    color: #1e3a5f;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    outline: none;
    min-height: 80px;
}

.form-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-textarea.is-error {
    border-color: #ef4444 !important;
    background: #fff5f5 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.12) !important;
    transition: border-color 0.2s, background-color 0.2s;
}

/* 生成按钮区 */
.generate-section {
    background: transparent;
    border: none;
    padding: 4px 0 0;
}

@keyframes btn-pulse {
    0%, 100% { box-shadow: 0 3px 10px rgba(37,99,235,0.35); }
    50%       { box-shadow: 0 3px 20px rgba(37,99,235,0.60), 0 0 0 5px rgba(37,99,235,0.08); }
}

.generate-btn {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    box-shadow: 0 3px 10px rgba(37,99,235,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    animation: btn-pulse 2.8s ease-in-out infinite;
}

.generate-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(37,99,235,0.50);
    animation: none;
}

.generate-btn:active {
    transform: translateY(0);
}

.generate-btn.loading {
    opacity: 0.75;
    cursor: not-allowed;
    pointer-events: none;
    animation: none;
}

/* --- 右侧输出面板 --- */
.k8s-output-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #1a2332;
    overflow: hidden;
    border-left: 4px solid #22d3ee;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 16px;
    background: #1e2d42;
    border-bottom: 1px solid #2d4060;
    flex-shrink: 0;
}

.output-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #7eb8e8;
}

.output-badge {
    background: #22c55e;
    color: #fff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.output-actions {
    display: flex;
    gap: 6px;
}

.output-action-btn {
    background: rgba(74,144,226,0.15);
    border: 1px solid rgba(74,144,226,0.30);
    color: #7eb8e8;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.output-action-btn:hover {
    background: rgba(74,144,226,0.30);
    border-color: #4a90e2;
    color: #fff;
}

.output-action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.output-content {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

.output-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #4a6080;
    text-align: center;
    gap: 8px;
}

/* 输出区加载状态 */
.output-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    gap: 14px;
}

.output-loading-spin {
    font-size: 40px;
    animation: k8s-spin 1s linear infinite;
    opacity: 0.75;
}

.output-loading-text {
    font-size: 13px;
    color: #4a7a9e;
    letter-spacing: 0.5px;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.6; }
    50%       { opacity: 1; }
}

.placeholder-icon {
    font-size: 48px;
    opacity: 0.3;
}

.placeholder-text {
    font-size: 14px;
    color: #5a7a9e;
}

.placeholder-sub {
    font-size: 12px;
    color: #3a5a78;
}

.yaml-code {
    margin: 0;
    padding: 18px 20px;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #e2f0ff;
    white-space: pre;
    background: transparent;
    tab-size: 2;
    overflow: visible;
}

/* YAML语法简单高亮 */
.yaml-code .k8s-key    { color: #79c0ff; }
.yaml-code .k8s-value  { color: #a5d6ff; }
.yaml-code .k8s-string { color: #7ee787; }
.yaml-code .k8s-comment{ color: #8b949e; font-style: italic; }
.yaml-code .k8s-sep    { color: #e3b341; font-weight: bold; }

/* --- AI侧边栏 --- */
.ai-sidebar {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0,0,0,0.18);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-sidebar.open {
    right: 0;
}

.ai-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e3a5f, #0d2b4a);
    color: #fff;
    flex-shrink: 0;
}

.ai-sidebar-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.ai-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.ai-close-btn:hover {
    background: rgba(255,255,255,0.30);
}

.ai-sidebar-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-input-group label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.ai-input-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c5d8ee;
    border-radius: 6px;
    font-size: 13px;
    color: #1e3a5f;
    resize: vertical;
    box-sizing: border-box;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 120px;
}

.ai-input-group textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* AI输入框校验失败状态 */
.ai-input-group textarea.is-error {
    border-color: #ef4444 !important;
    background: #fff5f5 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.12) !important;
    transition: border-color 0.2s, background-color 0.2s;
}

.ai-actions {
    display: flex;
    gap: 8px;
}

.ai-btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.30);
}

.ai-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
}

.ai-btn-cancel {
    background: #fee2e2;
    color: #dc2626;
}

.ai-btn-cancel:hover {
    background: #fecaca;
}

.ai-tips {
    background: #f0f7ff;
    border: 1px solid #bee3f8;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 12px;
    color: #374151;
}

.ai-tips p {
    margin: 0 0 6px;
    font-weight: 600;
    color: #1d4ed8;
}

.ai-tips ul {
    margin: 0;
    padding-left: 18px;
    color: #4b5563;
    line-height: 1.8;
}

/* AI错误区域 */
.ai-error-area {
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 6px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai-error-msg {
    font-size: 12px;
    color: #dc2626;
    line-height: 1.5;
    font-weight: 500;
}

.ai-retry-btn {
    align-self: flex-start;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 6px rgba(239,68,68,0.30);
}

.ai-retry-btn:hover {
    background: linear-gradient(135deg, #f87171, #ef4444);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(239,68,68,0.40);
}

/* AI遮罩 */
.ai-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 10000;
    display: none;
}

.ai-overlay.open {
    display: block;
}

/* --- 弹窗Modal --- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 11000;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 10px;
    width: 680px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e3a5f, #0d2b4a);
    color: #fff;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.modal-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.30);
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
}

/* 示例网格 */
.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.example-card {
    border: 1px solid #dce6f0;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafcff;
}

.example-card:hover {
    border-color: #2563eb;
    background: #e8f0fe;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.15);
}

.example-card-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 6px;
}

.example-card-type {
    font-size: 10px;
    background: #dbeafe;
    color: #2563eb;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 8px;
    font-weight: 600;
}

.example-card-desc {
    font-size: 11px;
    color: #64748b;
    line-height: 1.5;
}

/* 复制提示Toast */
.copy-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: #1e3a5f;
    color: #fff;
    padding: 10px 22px;
    border-radius: 22px;
    font-size: 13px;
    font-weight: 600;
    z-index: 20000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Toast类型颜色变体 */
.copy-toast.toast-warn {
    background: linear-gradient(135deg, #b45309, #92400e);
    box-shadow: 0 4px 16px rgba(180,83,9,0.35);
}

.copy-toast.toast-error {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    box-shadow: 0 4px 16px rgba(220,38,38,0.35);
}

.copy-toast.toast-info {
    background: linear-gradient(135deg, #0369a1, #075985);
    box-shadow: 0 4px 16px rgba(3,105,161,0.35);
}

/* 滚动条样式 */
.k8s-history-panel ::-webkit-scrollbar,
.k8s-config-panel::-webkit-scrollbar,
.output-content::-webkit-scrollbar,
.ai-sidebar-body::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.k8s-history-panel ::-webkit-scrollbar-thumb,
.k8s-config-panel::-webkit-scrollbar-thumb,
.output-content::-webkit-scrollbar-thumb,
.ai-sidebar-body::-webkit-scrollbar-thumb {
    background: #c5d8ee;
    border-radius: 3px;
}

.output-content::-webkit-scrollbar-thumb {
    background: #2d4060;
}

/* 统计信息栏 */
.output-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 18px;
    background: #1e2d42;
    border-top: 1px solid #2d4060;
    font-size: 11px;
    color: #4a7a9e;
    flex-shrink: 0;
}

.stat-sep {
    color: #2d4060;
}

/* 加载动效 */
@keyframes k8s-spin {
    to { transform: rotate(360deg); }
}

.spin {
    display: inline-block;
    animation: k8s-spin 0.8s linear infinite;
}

/* 响应式 */
@media (max-width: 900px) {
    .k8s-history-panel {
        display: none;
    }
    .k8s-config-panel {
        flex: 0 0 320px;
    }
}

@media (max-width: 640px) {
    .k8s-main-content {
        flex-direction: column;
    }
    .k8s-config-panel {
        flex: none;
        max-height: 60vh;
        overflow-y: auto;
    }
    .k8s-output-panel {
        min-height: 300px;
    }
}
