/* Enhanced CreateTable CSS with modern styling and improved UX */

/* Base styles */
* {
  box-sizing: border-box;
}

/* Input section styling */
.input-section {
  margin: 20px 0;
}

.textarea-container {
  position: relative;
  margin-bottom: 15px;
}

#masterlist {
  width: 100%;
  min-height: 120px;
  max-height: 300px;
  padding: 12px;
  border: 2px solid orange;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
  transition: border-color 0.3s ease;
}

#masterlist:focus {
  outline: none;
  border-color: #4878D1;
  box-shadow: 0 0 0 3px rgba(72, 120, 209, 0.1);
}

.help-text {
  font-size: 12px;
  color: #666;
  margin-top: 5px;
  font-style: italic;
}

/* Button styling */
.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 15px;
}

.primary-btn, .secondary-btn, .control-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.primary-btn {
  background-color: #4878D1;
  color: white;
}

.primary-btn:hover:not(:disabled) {
  background-color: #3a66b8;
  transform: translateY(-1px);
}

.primary-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

.secondary-btn {
  background-color: #f8f9fa;
  color: #333;
  border: 1px solid #ddd;
}

.secondary-btn:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
}

.control-btn {
  background-color: #6c757d;
  color: white;
  font-size: 13px;
  padding: 8px 16px;
}

.control-btn:hover:not(:disabled) {
  background-color: #5a6268;
}

.control-btn:disabled {
  background-color: #adb5bd;
  cursor: not-allowed;
}

/* Control buttons styling */
#onoffctrls {
  margin: 15px 0;
}

#onoffctrls .control-btn {
  background-color: #17a2b8;
}

#onoffctrls .control-btn:hover {
  background-color: #138496;
}

/* Example section */
.example-box {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 20px;
  margin: 15px 0;
}

.example-text {
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 15px;
  margin: 10px 0;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
}

/* Processing section */
#processing-section {
  margin: 30px 0;
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.instructions-panel {
  margin-bottom: 20px;
}

.instructions-panel h3 {
  margin-bottom: 15px;
  color: #333;
}

.control-panel {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

/* Display container */
#display-container {
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px;
  max-height: 400px;
  overflow-y: auto;
}

#display {
  font-size: 16px;
  line-height: 2;
  font-family: 'Courier New', monospace;
  word-wrap: break-word;
}

/* Space markers */
.space-marker {
  color: #007bff;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s ease;
  user-select: none;
}

.space-marker:hover {
  background-color: #e3f2fd;
  transform: scale(1.2);
}

.space-marker.marked {
  background-color: #007bff;
  color: white;
  font-weight: bold;
}

/* Table options panel */
.options-panel {
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 15px;
  margin-top: 15px;
}

.options-panel label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  cursor: pointer;
}

.options-panel input[type="checkbox"] {
  margin-right: 8px;
}

.options-panel select {
  margin-left: 8px;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* Results section */
#results-section {
  margin: 30px 0;
}

#table-preview {
  margin-bottom: 30px;
}

#preview-container {
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 20px;
  overflow-x: auto;
}

/* Table styling */
#mytable table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
}

#mytable th {
  background-color: #f8f9fa;
  font-weight: bold;
  text-align: left;
}

#mytable th, #mytable td {
  padding: 8px 12px;
  border: 1px solid #ddd;
}

#mytable .zebra-table tr:nth-child(even) {
  background-color: #f8f9fa;
}

/* Code block styling */
#codeblock {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 20px;
}

.code-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

#code {
  width: 100%;
  height: 200px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.4;
  background-color: white;
  resize: vertical;
}

#code:focus {
  outline: none;
  border-color: #4878D1;
  box-shadow: 0 0 0 3px rgba(72, 120, 209, 0.1);
}

/* Feedback messages */
.feedback-message {
  padding: 10px 15px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 14px;
  font-weight: 500;
}

.feedback-message.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.feedback-message.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.feedback-message.info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* Keyboard shortcuts help */
#shortcuts-help {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  max-width: 250px;
}

#shortcuts-help h4 {
  margin-top: 0;
  margin-bottom: 10px;
}

#shortcuts-help ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#shortcuts-help li {
  margin-bottom: 5px;
  font-size: 13px;
}

#shortcuts-help kbd {
  background-color: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: monospace;
}

/* Loading states */
.btn-loading {
  display: none;
}

.btn-loading::after {
  content: '';
  width: 12px;
  height: 12px;
  margin-left: 5px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Responsive design */
@media screen and (max-width: 768px) {
  .button-group {
    flex-direction: column;
  }
  
  .primary-btn, .secondary-btn {
    width: 100%;
    justify-content: center;
  }
  
  .control-panel {
    flex-direction: column;
  }
  
  .control-btn {
    width: 100%;
    justify-content: center;
  }
  
  .code-controls {
    flex-direction: column;
  }
  
  #display {
    font-size: 14px;
    line-height: 1.8;
  }
  
  #shortcuts-help {
    position: relative;
    top: auto;
    right: auto;
    margin: 20px 0;
    max-width: none;
  }
  
  #preview-container {
    padding: 10px;
  }
  
  #mytable {
    font-size: 12px;
  }
  
  #mytable th, #mytable td {
    padding: 6px 8px;
  }
}

@media screen and (max-width: 480px) {
  #display {
    font-size: 12px;
    line-height: 1.6;
  }
  
  .space-marker {
    padding: 1px 2px;
  }
  
  #code {
    font-size: 11px;
  }
  
  .example-text {
    font-size: 12px;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .space-marker {
    border: 2px solid currentColor;
  }
  
  .space-marker.marked {
    border-color: white;
  }
  
  #masterlist:focus, #code:focus {
    box-shadow: 0 0 0 3px yellow;
  }
}

/* Focus indicators for keyboard navigation */
.primary-btn:focus, .secondary-btn:focus, .control-btn:focus {
  outline: 2px solid #4878D1;
  outline-offset: 2px;
}

.space-marker:focus {
  outline: 2px solid #007bff;
  outline-offset: 1px;
}

/* Print styles */
@media print {
  #processing-section, #codeblock, .button-group, .control-panel {
    display: none !important;
  }
  
  #mytable {
    break-inside: avoid;
  }
}

