:root {
  --primary-bg: #181c20;
  --secondary-bg: #23272b;
  --accent: #4f8cff;
  --accent-hover: #357ae8;
  --border: #2c3136;
  --text: #f5f6fa;
  --text-secondary: #b0b8c1;
  --shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.12);
  --radius: 0.75rem;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: "Inter", "Segoe UI", "Roboto", "Arial", sans-serif;
}

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap");

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--primary-bg);
  color: var(--text);
  min-width: 0;
  font-size: 1rem;
  min-height: 100vh;
  overflow-x: hidden;
}

.page-header-title {
  font-size: 2.5rem;
  font-weight: 600;
}

.page-header-links {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
}

.page-header-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color var(--transition);
}

.page-header-links a:hover {
  color: var(--accent);
}

header,
.page-header {
  background: var(--secondary-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  flex-shrink: 0;
}

.page-header a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
.page-header a:hover {
  color: var(--accent-hover);
}

.container {
  display: flex;
  flex-direction: row;
  min-height: calc(100vh - 3.5rem);
  max-height: calc(100vh - 3.5rem);
  overflow: hidden;
}

.config-sidebar {
  background: var(--secondary-bg);
  padding: 2rem 1.25rem 2rem 1.25rem;
  width: 30%;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.config-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.image-input::file-selector-button {
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
}

h2,
h3 {
  color: var(--accent);
  margin: 0.5rem 0 1rem 0;
  font-weight: 600;
}

.export-options {
  background: var(--secondary-bg);
  padding: 2rem 1.25rem 2rem 1.25rem;
  align-items: center;
  display: flex;
  flex-direction: column;
}

ul,
li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.filament-list-item,
.draggable-item {
  background: var(--primary-bg);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  padding: 1rem 1rem 0.75rem 1rem;
  color: var(--text-secondary);
  transition: box-shadow var(--transition), border var(--transition);
}
.filament-list-item:focus-within,
.draggable-item:focus-within {
  border: 1.5px solid var(--accent);
  box-shadow: 0 2px 12px 0 rgba(79, 140, 255, 0.1);
}

.draggable-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drag-handle {
  cursor: grab;
  background: var(--secondary-bg);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.5rem;
  transition: background var(--transition);
}
.drag-handle:active {
  background: var(--accent);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.row span {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

input {
  width: 100%;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.option-group label {
  font-weight: 500;
  color: var(--text);
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.checkbox-group label {
  color: var(--text-secondary);
  cursor: pointer;
}

.status-message {
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.file-size-info {
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 0.75rem;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color var(--transition);
  padding: 0.5rem 0;
}

.footer-links a:hover {
  color: var(--accent);
}

input,
select,
textarea,
button {
  font-family: var(--font-main);
  font-size: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--secondary-bg);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  margin: 0.15rem 0;
  transition: border var(--transition), box-shadow var(--transition);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.1);
}

input[type="color"] {
  padding: 0.1rem;
  border: none;
  background: none;
  width: 2.2rem;
  height: 2.2rem;
}

input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}

button,
.filament-add-button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.08);
  transition: background var(--transition), box-shadow var(--transition);
}
button:hover,
.filament-add-button:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px 0 rgba(79, 140, 255, 0.1);
}
button:active,
.filament-add-button:active {
  background: #2851a3;
}
button:disabled,
.filament-add-button:disabled {
  background: #888;
  color: #ccc;
  cursor: not-allowed;
}

.h-divider {
  border-bottom: 1px solid var(--border);
  margin: 1.5rem 0;
}
.h-gap {
  width: 1.5rem;
  display: inline-block;
}
.h-gap-small {
  width: 0.5rem;
  display: inline-block;
}

.preview-window {
  flex: 1 1 0%;
  display: flex;
  gap: 1rem;
  flex-direction: column;
  align-items: center;
  background: var(--primary-bg);
  padding: 2rem;
  height: calc(100vh - 3.5rem);
  overflow: auto;
}
.preview-canvas {
  flex: 1;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: #101214;
  width: auto;
  height: auto;
  box-shadow: var(--shadow);
}

textarea {
  width: 100%;
  min-height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--secondary-bg);
  color: var(--text);
  padding: 0.75rem;
  resize: vertical;
}

.resize-handle {
  background: var(--secondary-bg);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: ns-resize;
  text-align: center;
  font-size: 0.9rem;
  margin-top: 1rem;
}

