/* Tool Container Styles */
.tool-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Markdown Tool Styles — golden luxury shell */
.markdown-tool {
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.97), rgba(248, 238, 222, 0.97));
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 14px 36px -24px rgba(94, 65, 30, 0.35);
  border: 1px solid rgba(145, 103, 48, 0.2);
}

.markdown-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

.input-section,
.preview-section {
  display: flex;
  flex-direction: column;
}

.input-section label,
.preview-section label {
  display: block;
  color: #5e4329;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#markdownInput {
  flex: 1;
  width: 100%;
  background: #fffaf2;
  border: 1px solid rgba(145, 103, 48, 0.26);
  border-radius: 8px;
  padding: 16px;
  color: #4a351f;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  resize: none;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

#markdownInput:focus {
  outline: none;
  border-color: #ab7c34;
  box-shadow: 0 0 0 3px rgba(171, 124, 52, 0.16);
}

#markdownInput::placeholder {
  color: #8c7558;
}

.html-preview {
  flex: 1;
  width: 100%;
  background: #fffdf8;
  border: 1px solid rgba(145, 103, 48, 0.2);
  border-radius: 8px;
  padding: 20px;
  color: #3d2e1f;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-y: auto;
  min-height: 400px;
  max-height: 600px;
  box-sizing: border-box;
  text-align: left;
  position: relative;
}

.html-preview.empty-state {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  padding: 40px 20px !important;
}

.html-preview .empty-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  max-width: 400px;
  width: 100%;
}

.html-preview .empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(182, 138, 58, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(145, 103, 48, 0.25);
  flex-shrink: 0;
}

.html-preview .empty-icon i {
  font-size: 2.5rem;
  color: rgba(122, 86, 42, 0.45);
  opacity: 0.9;
}

.html-preview .empty-preview h3 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #5e4329;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.html-preview .empty-preview p {
  font-size: 0.95rem;
  color: rgba(88, 64, 38, 0.75);
  margin: 0;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.html-preview h1,
.html-preview h2,
.html-preview h3,
.html-preview h4,
.html-preview h5,
.html-preview h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.25;
}

.html-preview h1 { font-size: 2em; border-bottom: 2px solid rgba(145, 103, 48, 0.15); padding-bottom: 0.3em; }
.html-preview h2 { font-size: 1.5em; border-bottom: 1px solid rgba(145, 103, 48, 0.12); padding-bottom: 0.3em; }
.html-preview h3 { font-size: 1.25em; }
.html-preview h4 { font-size: 1em; }
.html-preview h5 { font-size: 0.875em; }
.html-preview h6 { font-size: 0.85em; color: rgba(88, 64, 38, 0.7); }

.html-preview p {
  margin: 1em 0;
}

.html-preview ul,
.html-preview ol {
  margin: 1em 0;
  padding-left: 2em;
}

.html-preview li {
  margin: 0.5em 0;
}

.html-preview code {
  background: rgba(182, 138, 58, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.html-preview pre {
  background: rgba(245, 238, 226, 0.9);
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1em 0;
  border: 1px solid rgba(145, 103, 48, 0.12);
}

.html-preview pre code {
  background: none;
  padding: 0;
}

.html-preview blockquote {
  border-left: 4px solid rgba(182, 138, 58, 0.45);
  padding-left: 1em;
  margin: 1em 0;
  color: rgba(88, 64, 38, 0.85);
}

.html-preview a {
  color: #8b632e;
  text-decoration: none;
}

.html-preview a:hover {
  text-decoration: underline;
}

.html-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.html-preview table th,
.html-preview table td {
  border: 1px solid rgba(145, 103, 48, 0.2);
  padding: 8px 12px;
  text-align: left;
}

.html-preview table th {
  background: rgba(182, 138, 58, 0.12);
  font-weight: 600;
}

.html-preview hr {
  border: none;
  border-top: 2px solid rgba(145, 103, 48, 0.15);
  margin: 2em 0;
}

.html-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.html-preview .task-list {
  list-style: none;
  padding-left: 0;
}

.html-preview .task-list-item {
  list-style: none;
  margin-left: 0;
}

.html-preview .task-list-item input[type="checkbox"] {
  margin-right: 0.5em;
  cursor: default;
  accent-color: #b98b3b;
}

.html-preview .footnotes {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid rgba(145, 103, 48, 0.15);
}

.html-preview .footnotes h3 {
  font-size: 1.1em;
  margin-bottom: 1em;
}

.html-preview .footnote-ref {
  text-decoration: none;
  color: #8b632e;
  font-weight: 600;
}

.html-preview .footnote-backref {
  text-decoration: none;
  color: #8b632e;
  margin-left: 0.5em;
}

.html-preview sup {
  font-size: 0.8em;
  vertical-align: super;
}

.html-preview mark {
  background-color: #f0d78c;
  padding: 2px 4px;
  border-radius: 2px;
}

/* HTML export section */
.result-section {
  margin-bottom: 25px;
  background: #fffaf2;
  border-radius: 12px;
  border: 1px solid rgba(145, 103, 48, 0.15);
  overflow: hidden;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: rgba(182, 138, 58, 0.08);
  border-bottom: 1px solid rgba(145, 103, 48, 0.12);
}

.result-header h3 {
  color: #5e4329;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-header h3 i {
  font-size: 1rem;
}

.copy-btn-small {
  background: transparent;
  border: 1px solid rgba(145, 103, 48, 0.28);
  color: #7a572c;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
}

.copy-btn-small:hover {
  background: rgba(182, 138, 58, 0.12);
  border-color: #ab7c34;
  transform: scale(1.05);
}

.result-content {
  padding: 20px;
}

.html-output {
  width: 100%;
  background: #fff8ef;
  border: 1px solid rgba(145, 103, 48, 0.15);
  border-radius: 8px;
  padding: 16px;
  color: #4a351f;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  resize: vertical;
  box-sizing: border-box;
}

.html-output:focus {
  outline: none;
  border-color: #ab7c34;
  box-shadow: 0 0 0 3px rgba(171, 124, 52, 0.16);
}

/* Copy / download feedback — not in common styles.css */
.toast.markdown-preview-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  z-index: 10050;
  box-shadow: 0 10px 30px rgba(94, 65, 30, 0.2);
  animation: mdPreviewToastIn 0.35s ease;
}

.toast.markdown-preview-toast.success {
  background: linear-gradient(135deg, rgba(255, 250, 241, 0.98), rgba(244, 228, 200, 0.96));
  color: #4a351f;
  border: 1px solid rgba(145, 103, 48, 0.35);
}

@keyframes mdPreviewToastIn {
  from {
    transform: translateX(110%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes mdPreviewToastOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(110%);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .tool-container {
    padding: 0 15px;
  }

  .markdown-tool {
    padding: 25px 20px;
  }

  .markdown-wrapper {
    grid-template-columns: 1fr;
  }

  .html-preview {
    min-height: 300px;
    max-height: 400px;
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .copy-btn-small.copied {
    animation: copyPulse 0.6s ease;
    box-shadow: 0 0 12px rgba(182, 138, 58, 0.35);
  }

  .copy-btn-small.copied svg {
    display: inline-block;
    vertical-align: middle;
  }

  @keyframes copyPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1.05); }
  }

  .copy-btn-small {
    width: 100%;
  }

  .toast.markdown-preview-toast {
    top: auto;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 16px;
    max-width: none;
    animation: mdPreviewToastInMobile 0.35s ease;
  }

  @keyframes mdPreviewToastInMobile {
    from {
      transform: translateY(120%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}

.action-buttons.btn-contain-x {
  margin-bottom: 25px;
}
