/* protocolParser.css - 协议解析器样式文件 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
}

/* 左侧协议列表 */
.sidebar {
    width: 360px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 20px;
    background: #34495e;
    border-bottom: 1px solid #445566;
}

.sidebar-header h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #ecf0f1;
}

.create-protocol-btn {
    width: 100%;
    padding: 10px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    margin-bottom: 10px;
}

.create-protocol-btn:hover {
    background: #229954;
}

.load-protocols-btn {
    width: 100%;
    padding: 10px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.load-protocols-btn:hover {
    background: #2980b9;
}

.protocol-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.protocol-item {
    padding: 15px;
    margin-bottom: 10px;
    background: #34495e;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.protocol-item:hover {
    background: #3d566e;
}

.protocol-item.active {
    background: #3498db;
}

.protocol-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #e74c3c;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.protocol-item:hover .protocol-delete-btn {
    display: flex;
}

.protocol-delete-btn:hover {
    background: #c0392b;
}

.protocol-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #ecf0f1;
}

.protocol-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.protocol-settings-btn {
    font-size: 11px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    color: #bdc3c7;
    padding: 3px 8px;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all 0.2s;
}

.protocol-settings-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-color: rgba(255,255,255,0.4);
}

.protocol-info {
    font-size: 12px;
    color: #95a5a6;
    margin-bottom: 4px;
}

.protocol-item.active .protocol-info {
    color: #ecf0f1;
}

.protocol-files-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #445566;
}

.protocol-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    margin-bottom: 4px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    font-size: 11px;
    color: #bdc3c7;
}

.protocol-file-item:hover {
    background: rgba(0,0,0,0.3);
}

.file-delete-btn {
    width: 18px;
    height: 18px;
    background: #e74c3c;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.file-delete-btn:hover {
    background: #c0392b;
}

.protocol-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #445566;
    display: block;
}

.action-btn {
    width: 100%;
    padding: 8px;
    margin-bottom: 6px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.upload-file-btn {
    background: #27ae60;
    color: white;
}

.upload-file-btn:hover {
    background: #229954;
}

.generate-parser-btn {
    background: #e67e22;
    color: white;
}

.generate-parser-btn:hover {
    background: #d35400;
}

.generate-parser-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.update-parser-btn {
    background: #9b59b6;
    color: white;
}

.update-parser-btn:hover {
    background: #8e44ad;
}

.update-parser-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.parser-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 6px;
}

.parser-exists {
    background: #27ae60;
    color: white;
}

.parser-not-exists {
    background: #e74c3c;
    color: white;
}

.parser-actions {
    display: inline-block;
    margin-left: 8px;
}

.parser-action-btn {
    padding: 2px 8px;
    margin-left: 4px;
    border: none;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.view-parser-btn {
    background: #3498db;
    color: white;
}

.view-parser-btn:hover {
    background: #2980b9;
}

.download-parser-btn {
    background: #27ae60;
    color: white;
}

.download-parser-btn:hover {
    background: #229954;
}

.conversation-list {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #445566;
    display: none;
}

.conversation-list.expanded {
    display: block;
}

.conversation-item {
    padding: 8px 10px;
    margin-bottom: 5px;
    background: #2c3e50;
    border-radius: 4px;
    font-size: 12px;
    color: #bdc3c7;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #3d566e;
}

/* 文件上传区域 */
.upload-section {
    padding: 15px;
    background: #34495e;
    border-top: 1px solid #445566;
}

.upload-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #ecf0f1;
}

.protocol-name-input {
    margin-bottom: 10px;
}

.protocol-name-input label {
    display: block;
    font-size: 12px;
    color: #bdc3c7;
    margin-bottom: 5px;
}

.protocol-name-input input {
    width: 100%;
    padding: 8px 12px;
    background: #2c3e50;
    border: 1px solid #445566;
    border-radius: 4px;
    color: #ecf0f1;
    font-size: 13px;
}

.protocol-name-input input:focus {
    outline: none;
    border-color: #3498db;
}

.protocol-name-input input:disabled {
    background: #3d566e;
    cursor: not-allowed;
}

.protocol-name-status {
    font-size: 11px;
    margin-top: 4px;
    min-height: 16px;
}

.protocol-name-exists {
    color: #e74c3c;
}

.protocol-name-available {
    color: #2ecc71;
}

.file-input-wrapper {
    margin-bottom: 10px;
}

.file-input-wrapper input[type="file"] {
    width: 100%;
    padding: 8px;
    background: #2c3e50;
    border: 1px solid #445566;
    border-radius: 4px;
    color: #ecf0f1;
    font-size: 12px;
}

.upload-status {
    font-size: 12px;
    margin-bottom: 10px;
    min-height: 20px;
}

.upload-success {
    color: #2ecc71;
}

.upload-error {
    color: #e74c3c;
}

.upload-btn {
    width: 100%;
    padding: 10px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    margin-bottom: 8px;
}

.upload-btn:hover {
    background: #229954;
}

.upload-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.generate-btn {
    width: 100%;
    padding: 12px;
    background: #e67e22;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.generate-btn:hover {
    background: #d35400;
}

