:root {
  --primary-color: #4a6fa5;
  --secondary-color: #166088;
  --accent-color: #4fc3a1;
  --background-color: #f8f9fa;
  --text-color: #333;
  --light-gray: #e9ecef;
  --medium-gray: #ced4da;
  --dark-gray: #6c757d;
  --success-color: #28a745;
  --error-color: #dc3545;
  --warning-color: #ffc107;
  --border-radius: 8px;
  --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--background-color);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  padding: 20px;
  background-color: var(--primary-color);
  color: white;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

header p {
  font-size: 1.2rem;
  opacity: 0.9;
  margin-bottom: 20px;
}

nav ul {
  display: flex;
  justify-content: center;
  list-style: none;
  gap: 20px;
  margin-top: 20px;
}

nav a {
  color: white;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  transition: var(--transition);
  font-weight: 600;
}

nav a:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

nav a.active {
  background-color: rgba(255, 255, 255, 0.3);
}

main {
  display: block;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

@media (min-width: 768px) {
  #generator-tab.active {
    grid-template-columns: 1fr 2fr;
  }
}

.full-width {
  grid-column: 1 / -1;
}

.input-section, .output-section, .settings-section, .batch-results {
  background-color: white;
  padding: 25px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

.input-section h2, .output-section h2, .settings-section h2, .batch-results h2 {
  margin-bottom: 20px;
  color: var(--secondary-color);
  font-size: 1.5rem;
}

.settings-section h3 {
  margin: 20px 0 10px;
  color: var(--secondary-color);
  font-size: 1.2rem;
}

.form-group {
  margin-bottom: 20px;
}

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

input[type="text"], 
input[type="password"], 
select, 
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--medium-gray);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
}

input[type="text"]:focus, 
input[type="password"]:focus, 
select:focus, 
textarea:focus {
  border-color: var(--accent-color);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 195, 161, 0.2);
}

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

.api-key-input {
  display: flex;
  align-items: center;
}

.api-key-input input {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.toggle-password {
  background-color: var(--light-gray);
  border: 1px solid var(--medium-gray);
  border-left: none;
  padding: 12px 15px;
  cursor: pointer;
  border-top-right-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
}

.help-text {
  margin-top: 5px;
  font-size: 0.9rem;
  color: var(--dark-gray);
}

.help-text a {
  color: var(--primary-color);
  text-decoration: none;
}

.help-text a:hover {
  text-decoration: underline;
}

button {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: var(--transition);
}

button:hover {
  background-color: #3da58a;
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  background-color: var(--medium-gray);
  cursor: not-allowed;
  transform: none;
}

#generate-btn, #batch-generate-btn, #save-settings-btn {
  width: 100%;
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid var(--light-gray);
  border-top: 5px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

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

.article-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--light-gray);
}

.control-buttons {
  display: flex;
  gap: 10px;
}

#copy-btn, #download-btn, #download-xml-btn,
#modal-copy-btn, #modal-download-txt-btn, #modal-download-xml-btn,
#download-all-btn {
  background-color: var(--secondary-color);
  padding: 8px 16px;
  font-size: 0.9rem;
}

#article-content, #modal-article-content {
  background-color: var(--light-gray);
  padding: 20px;
  border-radius: var(--border-radius);
  max-height: 600px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: 'Courier New', Courier, monospace;
  line-height: 1.5;
}

#error-message, #batch-error {
  color: var(--error-color);
  text-align: center;
  padding: 20px;
}

.hidden {
  display: none !important;
}

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 20px;
  background-color: var(--light-gray);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: var(--accent-color);
  width: 0%;
  transition: width 0.3s ease;
}

#batch-progress-text {
  text-align: center;
  margin-bottom: 20px;
  font-weight: 600;
}

/* Batch Results Table */
#batch-results-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

#batch-results-table th,
#batch-results-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--light-gray);
}

#batch-results-table th {
  background-color: var(--secondary-color);
  color: white;
}

#batch-results-table tr:hover {
  background-color: var(--light-gray);
}

.batch-article-actions {
  display: flex;
  gap: 10px;
}

.batch-article-actions button {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.status-pending {
  color: var(--dark-gray);
}

.status-processing {
  color: var(--warning-color);
}

.status-completed {
  color: var(--success-color);
}

.status-failed {
  color: var(--error-color);
}

.batch-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  width: 80%;
  max-width: 900px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  animation: modalFadeIn 0.3s;
}

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

.modal-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--light-gray);
}

.modal-header h2 {
  margin: 0;
  color: var(--secondary-color);
}

.close-modal {
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--light-gray);
}

footer {
  margin-top: 50px;
  text-align: center;
  color: var(--dark-gray);
  padding: 20px;
}

/* WordPress Editor Style Preview */
.wp-preview {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  line-height: 1.8;
}

.wp-preview h1, .wp-preview h2, .wp-preview h3 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.wp-preview p {
  margin-bottom: 1.2em;
}

.wp-preview ul, .wp-preview ol {
  margin-left: 2em;
  margin-bottom: 1.2em;
}

.wp-preview img {
  max-width: 100%;
  height: auto;
  margin: 1em 0;
}