/* styles.css */
.openrouter-chat-container {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	background-color: var(--background-primary);
	position: relative;  /* Make sure container is positioned relative */
}

.openrouter-chat-header {
	padding: 12px 16px;
	border-bottom: 1px solid var(--background-modifier-border);
	display: flex;
	flex-direction: column;
	gap: 8px;
	background-color: var(--background-secondary);
	z-index: 10; /* Ensure header is above other elements */
}

.openrouter-chat-header h3 {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
}

.openrouter-model-select-container {
	display: flex;
	align-items: center;
	gap: 8px;
}

.openrouter-model-label-container {
	display: flex;
	align-items: center;
	gap: 6px;
}

.openrouter-model-select {
	flex-grow: 1;
	max-width: 180px;
	height: 30px;
	border-radius: 4px;
	border: 1px solid var(--background-modifier-border);
	padding: 0 8px;
	background-color: var(--background-primary);
}

.openrouter-model-search {
	flex-grow: 1;
	height: 28px;
	border-radius: 4px;
	border: 1px solid var(--background-modifier-border);
	padding: 0 8px;
	background-color: var(--background-primary);
	margin-right: 8px;
}

.openrouter-refresh-button,
.openrouter-websearch-button,
.openrouter-metrics-button {
	font-size: 14px;
	width: 24px;
	height: 24px;
	padding: 0;
	border-radius: 4px;
	background-color: var(--interactive-normal);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease;
}

.openrouter-refresh-button:hover,
.openrouter-websearch-button:hover,
.openrouter-metrics-button:hover {
	background-color: var(--interactive-hover);
}

.openrouter-refresh-button:active,
.openrouter-websearch-button:active,
.openrouter-metrics-button:active {
	background-color: var(--interactive-accent);
	color: var(--text-on-accent);
}

/* Web search button active state */
.openrouter-websearch-button.active {
	background-color: var(--interactive-accent);
	color: var(--text-on-accent);
}

/* Metrics button and popup */
.openrouter-message {
	position: relative;
}

.openrouter-metrics-button {
	position: absolute;
	top: 12px;
	right: 40px; /* Position to the left of the copy button */
	opacity: 0.7;
}

.openrouter-metrics-button:hover {
	opacity: 1;
}

.openrouter-metrics-popup {
	position: absolute;
	top: -120px;
	right: 0;
	width: 200px;
	background-color: var(--background-secondary);
	border: 1px solid var(--background-modifier-border);
	border-radius: 6px;
	padding: 8px 12px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
	z-index: 100;
	font-size: 12px;
}

.openrouter-metrics-popup div {
	margin: 4px 0;
	color: var(--text-normal);
}

/* Input container at the top */
.openrouter-input-container {
	border-bottom: 1px solid var(--background-modifier-border);
	padding: 12px 16px;
	display: flex;
	gap: 10px;
	background-color: var(--background-primary);
	z-index: 9; /* Ensure input is above messages but below header */
	position: sticky;
	top: 0;
}

/* Messages container comes after the input */
.openrouter-messages-container {
	flex-grow: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-bottom: 0;
}

