body {
  font-family: Arial;
  margin: 40px;
  background: #121212; /* Default dark background */
  color: #f1f1f1; /* Default light text */
  transition: 0.3s;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23333333' fill-opacity='0.1'%3E%3Ccircle cx='30' cy='30' r='3'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Light mode overrides */
body.light {
  background: #f4f4f4;
  color: #000;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23cccccc' fill-opacity='0.1'%3E%3Ccircle cx='30' cy='30' r='3'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

textarea,
button,
select {
  width: 98%;
  margin-top: 10px;
  padding: 10px;
  font-size: 16px;
  transition: 0.3s;
  background: #2b2b2b; /* Default dark */
  color: #f1f1f1;
  border: 1px solid #555;
}

/* Light mode overrides for form elements */
body.light textarea,
body.light button,
body.light select {
  background: #fff;
  color: #000;
  border: 1px solid #ccc;
}

button {
  margin-top: 0;
  cursor: pointer;
  background: #333; /* Default dark */
  color: #f1f1f1;
  border: 1px solid #555;
}

button:hover {
  background: #444;
  transform: translateY(-1px);
}

body.light button {
  background: #fff;
  color: #000;
  border: 1px solid #ccc;
}

body.light button:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
}

.center {
  text-align: center;
}

.question {
  color: #6db4ff; /* Lighter blue for dark mode */
}

body.light .question {
  color: blue;
}

.answer {
  margin-top: 5px;
  color: #000;
}

body.light .answer {
  color: #333;
}

.container {
  width: 95%;
  margin: auto;
  background: rgba(34, 34, 34, 0.95); /* Default dark with transparency */
  color: #f1f1f1;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  transition: 0.3s;
}

body.light .container {
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

body.light .container .summary {
  color: #555;
}

.container .summary {
  color: #aaa;
}
  
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #444;
}

body.light .top-bar {
  border-bottom: 2px solid #ddd;
}

.top-bar h2 {
  text-align: left;
  margin: 0;
  font-size: 1.8rem;
  background: linear-gradient(45deg, #007bff, #28a745);
  -webkit-background-clip: text;
  background-clip: text;
}

.gradient-text {
  background: linear-gradient(45deg, #007bff, #28a745);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.top-bar button {
  text-align: right;
  font-size: 16px;
  padding: 10px;
  cursor: pointer;
}

.top-bar-buttons {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

#registerBtn, #loginBtn, #logoutBtn, #changePasswordBtn, #promptBtn, #configBtn, #profileBtn, #darkModeBtn {
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-width: 40px;
  font-size: 16px;
  gap: 0;
}

.top-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.top-actions button {
  flex: 1;
  min-width: 120px;
}

#answerBox {
  margin-top: 20px;
  margin-bottom: 20px;
  background: #2b2b2b; /* Default dark */
  color: #f1f1f1;
  min-height: 120px;
  white-space: pre-wrap;
  transition: 0.3s;
  max-height: 400px;
  overflow-y: auto;
  padding: 15px;
  border: 2px solid #555;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-style: italic;
}

body.light #answerBox {
  background: #f8f9fa;
  color: #000;
  border: 2px solid #ddd;
}

#historyBox {
  margin-top: 20px;
  max-height: 500px;
  overflow-y: auto;
  padding: 10px;
}

#aiLogBox {
  margin-top: 20px;
  max-height: 500px;
  overflow-y: auto;
  padding: 10px;
}

.bottom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

button {
  flex: 1;
  min-width: 120px;
  padding: 12px;
  border-radius: 4px;
  font-weight: 600;
}

#submitButton {
  background: linear-gradient(45deg, #28a745, #20c997);
  color: white;
  border: none;
  font-size: 16px;
  width: 100%;
}

#submitButton:hover {
  background: linear-gradient(45deg, #1e7e34, #17a2b8);
}

.history-block {
  margin-top: 10px;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #007bff;
}

.history-block:nth-child(odd) {
  background: #2b2b2b; /* Dark mode default */
}

.history-block:nth-child(even) {
  background: #3b3b3b; /* Dark mode default */
}

