/* CSS Variables for theming */
:root {
  --primary-color: #007bff;
  --primary-hover: #0056b3;
  --primary-active: #004085;
  --danger-color: #dc3545;
  --danger-hover: #c82333;
  --secondary-color: #6c757d;
  --secondary-hover: #5a6268;
  --bg-color: rgb(74, 77, 80);
  --bg-light: rgba(255, 255, 255, 0.1);
  --bg-lighter: rgba(255, 255, 255, 0.15);
  --text-color: white;
  --border-color: #ccc;
  --focus-shadow: rgba(0, 123, 255, 0.25);
  --warning-color: #ffc107;
  --error-display-duration: 5000ms;
}

body {
  color: var(--text-color);
  font-family: Arial, sans-serif;
  background: var(--bg-color);
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.input-section {
  margin-bottom: 20px;
  clear: both;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
}

textarea {
  width: 100%;
  max-width: 800px;
  height: 200px;
  font-family: monospace;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--focus-shadow);
}

button {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
  margin-right: 10px;
  transition: background 0.2s ease, transform 0.1s ease;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  background: var(--primary-active);
  transform: scale(0.98);
}

button:focus {
  outline: 2px solid var(--primary-hover);
  outline-offset: 2px;
}

button:disabled {
  background: var(--secondary-color);
  cursor: not-allowed;
  opacity: 0.6;
}

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

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

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

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

.btn-small {
  padding: 4px 8px;
  font-size: 0.85em;
}

.example-section {
  margin: 20px 0;
  padding: 15px;
  background: var(--bg-light);
  border-radius: 4px;
  margin-bottom: 30px;
  max-width: 800px;
}

.example-section p {
  margin-top: 0;
}

code {
  display: block;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  line-height: 1.6;
  overflow-x: auto;
}

.group {
  margin-top: 20px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h3 {
  width: 100%;
  max-width: 800px;
  background: var(--primary-color);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 1.05em;
  margin: 10px 0;
  user-select: none;
}

table {
  width: 100%;
  max-width: 800px;
  border-collapse: collapse;
  margin-bottom: 20px;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

th, td {
  color: black;
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  text-align: left;
}

th {
  color: black;
  background: #e9ecef;
  font-weight: bold;
}

tr:nth-child(even) {
  background: #f8f9fa;
}

tbody tr {
  transition: background-color 0.15s ease;
  cursor: move;
}

tbody tr:hover {
  background: #e3f2fd !important;
}

/* Drag and drop styles */
tbody tr[draggable="true"] {
  cursor: move;
}

tbody tr.dragging {
  opacity: 0.5;
  background: var(--primary-color) !important;
  color: white;
}

tbody tr.dragging td {
  color: white;
}

tbody tr.drag-over {
  border-top: 3px solid var(--primary-color);
}

/* Class color coding */
.class-warrior { background-color: #c79c6e !important; }
.class-cleric { background-color: #f0ebe0 !important; }
.class-paladin { background-color: #f48cba !important; }
.class-ranger { background-color: #aad372 !important; }
.class-shadowknight { background-color: #c41e3b !important; color: white !important; }
.class-druid { background-color: #ff7c0a !important; }
.class-monk { background-color: #00ffba !important; }
.class-bard { background-color: #aa8a00 !important; }
.class-rogue { background-color: #fff468 !important; }
.class-shaman { background-color: #0070dd !important; }
.class-necromancer { background-color: #8788ee !important; }
.class-wizard { background-color: #3fc7eb !important; }
.class-magician { background-color: #3fc7eb !important; }
.class-enchanter { background-color: #f48cba !important; }
.class-beastlord { background-color: #a330c9 !important; color: white !important; }

/* Duplicate warning styling */
.duplicate-warning {
  color: var(--warning-color);
  font-weight: bold;
  font-style: italic;
}

.example-link {
  color: #4db8ff;
  text-decoration: none;
  font-weight: bold;
  transition: color 0.2s ease;
}

.example-link:hover {
  text-decoration: underline;
  color: #80d4ff;
}

/* Error and warning banners */
.error-banner {
  background: var(--danger-color);
  color: white;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 20px;
  animation: slideIn 0.3s ease;
}

.warning-banner {
  background: var(--warning-color);
  color: black;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 20px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Loading state */
.loading {
  opacity: 0.6;
  pointer-events: none;
  cursor: wait;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  textarea {
    height: 150px;
  }
  
  table {
    font-size: 0.9em;
  }
  
  th, td {
    padding: 6px;
  }
  
  button {
    padding: 8px 12px;
    font-size: 0.9em;
    margin-bottom: 8px;
  }
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background-color: var(--bg-color);
  margin: 2% auto;
  padding: 0;
  border: 1px solid #888;
  border-radius: 8px;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideDown 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

@keyframes slideDown {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 15px 20px;
  background: var(--primary-color);
  color: white;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3em;
}

.close {
  color: white;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease, transform 0.2s ease;
}

.close:hover,
.close:focus {
  color: #ddd;
  transform: rotate(90deg);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 8px 8px;
  text-align: right;
}

.config-group {
  background: var(--bg-light);
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 15px;
  transition: opacity 0.3s ease, background 0.2s ease;
}

.config-group:hover {
  background: var(--bg-lighter);
}

.config-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.group-name-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.group-name-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--focus-shadow);
}

.config-content {
  padding-left: 25px;
  transition: opacity 0.3s ease;
}

.config-content.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.config-section {
  margin-bottom: 20px;
}

.config-section label {
  display: block;
  margin-bottom: 10px;
  font-weight: bold;
  color: white;
}

.class-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  margin-bottom: 10px;
}

.class-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  font-size: 0.9em;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 4px;
  border-radius: 3px;
}

.class-checkbox:hover {
  background: var(--bg-lighter);
}

.class-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.class-checkbox input[type="checkbox"]:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.config-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  margin-top: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 4px;
  border-radius: 3px;
}

.config-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.modal-actions {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  gap: 10px;
}

/* Better mobile support for modal */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 5% auto;
    max-height: 85vh;
  }
  
  .class-selector {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    padding: 8px;
  }
  
  .modal-header h2 {
    font-size: 1.1em;
  }
  
  .close {
    font-size: 24px;
  }
  
  .config-group {
    padding: 12px;
  }
  
  .config-content {
    padding-left: 15px;
  }
  
  .modal-actions {
    flex-direction: column;
  }
  
  .modal-actions button {
    width: 100%;
    margin-right: 0;
  }
}

/* Small screens */
@media (max-width: 480px) {
  body {
    padding: 8px;
  }
  
  .modal-content {
    width: 98%;
    margin: 2% auto;
  }
  
  .class-selector {
    grid-template-columns: 1fr;
  }
  
  .config-header {
    flex-wrap: wrap;
  }
  
  .group-name-input {
    width: 100%;
    order: 1;
  }
  
  button.btn-small {
    order: 3;
  }
  
  input[type="checkbox"] {
    order: 2;
  }
}