body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
  background: #f4f4f4;
}

h1 {
  color: #333;
}

#messageContainer {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 1000;
  min-width: 200px;
  max-width: 400px;
  pointer-events: none;
}

#messageContainer.hidden {
  display: none;
}

.message-item {
  padding: 12px 20px;
  margin-bottom: 12px;
  border-radius: 4px;
  background-color: #4CAF50;
  color: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: all 0.3s ease-in-out;
  overflow: hidden;
  pointer-events: none;
}

.message-item.error {
  background-color: #f44336;
}

form {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

label {
  display: block;
  margin-bottom: 5px;
  color: #666;
}

input[type=text],
input[type=password],
textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 20px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
}

.simple-text {
  margin-bottom: 5px;
}

.set-default {
  font-size: 12px;
}

.form-row {
  position: relative;
}

.set-default {
  position: absolute;
  top: -0px;
  right: 0;
  font-size: 0.8em;
}

input[type=submit],
input[type=button] {
  padding: 10px 15px;
  background: #5cb85c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 5px;
}

select#document_section_key {
  padding: 10px 15px;
  background: #5cb85c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 5px;
  margin-bottom: 5px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3e%3cpath fill='white' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 8px 10px;
  vertical-align: middle;
  margin-top: 5px;
}

select#document_section:hover {
  background: #4cae4c;
}

select#document_section:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(92, 184, 92, 0.5);
}

#saveButtonPublic,
#saveButtonPrivate,
#saveButtonAsPublic,
#saveButtonAsPrivate,
#loadButton,
#clearButton_start_text,
#saveButtonMemory,
#downloadZipButton,
#document_section,
#loadButtonMemory {
  float: right;
  margin-left: 5px;
  margin-bottom: 5px;
}

input[type=submit]:hover,
input[type=button]:hover {
  background: #4cae4c;
}

option {
  padding: 10px 15px;
}

#popup, #fileInfoModal {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 20px;
  width: auto;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  border: 1px solid #ccc;
  overflow: auto;
  max-height: 95%;
}

#server_offline {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background-color: white;
  padding: 20px;
  border: 1px solid #ccc;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

#overlay,
#server_status {
  position: fixed;
  display: none;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 200;
}

#template {
  width: 50ch;
}

.small_text {
  font-size: 0.55em;
  color: #666;
}

#popupList {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-group-item {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f8f8;
}

#server_status p {
  color: red;
}

.list-group-item:last-child {
  margin-bottom: 0;
}

.file-name {
  margin-right: 10px;
  flex-grow: 1;
}

.btn {
  padding: 5px 10px;
  color: #fff;
  text-align: center;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.btn-danger {
  background-color: #dc3545;
}

.btn-danger:hover {
  background-color: #c82333;
}

input[type=submit][disabled],
input[type=button][disabled] {
  background: #cccccc;
  color: #666666;
  cursor: not-allowed;
}

input[type=submit][disabled]:hover,
input[type=button][disabled]:hover {
  background: #cccccc;
  color: #666666;
}

.input-group input[type=text] {
  width: 10ch;
  display: inline-block;
}

#debug {
  margin-left: 5px;
  background-color: #cccccc;
  color: #666666;
  cursor: not-allowed;
}

#debug:hover {
  background-color: #cccccc;
  color: #666666;
}

.toggle-container {
  display: flex;
  align-items: center;
  padding: 5px;
}

.toggle-label {
  margin-right: 10px;
}

.toggle-checkbox {
  height: 0;
  width: 0;
  visibility: hidden;
}

.toggle-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  width: 70px;
  height: 26px;
  background: grey;
  border-radius: 100px;
  position: relative;
  transition: background-color .2s;
}

.toggle {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 45px;
  transition: 0.2s;
  background: #ffffff;
  box-shadow: 0 2px 2px 0 rgba(10, 10, 10, 0.29);
}

.toggle-checkbox:checked+.toggle {
  left: calc(100% - 2px);
  transform: translateX(-100%);
}

.toggle-checkbox:checked+.toggle-switch {
  background-color: #4bd763;
}

.toggle-state-true,
.toggle-state-false {
  margin-left: 10px;
}

/* files.ejs styles */
#fileBasicInfo {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

#fileBasicInfo label {
  margin-right: 5px;
  flex: 0 0 auto;
}

#fileBasicInfo p {
  margin: 0;
  margin-right: 20px;
  flex: 1 1 auto;
}

.file-manager-container {
  margin-bottom: 20px;
}

.file-manager-controls {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
}

.file-type-dropdown {
  padding: 5px;
  margin-right: 10px;
}

.file-upload-input {
  margin-right: 10px;
}

.upload-button {
  padding: 5px 10px;
  background-color: #4CAF50;
  color: white;
  border: none;
  cursor: pointer;
}

.file-list {
  list-style-type: none;
  padding: 0;
}

.parent-item {
  margin-bottom: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  padding-left: 20px;
}

.file-name {
  margin-right: 10px;
}

.file-type {
  margin-right: 10px;
  color: #888;
}

.child-item {
  padding-left: 40px;
  position: relative;
}

.child-item::before {
  content: "▶";
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #888;
}

.child-list {
  list-style-type: none;
  padding-left: 20px;
  margin-top: 5px;
}

.delete-button {
  padding: 3px 8px;
  background-color: #f44336;
  color: white;
  border: none;
  cursor: pointer;
}

/* Make all containers fluid */
.container {
    max-width: 100% !important;
    padding-left: 15px;
    padding-right: 15px;
}

/* navigation */
.nav-container {
    background-color: #295d1b;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav {
    flex: 1;
}

