/* style.css */

/* 
   ChatGPT-inspired styling with light/dark mode toggle 
   via prefers-color-scheme. All colors, spacing, button 
   shapes, and typography are consistent between modes.
*/

/* Light mode (default) */
:root {
  /* Colors */
  --body-bg-color: #f7f7f8;           /* Light background */
  --container-bg-color: #ffffff;      /* White container background */
  --text-color: #202123;              /* Dark text */
  --link-color: #10a37f;              /* Teal/green accent */
  --link-hover: #0e8f73;
  --danger-color: #dc2626;
  --danger-hover: #b91c1c;

  /* We reuse the accent color for primary buttons */
  --primary-color: var(--link-color);
  --primary-hover: var(--link-hover);

  /* Shared */
  --border-radius: 6px;
  --gray-mid: #cbd5e1; /* border color or input border in light mode */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", 
                 "Helvetica Neue", "Noto Sans", sans-serif;
}

/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
  :root {
    --body-bg-color: #202123;         /* ChatGPT dark body */
    --container-bg-color: #343541;    /* Slightly lighter dark container */
    --text-color: #ececf1;            /* Light text */
    --link-color: #10a37f;            /* Teal accent */
    --link-hover: #0e8f73;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;

    /* Same logic for button accent colors */
    --primary-color: var(--link-color);
    --primary-hover: var(--link-hover);

    --gray-mid: #565869;
  }
}

/* Base resets / Body styling */
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background: var(--body-bg-color);
  color: var(--text-color);
}

/* Container with some padding and border radius */
.container {
  max-width: 900px;
  margin: 2rem auto;
  background: var(--container-bg-color);
  padding: 1.5rem;
  border-radius: var(--border-radius);
}

/* Utility for full height centering (e.g., login) */
.full-height-center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

/* Headers */
h1, h2 {
  margin-top: 0;
}

/* Top bar within .container */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* Buttons & Links */
header a,
.btn {
  text-decoration: none;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s ease;
}

header a:hover,
.btn:hover {
  background: var(--primary-hover);
}

/* Danger variant */
.btn-danger {
  text-decoration: none;
  background: var(--danger-color);
  color: #fff;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s ease;
}
.btn-danger:hover {
  background: var(--danger-hover) !important;
}

/* Basic table styling */
.table-list {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
.table-list th,
.table-list td {
  border: 1px solid var(--gray-mid);
  padding: 0.6rem;
}

/* Inputs, textareas, selects */
textarea,
select,
input[type="text"],
input[type="password"],
input[type="number"] {
  border: 1px solid var(--gray-mid);
  background: none; /* let background match container in light mode, or dark in dark mode */
  color: var(--text-color);
  border-radius: var(--border-radius);
  padding: 0.6rem;
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
}

textarea {
  resize: vertical;
}

/* A multi-select field with fixed size */
.select-multi {
  width: 200px;
  height: 6em;
}

/* Basic spacing for form fields */
.form-field {
  margin-bottom: 1rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}
.modal-backdrop.active {
  display: flex;
}
.modal {
  background: var(--container-bg-color);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  max-width: 500px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  margin: 0 1rem;
}
.modal h2 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.125rem;
  font-weight: 600;
}

/* Placeholder select options container */
.options-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* "Other" input container hidden by default */
.input-container {
  display: none;
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.input-container.active {
  display: flex;
}

/* Modal footer */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* .template-card, .template-header, etc. for manage_templates page */
.template-card {
  border: 1px solid var(--gray-mid);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.template-header {
  display: flex; 
  justify-content: space-between;
  align-items: center;
}

/* For details summary pointer */
details summary {
  cursor: pointer;
}

/* For text wrapping in <pre> */
.pre-wrap {
  white-space: pre-wrap;
}

/* Buttons row in editor */
.buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Responsive layout: smaller margin, narrower container on mobile */
@media screen and (max-width: 640px) {
  .container {
    margin: 1rem;
    padding: 1rem;
  }
}
