/*
 * Beautiful Custom Styles for Converted Content
 * Injected into #content to make any webpage look great
 */

#content.styled {
  /* Typography */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #2c3e50;
  margin: 0 16px;
  padding: 20px 16px;
  /* Prevent text overflow */
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Headings */
#content.styled h1,
#content.styled h2,
#content.styled h3,
#content.styled h4,
#content.styled h5,
#content.styled h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 700;
  line-height: 1.3;
  color: #1a202c;
  /* Wrap long headings */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#content.styled h1 {
  font-size: 2.5em;
  border-bottom: 3px solid #3498db;
  padding-bottom: 0.3em;
  margin-top: 0;
}

#content.styled h2 {
  font-size: 2em;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.3em;
}

#content.styled h3 {
  font-size: 1.5em;
}

#content.styled h4 {
  font-size: 1.25em;
}

#content.styled h5,
#content.styled h6 {
  font-size: 1em;
  color: #4a5568;
}

/* Paragraphs */
#content.styled p {
  margin-bottom: 1.25em;
  text-align: justify;
}

#content.styled p:last-child {
  margin-bottom: 0;
}

/* Links */
#content.styled a {
  color: #3498db;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
  /* Wrap long URLs */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#content.styled a:hover {
  color: #2980b9;
  border-bottom-color: #3498db;
}

/* Lists */
#content.styled ul,
#content.styled ol {
  margin: 1em 0;
  padding-left: 2em;
}

#content.styled li {
  margin-bottom: 0.5em;
}

#content.styled li > p {
  margin-bottom: 0.5em;
}

/* Blockquotes */
#content.styled blockquote {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  border-left: 5px solid #3498db;
  background: #f8f9fa;
  color: #4a5568;
  font-style: italic;
}

#content.styled blockquote p:last-child {
  margin-bottom: 0;
}

/* Code */
#content.styled code {
  background: #f1f3f5;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
  color: #e83e8c;
}

#content.styled pre {
  background: #282c34;
  color: #abb2bf;
  padding: 1.5em;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5em 0;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#content.styled pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  border-radius: 0;
  font-size: 0.9em;
}

/* Tables */
#content.styled table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
  overflow-x: auto;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}

#content.styled thead {
  background: #3498db;
  color: white;
}

#content.styled th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85em;
  letter-spacing: 0.5px;
}

#content.styled td {
  padding: 12px 15px;
  border-bottom: 1px solid #e2e8f0;
}

#content.styled tbody tr {
  background: white;
  transition: background 0.2s ease;
}

#content.styled tbody tr:hover {
  background: #f8f9fa;
}

#content.styled tbody tr:nth-child(even) {
  background: #f8f9fa;
}

#content.styled tbody tr:nth-child(even):hover {
  background: #e9ecef;
}

/* Images - preserve original display type from source page */
#content.styled img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  vertical-align: middle;
}

/* Use original display type captured from browser */
#content.styled img[data-original-display="inline"] {
  display: inline;
  margin: 0;
}

#content.styled img[data-original-display="inline-block"] {
  display: inline-block;
  margin: 0 0.25em;
}

#content.styled img[data-original-display="block"] {
  display: block;
  margin: 1.5em auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Fallback for images without captured display type */
#content.styled img:not([data-original-display]) {
  display: block;
  margin: 1.5em auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#content.styled figure {
  margin: 2em 0;
  text-align: center;
}

#content.styled figcaption {
  margin-top: 1em;
  font-size: 0.9em;
  color: #6c757d;
  font-style: italic;
}

/* Horizontal Rules */
#content.styled hr {
  border: none;
  border-top: 2px solid #e2e8f0;
  margin: 2em 0;
}

/* Strong & Em */
#content.styled strong,
#content.styled b {
  font-weight: 700;
  color: #1a202c;
}

#content.styled em,
#content.styled i {
  font-style: italic;
  color: #4a5568;
}

/* Buttons (if any) */
#content.styled button,
#content.styled .button {
  background: #3498db;
  color: white;
  border: none;
  padding: 0.75em 1.5em;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

#content.styled button:hover,
#content.styled .button:hover {
  background: #2980b9;
  box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4);
  transform: translateY(-1px);
}

/* Dark Theme */
body.dark #content.styled {
  background: #1f2937;
  color: #f3f4f6;
}

body.dark #content.styled h1,
body.dark #content.styled h2,
body.dark #content.styled h3,
body.dark #content.styled h4,
body.dark #content.styled h5,
body.dark #content.styled h6 {
  color: #f9fafb;
}

body.dark #content.styled h1 {
  border-bottom-color: #6366f1;
}

body.dark #content.styled h2 {
  border-bottom-color: #374151;
}

body.dark #content.styled a {
  color: #60a5fa;
}

body.dark #content.styled a:hover {
  color: #93c5fd;
  border-bottom-color: #60a5fa;
}

body.dark #content.styled blockquote {
  background: #374151;
  border-left-color: #6366f1;
  color: #d1d5db;
}

body.dark #content.styled code {
  background: #374151;
  color: #f472b6;
}

body.dark #content.styled table {
  background: #374151;
}

body.dark #content.styled th {
  background: #4f46e5;
}

body.dark #content.styled td {
  border-bottom-color: #4b5563;
}

body.dark #content.styled tbody tr {
  background: #374151;
}

body.dark #content.styled tbody tr:hover {
  background: #4b5563;
}

body.dark #content.styled tbody tr:nth-child(even) {
  background: #4b5563;
}

body.dark #content.styled tbody tr:nth-child(even):hover {
  background: #6b7280;
}

body.dark #content.styled hr {
  border-top-color: #4b5563;
}

/* Universal text overflow prevention */
#content.styled * {
  /* Prevent any element from overflowing */
  max-width: 100%;
  /* Wrap long words in all text elements */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Specific handling for code elements - don't break words, just scroll */
#content.styled code,
#content.styled pre {
  word-wrap: normal;
  overflow-wrap: normal;
  word-break: normal;
}
