/* --- Global Styles & Variables --- */
:root {
  --background-color: #f9fafb;
  --card-background-color: #ffffff;
  --border-color: #e5e7eb;
  --text-color: #1f2937;
  --text-color-light: #6b7280;
  --primary-color: #111827;
  --primary-color-hover: #374151;
  --accent-color: #3b82f6;
  --error-color: #ef4444;
  --info-text-color: #1e40af;
  --info-bg-color: #eff6ff;
  --info-border-color: #dbeafe;
  --border-radius: 6px;
  --box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

body {
  background-color: var(--background-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-color);
  margin: 0;
  padding: 2rem;
}

hr {
  margin: 50px;
  border: 1px solid var(--border-color);
}

/* --- Layout Containers --- */
.container {
  max-width: 800px;
  margin: 2rem auto;
}

.card {
  background-color: var(--card-background-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 1rem 2rem 2rem;
}

/* --- Typography --- */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 0;
}

p {
  color: var(--text-color-light);
}

a {
  color: var(--accent-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Form Elements --- */
.form-group,
.display_block {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

input[type="email"],
input[type="password"],
input[type="text"],
select,
textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: #fff;
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"] {
  padding: 5px;
}

select:not([multiple]) {
  padding: 0.75rem;
}

select[multiple] {
  padding: 0.5rem; /* Provides internal spacing */
  height: 12rem; /* Makes it tall enough to show multiple options */
  background-image: none; /* A listbox doesn't have a dropdown arrow */
  resize: vertical; /* Allows dragging the corner */
  min-height: 8rem; /* Prevents it from becoming too small */
}

select[multiple] option {
  padding: 0.5rem 0.75rem;
  border-radius: 4px; /* Optional: gives a nice look to selected items */
}

select[multiple] option:checked {
  background-color: var(--accent-color);
  color: white;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

textarea {
  min-height: 200px;
  resize: vertical;
}

textarea:read-only {
  background-color: #f9fafb;
  cursor: default;
}

/* --- Button --- */
.btn {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-color-hover);
}

/* --- Utility & Message Classes --- */
.cost-display {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-color-light);
}

.cost-display span {
  font-weight: 600;
  color: var(--text-color);
}

#message {
  position: fixed; /* Makes the element stay in one place even when scrolling */
  top: 0;          /* Aligns it to the top of the viewport */
  left: 0;         /* Aligns it to the left of the viewport */
  width: 100%;     /* Makes it span the full width of the viewport */
  z-index: 1000;   /* Ensures it sits on top of all other content */
  box-sizing: border-box; /* Ensures padding is included in the element's total width */

  padding: 1rem;
  margin-bottom: 0;

  background: var(--card-background-color);
  border: 1px solid var(--border-color);
  text-align: center;
}

#message .error {
  color: var(--error-color);
  background-color: #fef2f2;
  border-color: #fecaca;
}

#message .info { /* NEW: Informational message style */
  color: var(--info-text-color);
  background-color: var(--info-bg-color);
  border-color: var(--info-border-color);
}

#message:not(:empty) {
   display: block;
}

#message:empty {
   display: none;
}

.warning-msg {
  color: #92400e; /* Dark Orange/Brown */
  background-color: #fffbeb; /* Light Yellow */
  border: 1px solid #fcd34d; /* Yellow Border */
  padding: 0.5rem;
  border-radius: 4px;
  margin-top: 0.5rem;
  white-space: pre-wrap; /* Preserve formatting */
}

.hidden {
  display: none;
}

.verification-controls {
  margin-top: 10px;
}

.btn-resend {
  width: auto;
  padding: 5px 10px;
  font-size: 0.9rem;
  background-color: #d97706; /* Darker orange for button */
  color: white; /* Ensure text is readable */
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
}

.btn-resend:hover {
  background-color: #b45309;
}

.text-success {
  margin-left: 10px;
  font-size: 0.9rem;
  color: green;
}

.text-error {
  margin-left: 10px;
  font-size: 0.9rem;
  color: var(--error-color);
}

/* --- Loader Animation --- */
#loader { /* MODIFIED: Redesigned spinner */
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-color);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  animation: spin 1s linear infinite;
}

#body.loading {
  opacity: 0.4;
  pointer-events: none;
}

#body.loading textarea {
  pointer-events: auto;
}

#body.loading #company-link {
  pointer-events: auto;
}

#loader.notloading {
  visibility: hidden;
}

#body.notloading {
  opacity: 1.0;
}

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

.company-link-wrapper a[href=""] {
  color: var(--text-color-light);
  pointer-events: none;
  cursor: default;
}

.company-link-wrapper a[href=""]:hover {
  text-decoration: none;
}

#companies {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

#companies td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

/* Adds "zebra striping" for better readability */
#companies tbody tr:nth-of-type(even) {
  background-color: var(--background-color);
}