.generate-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* 右侧聊天区域 */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-header {
    padding: 14px 20px 12px;
    background: rgba(255,255,255,0.78);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.chat-header h3 {
    color: #2c3e50;
    font-size: 17px;
    font-weight: 600;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-actions .btn-icon {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    color: #555;
    transition: all 0.2s;
}

.chat-header-actions .btn-icon:hover {
    background: #f0f0f0;
    border-color: #999;
    color: #333;
}

.chat-header .status {
    font-size: 12px;
    color: #7d8b99;
    margin-top: 4px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 22px;
    background:
        radial-gradient(circle at top left, rgba(255,255,255,0.36), transparent 45%),
        linear-gradient(180deg, #ebebeb 0%, #e9edf1 100%);
}

.message {
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-user,
.message-assistant {
    display: flex;
}

.message-user {
    justify-content: flex-end;
}

.message-assistant {
    justify-content: flex-start;
}

.message-shell {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 82%;
}

.message-bubble {
    position: relative;
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.message-user .message-bubble {
    background: #95ec69;
    color: #1f2d3a;
    border-top-right-radius: 6px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

.message-user .message-bubble::after {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 10px;
    width: 12px;
    height: 12px;
    background: #95ec69;
    transform: rotate(45deg);
    border-radius: 2px;
}

.message-assistant .message-bubble {
    background: rgba(255,255,255,0.96);
    color: #1f2d3a !important;
    border: 1px solid rgba(0,0,0,0.05);
    border-top-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.message-assistant .message-bubble::after {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 10px;
    width: 12px;
    height: 12px;
    background: rgba(255,255,255,0.96);
    border-left: 1px solid rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transform: rotate(45deg);
    border-radius: 2px;
}

.message-content {
    line-height: 1.6;
    font-size: 15px;
    white-space: normal;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.message-avatar-user {
    background: linear-gradient(180deg, #6ad35f 0%, #35b96f 100%);
    color: white;
}

.message-avatar-assistant {
    background: linear-gradient(180deg, #ffffff 0%, #eef3f7 100%);
    color: #4f6b7d;
    border: 1px solid rgba(0,0,0,0.06);
}

.message-system {
    display: flex;
    justify-content: center;
}

.message-system-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}

.message-system .message-content {
    background: rgba(0,0,0,0.18);
    color: #fff;
    padding: 4px 12px;
    border-radius: 999px;
    max-width: 80%;
    word-wrap: break-word;
    text-align: center;
    font-style: normal;
    font-size: 12px;
}

.message-time-divider {
    display: flex;
    justify-content: center;
    margin: 8px 0 12px;
}

.message-time-divider span {
    background: rgba(0,0,0,0.2);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: 0.5px;
}

.message-content pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.message-content code {
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 2px;
    background: transparent;
    box-shadow: none;
}

.typing-indicator span {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #7f8c8d;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

.input-area {
    padding: 14px 16px 16px;
    background: rgba(255,255,255,0.82);
    border-top: 1px solid rgba(0,0,0,0.06);
    backdrop-filter: blur(8px);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.input-wrapper textarea {
    flex: 1;
    min-height: 54px;
    max-height: 150px;
    padding: 12px 14px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 14px;
    background: rgba(255,255,255,0.94);
    color: #1f2d3a;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: #95ec69;
    box-shadow: 0 0 0 3px rgba(149, 236, 105, 0.18);
}

.btn-send {
    min-width: 72px;
    padding: 12px 18px;
    background: #2fb344;
    color: white;
    align-self: flex-end;
    border-radius: 12px;
}

.btn-send:hover {
    background: #28a03d;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #95a5a6;
    text-align: center;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #7f8c8d;
}

.empty-state p {
    font-size: 14px;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

.hidden {
    display: none !important;
}

/* 加载动画旋转效果 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 加载动画容器 */
.loading-animation {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

/* 加载文本样式 - 不使用动画，避免闪烁 */
.loading-text {
    color: #7f8c8d;
    font-style: italic;
    display: inline-block;
}

/* 权限确认按钮样式 */
.permission-prompt {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: none;
}

.permission-prompt.active {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.permission-prompt-header {
    font-size: 14px;
    font-weight: 600;
    color: #856404;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.permission-prompt-header::before {
    content: '🔐';
    font-size: 18px;
}

.permission-prompt-message {
    font-size: 13px;
    color: #856404;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.permission-prompt-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.permission-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.permission-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.permission-btn:active {
    transform: translateY(0);
}

.btn-allow-all {
    background: #28a745;
    color: white;
}

.btn-allow-all:hover {
    background: #218838;
}

.btn-allow-once {
    background: #007bff;
    color: white;
}

.btn-allow-once:hover {
    background: #0069d9;
}

.btn-deny {
    background: #dc3545;
    color: white;
}

.btn-deny:hover {
    background: #c82333;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

.permission-btn .shortcut {
    font-size: 11px;
    opacity: 0.8;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 3px;
}

/* 对话框样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 80%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 18px;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    background: #e74c3c;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close-btn:hover {
    background: #c0392b;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body pre {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.form-group .required {
    color: #e74c3c;
    margin-left: 4px;
}

.form-select,
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #2c3e50;
    transition: border-color 0.2s;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-select {
    cursor: pointer;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-primary:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}