.openrouter-message {
	margin-bottom: 4px;
	border-radius: 8px;
	padding: 12px 16px;
	max-width: 85%;
	position: relative;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.openrouter-message-user {
	align-self: flex-end;
	background-color: var(--interactive-accent);
	color: var(--text-on-accent);
}

.openrouter-message-assistant {
	align-self: flex-start;
	background-color: var(--background-secondary);
	color: var(--text-normal);
	padding-right: 32px; /* Make room for copy button */
}

.openrouter-message-error {
	align-self: center;
	background-color: var(--background-modifier-error);
	color: var(--text-error);
}

.openrouter-message-role {
	font-weight: bold;
	margin-bottom: 8px;
}

.openrouter-message-content {
	white-space: pre-wrap;
	word-break: break-word;
	line-height: 1.5;
}

.openrouter-message-content p {
	margin-top: 0;
}

.openrouter-copy-button {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 24px;
	height: 24px;
	background-color: transparent;
	border: none;
	cursor: pointer;
	opacity: 0.7;
	transition: opacity 0.2s ease;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
}

.openrouter-copy-button:hover {
	opacity: 1;
	background-color: var(--background-modifier-hover);
}

.openrouter-copy-button.copied {
	color: var(--text-accent);
}

.openrouter-input {
	flex-grow: 1;
	min-height: 38px;
	max-height: 150px;
	resize: none;
	padding: 8px 12px;
	border-radius: 6px;
	border: 1px solid var(--background-modifier-border);
	background-color: var(--background-primary);
	color: var(--text-normal);
	font-family: inherit;
	line-height: 1.5;
	overflow-y: auto;
}

.openrouter-input:focus {
	outline: none;
	border-color: var(--interactive-accent);
	box-shadow: 0 0 0 2px rgba(var(--interactive-accent-rgb), 0.2);
}

.openrouter-send-button,
.openrouter-clear-button {
	padding: 8px 16px;
	border-radius: 6px;
	cursor: pointer;
	border: none;
	font-weight: 500;
	transition: background-color 0.2s ease;
	height: 38px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.openrouter-send-button {
	background-color: var(--interactive-accent);
	color: var(--text-on-accent);
}

.openrouter-send-button:hover {
	background-color: var(--interactive-accent-hover);
}

.openrouter-clear-button {
	background-color: var(--background-modifier-border);
	color: var(--text-normal);
}

.openrouter-clear-button:hover {
	background-color: var(--background-modifier-hover);
}

/* Thinking indicator */
.openrouter-thinking {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	background-color: var(--background-secondary-alt);
	border-radius: 8px;
	align-self: flex-start;
	margin-bottom: 8px;
	font-style: italic;
	color: var(--text-muted);
	animation: pulse 1.5s infinite;
}

@keyframes pulse {
	0% { opacity: 0.6; }
	50% { opacity: 1; }
	100% { opacity: 0.6; }
}

/* Model filtering and grouping */
.openrouter-model-filter {
	margin-top: 12px;
	padding: 8px 0;
	display: flex;
	gap: 12px;
	align-items: center;
	flex-wrap: wrap;
}

.openrouter-model-filter-options {
	display: flex;
	gap: 8px;
	align-items: center;
}

.openrouter-model-filter-option {
	font-size: 12px;
	padding: 4px 8px;
	border-radius: 12px;
	background-color: var(--background-secondary);
	cursor: pointer;
}

.openrouter-model-optgroup {
	font-weight: bold;
	border-bottom: 1px solid var(--background-modifier-border);
	padding: 4px 8px;
	background-color: var(--background-secondary-alt);
}

/* Modal styles */
.openrouter-modal {
	padding: 20px;
}

.openrouter-modal h2 {
	margin-top: 0;
	margin-bottom: 16px;
	font-size: 20px;
}

.openrouter-modal-model-container {
	margin-bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.openrouter-modal-model-select {
	width: 100%;
	height: 32px;
	border-radius: 4px;
	border: 1px solid var(--background-modifier-border);
	padding: 0 8px;
	background-color: var(--background-primary);
}

.openrouter-modal-prompt,
.openrouter-modal-response {
	margin-bottom: 16px;
	padding: 12px;
	border-radius: 4px;
	background-color: var(--background-secondary);
	max-height: 200px;
	overflow-y: auto;
	white-space: pre-wrap;
	font-family: var(--font-monospace);
	font-size: 14px;
}

.openrouter-modal-response {
	min-height: 100px;
}

.openrouter-modal-buttons {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

.openrouter-modal-generate,
.openrouter-modal-insert,
.openrouter-modal-cancel {
	padding: 8px 16px;
	border-radius: 4px;
	cursor: pointer;
	border: none;
	font-weight: 500;
	transition: background-color 0.2s ease;
}

.openrouter-modal-generate {
	background-color: var(--interactive-accent);
	color: var(--text-on-accent);
}

.openrouter-modal-generate:hover {
	background-color: var(--interactive-accent-hover);
}

.openrouter-modal-insert {
	background-color: var(--background-modifier-success);
	color: var(--text-on-accent);
}

.openrouter-modal-insert:hover {
	background-color: var(--background-modifier-success-hover);
}

.openrouter-modal-insert[disabled] {
	opacity: 0.5;
	cursor: not-allowed;
}

.openrouter-modal-cancel {
	background-color: var(--background-modifier-border);
	color: var(--text-normal);
}

.openrouter-modal-cancel:hover {
	background-color: var(--background-modifier-hover);
}

/* About section in settings */
.openrouter-about {
	margin-top: 24px;
	padding: 16px;
	background-color: var(--background-secondary);
	border-radius: 8px;
}

.openrouter-about p {
	margin: 0;
}

.openrouter-model-refresh-container {
	margin-bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.openrouter-last-update {
	font-size: 12px;
	color: var(--text-muted);
	margin-top: 4px;
	margin-bottom: 16px;
}

.openrouter-model-search-container {
	flex-grow: 1;
	max-width: 300px;
}

.openrouter-free-models-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
}

.openrouter-free-models-label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	cursor: pointer;
}

.openrouter-free-models-label input[type="checkbox"] {
	margin: 0;
}