body.light .history-block:nth-child(odd) {
  background: #e3f2fd;
}

body.light .history-block:nth-child(even) {
  background: #f1f8e9;
}

.ai-log-block {
  margin-top: 10px;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #28a745;
}

.ai-log-block:nth-child(odd) {
  background: #2b2b2b; /* Dark mode default */
}

.ai-log-block:nth-child(even) {
  background: #3b3b3b; /* Dark mode default */
}

body.light .ai-log-block:nth-child(odd) {
  background: #e8f5e8;
}

body.light .ai-log-block:nth-child(even) {
  background: #fff3cd;
}

.qa-block pre {
  background: #333; /* Dark mode default */
  color: #f1f1f1;
  padding: 15px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: 1px solid #555;
}

body.light .qa-block pre {
  background: #f8f9fa;
  color: #000;
  border: 1px solid #ddd;
}

.ai-container, .ai-prompt-container {
  display: none;
  flex-direction: column;
  margin: 20px 0;
  gap: 15px;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #444;
}

body.light .ai-container, body.light .ai-prompt-container {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid #ddd;
}

.ai-container label, .ai-prompt-container label {
  margin-bottom: 5px;
  font-weight: bold;
  color: #007bff;
}

body.light .ai-container label, body.light .ai-prompt-container label{
  color: #0056b3;
}

.template-section {
  padding: 0;
}

#systemPrompt, #personaInput, #taskInput, #instructionsInput, #contextInput, #examplesInput {
  width: 100%;
  border-radius: 8px;
}

#clearSelectedBtn {
  width: 100%;
  display: none;
}

#systemPromptSelect {
  max-height: 40px;
}

/* Question box styling with dark mode as default */
#questionBox {
  display: block;
  margin: 16px auto;
  margin-top: 10px;
  width: 100%;
  background-color: #333;
  color: #fff;
  padding: 15px;
  border-radius: 8px;
  border: 2px solid #007bff;
  transition: 0.3s;
  font-size: 16px;
  resize: vertical;
}

#questionBox:focus, #systemPrompt:focus {
  outline: none;
  border-color: #28a745;
  box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}

#questionBox::placeholder, #systemPrompt::placeholder {
  color: #bbb; /* Light gray placeholder as default */
  opacity: 1;
}

/* Light mode overrides for question box */
body.light #questionBox, body.light #systemPrompt {
  background-color: #fff;
  color: #000;
  border: 2px solid #007bff;
}

body.light #questionBox::placeholder, #systemPrompt::placeholder {
  color: #666;
}

#systemPrompt {
    margin-top: 0;
    margin-bottom: 0;
}

#spinner {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
}

#spinner div {
  border: 8px solid #333; /* Darker for dark mode */
  border-top: 8px solid #007bff;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
}

body.light #spinner div {
  border: 8px solid #f3f3f3;
  border-top: 8px solid #007bff;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

  .row { flex-direction: row; flex-wrap: wrap; gap:12px; width: 100%; }
  .select-group { flex:1 1 calc(50% - 12px); }
  .bottom-actions { grid-template-columns: repeat(4,1fr); }
  #submitButton { grid-column: span 1; }

.select-group {
  flex: 1 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.05);
  padding: 15px;
  border-radius: 8px;
}

body.light .select-group {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid #ddd;
}

.select-group label {
  margin-bottom: 8px;
  font-weight: 600;
}

.select-group input[type="range"] {
  margin-bottom: 8px;
  accent-color: #007bff;
}

.select-group input[type="number"] {
  margin-bottom: 8px;
}

.select-group input,
.select-group select {
  width: 100%;
  margin-bottom: 0.25rem;
}

.ai-image {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Bootstrap override to maintain custom styling */
.container-fluid,
.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  width: 95% !important;
  max-width: none !important;
}

/* Section headers styling */
h2.center {
  background: linear-gradient(45deg, #007bff, #28a745);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  margin: 20px 0;
}

hr {
  border: none;
  height: 2px;
  background: linear-gradient(45deg, #007bff, #28a745);
  margin: 10px 0;
}

footer {
    text-align:center;
    margin-top:20px;
    font-size:14px;
}