nav ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

nav ul li {
    display: inline;
    margin-right: 10px;
}

.page-title {
    color: white;
    font-weight: bold;
    padding: 5px 15px;
    text-align: right;
    font-size: 1.1rem;
}

nav ul li a {
  color: white;
  text-decoration: none;
  padding: 5px 10px;
}

nav ul li a:hover {
  background-color: #555;
}

nav ul li a.active {
  background-color: #555;
  font-weight: bold;
}

#loginForm {
  width: 40%;
  min-width: 300px;
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.file-info-close {
  cursor: pointer;
}

#fileResult {
  margin-top: 20px;
}

.templates-section {
  margin-top: 20px;
  padding: 20px;
  background-color: #f5f5f5;
  border-radius: 8px;
}

.templates-section h3 {
  margin-top: 0;
  margin-bottom: 10px;
}

.download-templates-container {
  margin-bottom: 10px;
}

.backup-templates-container {
  margin-bottom: 10px;
}

.upload-templates-container {
  display: flex;
  align-items: center;
}

.templates-upload-input {
  margin-right: 10px;
}

.loading {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #3498db;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

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

/* file viewer */
.view-icon {
  cursor: pointer;
  margin-right: 5px;
}

.file-contents-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  max-width: 80%;
  max-height: 80%;
  overflow: auto;
}

.file-contents-popup h3 {
  margin-top: 0;
}

.file-contents-popup textarea {
  width: 100%;
  height: 400px;
  resize: none;
  margin-bottom: 10px;
}

.close-button {
  padding: 5px 10px;
  background-color: #f44336;
  color: white;
  border: none;
  cursor: pointer;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #ccc;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

/* Dropdown styles */
.nav-menu {
  display: flex;
  align-items: center;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropbtn {
  background-color: #295d1b;
  color: white;
  padding: 5px 10px;
  border: none;
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #295d1b;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1100;
}

.dropdown-content a {
  color: white;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content a:hover {
  background-color: #3a7d25;
}

.dropdown-content {
  flex-direction: column;
}

.dropdown:hover .dropdown-content,
.dropdown-content:hover {
  display: block;
}

nav ul li {
  display: inline-block;
  margin-right: 10px;
}

nav ul li a,
.dropbtn {
  color: white;
  text-decoration: none;
  padding: 5px 10px;
  display: inline-block;
}

nav ul li a:hover,
.dropdown:hover .dropbtn {
  background-color: #3a7d25;
}

nav ul li a.active {
  background-color: #3a7d25;
  font-weight: bold;
}

.active-dropdown > .dropbtn {
  background-color: #3a7d25;
  font-weight: bold;
}

.active-dropdown > .dropbtn::after {
  content: '▼';
  margin-left: 5px;
  font-size: 0.8em;
}

.dropdown-content a.active {
  background-color: #3a7d25;
  font-weight: bold;
}

.template-test-popup {
  position: fixed;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.template-test-popup-content {
  background-color: white;
  padding: 20px;
  border-radius: 5px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

.template-test-file-checkboxes {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.template-test-checkbox-wrapper {
  width: 30%;
  margin-bottom: 5px;
}

.template-test-processed-template {
  white-space: pre-wrap;
  border: 1px solid #ccc;
  padding: 10px;
  margin-bottom: 20px;
  max-height: 50%;
  overflow-y: auto;
}

/* Instruction settings styles */
.instruction-settings {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
}

.setting-group {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.setting-group label {
  width: 100px;
  margin-right: 10px;
  color: #666;
}

.setting-group select {
  padding: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 100px;
}

.setting-group .creativity-slider {
  width: 150px;
  margin: 0 10px;
}

.setting-group .creativity-value {
  width: 40px;
  text-align: right;
  color: #666;
}

/* Enhanced button styling for blue gradient background in file manager */
.document-header-full .btn {
  font-weight: 600;
  border-width: 2px;
  text-shadow: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.document-header-full .btn-outline-secondary {
  background-color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.8);
  color: #495057;
}

.document-header-full .btn-outline-secondary:hover {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #495057;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.document-header-full .btn-primary {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #667eea;
  font-weight: 700;
}

.document-header-full .btn-primary:hover {
  background-color: #f8f9fa;
  border-color: #f8f9fa;
  color: #5a6fd8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.document-header-full .btn-outline-warning {
  background-color: rgba(255, 193, 7, 0.95);
  border-color: rgba(255, 193, 7, 0.8);
  color: #212529;
  font-weight: 600;
}

.document-header-full .btn-outline-warning:hover {
  background-color: #ffc107;
  border-color: #ffc107;
  color: #212529;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Ensure icons in buttons are visible */
.document-header-full .btn i {
  opacity: 0.9;
}

.document-header-full .btn:hover i {
  opacity: 1;
}

/* Additional styling for better contrast on gradient backgrounds */
.document-header-full .btn-outline-primary {
  background-color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.8);
  color: #0d6efd;
  font-weight: 600;
}

.document-header-full .btn-outline-primary:hover {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #0b5ed7;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Ensure all buttons on gradient background have good contrast */
.document-header-full .btn:not(.btn-link) {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* Fix for any remaining low-contrast buttons */
.document-header-full .btn[class*="btn-outline"]:not(.btn-outline-secondary):not(.btn-outline-warning):not(.btn-outline-primary) {
  background-color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.7);
  color: #495057;
}

.document-header-full .btn[class*="btn-outline"]:not(.btn-outline-secondary):not(.btn-outline-warning):not(.btn-outline-primary):hover {
  background-color: #ffffff;
  border-color: #ffffff;
  color: #495057;
}