::-webkit-scrollbar {
  width: 10px;
  background: var(--secondary-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

.margin-bottom {
  margin-bottom: 3.5rem;
}

/* Mobile Styles */
@media (max-width: 900px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .page-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .page-header-title {
    font-size: 1.25rem;
  }

  .page-header-links {
    margin-left: 0;
    gap: 1rem;
  }

  .config-sidebar {
    width: 50%;
  }

  .preview-canvas {
    width: 90%;

  }

  /* Increase touch targets for mobile */
  button,
  .filament-add-button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    min-height: 44px;
    margin-bottom: 0.75rem;
  }

  input,
  select,
  textarea {
    padding: 0.75rem;
    font-size: 1rem;
  }

  .row {
    gap: 1rem;
  }
}

@media (max-width: 600px) {
  .page-header {
    justify-content: space-between;
  }
  .container {
    flex-direction: column;
  }
  .config-sidebar {
    width: auto;
    max-height: 50vh;
  }

  input {
    width: auto;
  }

  .preview-window {
    padding: 0.75rem 0.5rem;
    flex-direction: row;
    flex: auto;
    overflow: hidden;
  }
  .preview-canvas {
    flex: 1;
    height: auto;
    width: 45vw;
  }

  .margin-bottom {
    margin-bottom: 0;
  }

  .filament-list-item,
  .draggable-item {
    padding: 1rem 0.75rem 0.75rem 0.75rem;
    margin-bottom: 1rem;
  }

  button,
  .filament-add-button {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    width: 100%;
    margin-right: 0;
    margin-bottom: 0.75rem;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .row-item {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
  }

  input[type="range"] {
    width: auto;
  }

  .h-gap,
  .h-gap-small {
    display: none;
  }

  /* Stack buttons vertically on mobile */
  .row button {
    width: 100%;
    margin-right: 0;
  }

  .button-group {
    flex-direction: column;
  }

  .footer-links {
    gap: 0.75rem;
  }
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease-out;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  max-width: 90vw;
  max-height: 90vh;
  width: 800px;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--primary-bg);
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h2 {
  margin: 0;
  color: var(--accent);
  font-size: 1.5rem;
}

.close-modal {
  color: var(--text-secondary);
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
  user-select: none;
}

.close-modal:hover {
  color: var(--accent);
}

.modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
  max-height: 60vh;
}

.modal-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--primary-bg);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex;
  justify-content: center;
}

.close-modal-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.close-modal-btn:hover {
  background: var(--accent-hover);
}

/* How to Use Content Styles */
.how-to-section {
  margin-bottom: 2.5rem;
}

.how-to-section h3 {
  color: var(--accent);
  font-size: 1.3rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
}

.how-to-section p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.step-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.step-number {
  background: var(--accent);
  color: white;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.step-content h4 {
  color: var(--text);
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
}

.step-content p {
  margin: 0 0 0.75rem 0;
}

.step-content ul {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.step-content li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.tip {
  background: rgba(79, 140, 255, 0.1);
  border: 1px solid rgba(79, 140, 255, 0.3);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
}

.tip strong {
  color: var(--accent);
}

.control-group,
.example-group,
.troubleshoot-group {
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.control-group h4,
.example-group h4,
.troubleshoot-group h4 {
  color: var(--text);
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
}

.control-group ul,
.example-group ul {
  padding-left: 1.5rem;
}

.control-group li,
.example-group li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.control-group li ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.control-group li li {
  margin-bottom: 0.25rem;
  font-style: italic;
}

.issue {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.issue h5 {
  color: #ff6b6b;
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

.issue p {
  margin: 0;
  color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* Responsive Modal */
@media (max-width: 768px) {
  .modal.show {
    padding: 0.5rem;
  }

  .modal-content {
    width: 95vw;
    max-height: 95vh;
  }

  .modal-header {
    padding: 1rem 1.5rem;
  }

  .modal-header h2 {
    font-size: 1.3rem;
  }

  .modal-body {
    padding: 1.5rem;
    max-height: 70vh;
  }

  .modal-footer {
    padding: 1rem 1.5rem;
  }

  .step {
    flex-direction: column;
    gap: 0.75rem;
  }

  .step-number {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .modal-header h2 {
    font-size: 1.1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .step {
    padding: 1rem;
  }

  .control-group,
  .example-group,
  .troubleshoot-group {
    padding: 1rem;
  }
}

/* Accessibility: focus ring for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
