/* ===== AI Chat Interface ===== */
.ai-chat-container {
    max-width: 1200px;
    width: 95%;
    margin: 1rem auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    height: 80vh;
    min-height: 500px;
    background: #fff;
}

.ai-testing-layout .ai-chat-container {
    flex: 1;
    margin: 0;
    width: auto;
    height: 100%;
    min-width: 0;
    margin-left: auto;
    max-width: calc(100% - 340px);
}

.ai-chat-messages {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 300px;
}

.chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.ai {
    align-self: flex-start;
}

.message-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chat-message.user .message-icon {
    background: #fff7ed;
    color: #f97316;
}

.chat-message.ai .message-icon {
    background: #f0fdf4;
    color: #22c55e;
}

.message-content {
    background: #f9fafb;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid #f3f4f6;
}

.chat-message.user .message-content {
    background: #f97316;
    color: #fff;
    border-color: #f97316;
}

.message-content p {
    margin: 0;
    line-height: 1.6;
    font-weight: 400;
}

/* Input area */
.ai-chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}

#ai-command-form {
    display: flex;
    gap: 8px;
}

#ai-command-input {
    flex-grow: 1;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 14px;
    background: #fff;
    color: #111827;
    transition: border-color 0.15s;
    outline: none;
}

#ai-command-input:focus {
    border-color: #f97316;
}

#ai-command-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: none;
    background: #f97316;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s;
}

#ai-command-send-btn:hover {
    background: #ea580c;
}

#ai-command-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

#ai-stop-btn {
    margin-top: 8px;
    padding: 8px 16px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

#ai-stop-btn:hover {
    background: #dc2626;
}

.subtitle {
    font-size: 14px;
    color: #6b7280;
    text-align: center;
    max-width: 500px;
    margin: -8px auto 16px auto;
}

/* AI Testing Layout */
.ai-testing-layout {
    display: flex;
    gap: 20px;
    height: 80vh;
    min-height: 500px;
    padding: 0 16px;
}

/* AI Help Panel */
.ai-help-panel {
    width: 300px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    flex-shrink: 0;
}

.ai-help-panel.collapsed {
    width: 48px;
}

.help-header {
    background: #fafafa;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e5e7eb;
}

.help-header h3 {
    color: #111827;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-toggle {
    background: none;
    border: 1px solid #e5e7eb;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s;
}

.help-toggle:hover {
    border-color: #f97316;
    color: #f97316;
}

.ai-help-panel.collapsed .help-toggle i {
    transform: rotate(180deg);
}

.help-content {
    padding: 16px;
    max-height: calc(80vh - 60px);
    overflow-y: auto;
}

.ai-help-panel.collapsed .help-content {
    display: none;
}

.help-section {
    margin-bottom: 20px;
}

.help-section h4 {
    color: #111827;
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.command-examples {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.command-example {
    background: #fafafa;
    color: #374151;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    border: 1px solid #e5e7eb;
}

.command-example:hover {
    background: #fff7ed;
    border-color: #f97316;
    color: #f97316;
}

.help-tip {
    background: #fff7ed;
    color: #92400e;
    padding: 12px;
    border-radius: 4px;
    margin-top: 16px;
    border-left: 3px solid #f97316;
    font-size: 13px;
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.help-tip i {
    color: #f97316;
    margin-top: 1px;
}

/* Browser controls */
.ai-browser-controls {
    background: #fafafa;
    border-radius: 6px;
    padding: 14px;
    margin: 10px 0;
    border: 1px solid #e5e7eb;
}

.browser-visibility-section h4 {
    color: #111827;
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.browser-visibility-section h4 i {
    color: #f97316;
}

.browser-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.browser-toggle {
    flex: 1;
    cursor: pointer;
    display: block;
}

.browser-toggle input[type="radio"] {
    display: none;
}

.toggle-label {
    display: block;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: border-color 0.15s;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

.toggle-label i {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
    color: #9ca3af;
}

.toggle-label small {
    display: block;
    font-size: 10px;
    color: #9ca3af;
    margin-top: 2px;
}

.browser-toggle input[type="radio"]:checked + .toggle-label {
    background: #fff7ed;
    border-color: #f97316;
    color: #f97316;
}

.browser-toggle input[type="radio"]:checked + .toggle-label i {
    color: #f97316;
}

.browser-toggle input[type="radio"]:checked + .toggle-label small {
    color: #ea580c;
}

.browser-toggle:hover .toggle-label {
    border-color: #f97316;
}

.browser-info {
    background: #fff7ed;
    border-radius: 4px;
    padding: 8px 10px;
    border-left: 3px solid #f97316;
}

.browser-info p {
    margin: 0;
    font-size: 12px;
    color: #92400e;
    line-height: 1.4;
}

.browser-info i {
    color: #f97316;
    margin-right: 4px;
}

/* Site Selector */
.ai-site-selector {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin: 12px 0;
}

.site-selector-header {
    background: #fafafa;
    color: #111827;
    padding: 12px 16px;
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.site-selector-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.close-selector-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.close-selector-btn:hover {
    color: #111827;
}

.site-selector-content {
    padding: 16px;
}

.site-selector-options {
    margin-bottom: 12px;
}

.site-option {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
    position: relative;
}

.site-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.option-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.15s;
    cursor: pointer;
}

.option-label:hover {
    border-color: #f97316;
}

.site-option input[type="radio"]:checked + .option-label {
    border-color: #f97316;
    background: #fff7ed;
}

.option-label .option-header {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
}

.option-label i {
    margin-right: 10px;
    color: #f97316;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.option-label .option-title {
    font-weight: 600;
    color: #111827;
    font-size: 14px;
}

.option-label small {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-left: 30px;
    line-height: 1.4;
}

.single-site-dropdown {
    margin: 12px 0;
    background: #fafafa;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.dropdown-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #374151;
    font-size: 13px;
}

.dropdown-label i {
    margin-right: 6px;
    color: #f97316;
}

.site-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    transition: border-color 0.15s;
    font-family: inherit;
    outline: none;
}

.site-select:focus {
    border-color: #f97316;
}

.site-selector-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.confirm-selection-btn {
    flex: 1;
    background: #f97316;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.confirm-selection-btn:hover {
    background: #ea580c;
}

.cancel-selection-btn {
    background: #fff;
    color: #374151;
    border: 1px solid #e5e7eb;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.cancel-selection-btn:hover {
    border-color: #d1d5db;
}

/* Responsive */
@media (max-width: 1200px) {
    .ai-testing-layout {
        flex-direction: column;
        height: auto;
    }
    .ai-help-panel {
        width: 100%;
        max-height: 250px;
    }
    .ai-help-panel.collapsed {
        width: 100%;
        max-height: 48px;
    }
    .help-content {
        max-height: 200px;
    }
    .ai-testing-layout .ai-chat-container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .ai-help-panel {
        max-height: 180px;
    }
    .help-content {
        max-height: 120px;
        padding: 12px;
    }
    .browser-controls {
        flex-direction: column;
        gap: 6px;
    }
    .ai-chat-messages {
        padding: 16px;
    }
    .ai-chat-input-area {
        padding: 12px 16px;
    }
}