/* Remove the bottom border from the final row for a cleaner look */
#companies tbody tr:last-child td {
  border-bottom: none;
}

/* Make the company name (the 2nd column) stand out */
#companies td:nth-child(2) {
  font-weight: 500;
  color: var(--text-color);
}

/* Style for the 'view' buttons to be less prominent */
#companies button {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color-light);
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

#companies button:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background-color: var(--info-bg-color);
}

/* --- Modal Window Styles --- */

#json-modal-overlay {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(31, 41, 55, 0.7); /* Semi-transparent background */
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

/* This class will be added by JavaScript to show the modal */
#json-modal-overlay.show {
  display: flex;
}

.modal-content {
  background-color: var(--card-background-color);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  position: relative;
  width: 90%;
  max-width: 600px;
}

.modal-content h3 {
  margin-top: 0;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  font-size: 1.75rem;
  font-weight: bold;
  color: var(--text-color-light);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-color);
}

#json-data-container {
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  max-height: 60vh; /* Make the content scrollable if it's too long */
  overflow-y: auto;
  white-space: pre-wrap; /* Wrap long lines */
  word-break: break-all; /* Break long strings */
}

.card .tool-list {
  list-style-type: none; /* Removes the bullet points */
  padding: 0;
  margin-top: 1.5rem;
}

.card .tool-list li {
  margin-bottom: 1rem; /* Adds vertical space between links */
}

.card .tool-list li a {
  display: block;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  text-align: center;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
}

.card .tool-list li a:hover {
  text-decoration: none;
  border-color: var(--accent-color);
  color: var(--accent-color);
  background-color: var(--info-bg-color);
}

/* --- Prompt Version Cards --- */

#prompt_verions {
  /* Optional: limit height and scroll if there are many versions */
  max-height: 400px;
  overflow-y: auto;
  margin-top: 0.5rem;
  /* Use margin on container instead of children to prevent scrollbar overlap if needed */
  padding-right: 4px;
}

#prompt_verions > div {
  display: flex;
  flex-direction: row;
  align-items: center; /* Vertically center the radio button with the text block */
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: #fff; /* Clean card look */
  transition: all 0.2s ease-in-out;
}

/* Hover effect for cards */
#prompt_verions > div:hover {
  border-color: var(--accent-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Style the radio button */
#prompt_verions input[type="radio"] {
  width: 1.2rem;
  height: 1.2rem;
  margin-right: 1rem;
  flex-shrink: 0; /* Prevent radio button from squishing */
  cursor: pointer;
  accent-color: var(--accent-color);
}

/* Container for the text paragraphs */
#prompt_verions > div > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* General paragraph styles within the version card */
#prompt_verions p {
  margin: 0;
  line-height: 1.4;
  color: var(--text-color);
}

/* Specific styling based on the order generated by embed.js */
/* 1. Date */
#prompt_verions p:nth-of-type(1) {
  font-size: 0.75rem;
  color: var(--text-color-light);
}

/* 2. Author */
#prompt_verions p:nth-of-type(2) {
  font-size: 0.75rem;
  color: var(--text-color-light);
  margin-bottom: 0.25rem;
}

/* 3. Message */
#prompt_verions p:nth-of-type(3) {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-color);
}

/* test_auth.html */
.auth-container {
  max-width: 500px;
  margin: 2rem auto;
  padding: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}

.section {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.auth-container input {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
}

.auth-container button {
  width: 100%;
  padding: 0.5rem;
  background: #111827;
  color: white;
  border: none;
  cursor: pointer;
}

.auth-container button:hover {
  background: #374151;
}

.auth-container pre {
  background: #f3f4f6;
  padding: 1rem;
  overflow-x: auto;
}

#auth-status {
  text-align:center;
  margin-bottom: 20px;
}

button#logout {
  background-color: #ef4444;
  color: white;
  margin-top: 10px;
}

p.reset-password {
  text-align: center;
  margin-top: 0.5rem;
}

/* --- Modal & Org Manager Styles --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(31, 41, 55, 0.7);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.show {
  display: flex;
}

.hidden {
  display: none !important;
}

.org-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.org-header h2 {
  margin: 0;
}

.org-meta {
  margin-bottom: 1rem;
}

.btn-auto-width {
  width: auto;
}

.btn-logout {
  margin-top: 2rem;
  background-color: #ef4444;
  color: white;
}

.btn-logout:hover {
  background-color: #dc2626;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  background-color: var(--background-color);
}

.action-link {
  color: var(--accent-color);
  cursor: pointer;
  text-decoration: underline;
  margin-right: 1rem;
  margin-left: 1rem;
  border: none;
  background: none;
  font-size: 1rem;
  padding: 0;
}

.action-link:hover {
  color: var(--primary-color);
}

#btn-login {
  margin-bottom: 1rem;
}

hr.login {
  margin: 1.5rem 0;
}

#btn-google-login {
  background-color: #db4437;
  color: white;
}
