/* Reset CSS para neutralizar estilos do servidor */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}

body {
    margin: 0 !important;
    padding: 0 !important;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    background: hsl(0, 0%, 2%) !important;
    color: #e1f0ff !important;
    /* Melhorias para mobile */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    box-sizing: border-box;
  }
  
  *, *::before, *::after {
    box-sizing: border-box;
  }
  
  body.light {
    background: #f4f6f8 !important;
    color: #111 !important;
  }
  
  body.light .editor-header {
    background: linear-gradient(135deg, rgba(150,185,207,0.2) 0%, rgba(62,94,134,0.2) 100%) !important;
    border-bottom: 1px solid rgba(150,185,207,0.4) !important;
  }
  
  body.light .back-btn {
    background: rgba(150,185,207,0.3) !important;
    color: #2c3e50 !important;
    border: 1px solid rgba(150,185,207,0.5) !important;
  }
  
  body.light .back-btn:hover {
    background: rgba(150,185,207,0.4) !important;
    color: #1a252f !important;
    box-shadow: 0 0 15px rgba(150,185,207,0.4) !important;
  }
  
  body.light .header-left h1 {
    color: #2c3e50 !important;
  }
  
  body.light .editor-header button {
    background: rgba(150,185,207,0.3) !important;
    color: #2c3e50 !important;
    border: 1px solid rgba(150,185,207,0.5) !important;
  }
  
  body.light .editor-header button:hover {
    background: rgba(150,185,207,0.4) !important;
    color: #1a252f !important;
    box-shadow: 0 0 15px rgba(150,185,207,0.4) !important;
  }
  
  body.light .cover-control button {
    background: rgba(150,185,207,0.3) !important;
    color: #2c3e50 !important;
    border: 1px solid rgba(150,185,207,0.5) !important;
  }
  
  body.light .cover-control button:hover {
    background: rgba(150,185,207,0.4) !important;
    color: #1a252f !important;
  }
  
  body.light .toolbar {
    background: rgba(150,185,207,0.15) !important;
    border-bottom: 1px solid rgba(150,185,207,0.3) !important;
  }
  
  body.light .toolbar button,
  body.light .toolbar select {
    background: rgba(150,185,207,0.2) !important;
    color: #2c3e50 !important;
    border: 1px solid rgba(150,185,207,0.4) !important;
  }
  
  body.light .toolbar button:hover,
  body.light .toolbar select:hover {
    background: rgba(150,185,207,0.3) !important;
    color: #1a252f !important;
    box-shadow: 0 0 10px rgba(150,185,207,0.3) !important;
  }
  
  body.light .toolbar select option {
    background: #fff !important;
    color: #2c3e50 !important;
  }
  
  body.light #editor {
    background: rgba(255,255,255,0.9) !important;
    color: #333 !important;
    border: 1px solid rgba(150,185,207,0.3) !important;
  }
  
  body.light #editor:focus {
    box-shadow: 0 0 0 2px rgba(150,185,207,0.5), 0 0 20px rgba(150,185,207,0.3) !important;
  }
  
  body.light .publish-menu {
    background: rgba(255,255,255,0.95) !important;
    border: 1px solid rgba(150,185,207,0.3) !important;
  }
  
  body.light .publish-menu button {
    color: #2c3e50 !important;
    background: transparent !important;
  }
  
  body.light .publish-menu button:hover {
    background: rgba(150,185,207,0.2) !important;
    color: #1a252f !important;
  }
  
  .editor-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px 20px !important;
    background: linear-gradient(135deg, rgba(150,185,207,0.1) 0%, rgba(62,94,134,0.1) 100%) !important;
    border-bottom: 1px solid rgba(150,185,207,0.2) !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  .header-left {
    display: flex;
    align-items: center;
    gap: 15px;
  }
  
  .back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(150,185,207,0.15);
    border: 1px solid rgba(150,185,207,0.3);
    border-radius: 8px;
    color: #e1f0ff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
  }
  
  .back-btn:hover {
    background: rgba(150,185,207,0.25);
    box-shadow: 0 0 15px rgba(150,185,207,0.3);
    transform: translateX(-2px);
  }
  
  .back-btn svg {
    transition: transform 0.3s ease;
  }
  
  .back-btn:hover svg {
    transform: translateX(-2px);
  }
  
  .editor-header h1 {
    margin: 0;
    font-size: 1.5rem;
  }
  
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .editor-header button {
    padding: 12px 16px;
    font-size: 16px;
    min-height: 44px;
    border: 1px solid rgba(150,185,207,0.3);
    border-radius: 8px;
    background: rgba(150,185,207,0.15);
    color: #e1f0ff;
    cursor: pointer;
    transition: all 0.3s ease;
    /* Garantir funcionalidade */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }
  
  .editor-header button:hover {
    background: rgba(150,185,207,0.25);
    box-shadow: 0 0 15px rgba(150,185,207,0.3);
  }
  
  .cover-control {
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }
  
  .cover-control button {
    padding: 12px 16px;
    font-size: 16px;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    background: #2d3748;
    color: #e1f0ff;
    cursor: pointer;
    transition: background 0.2s;
    /* Garantir funcionalidade */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }
  
  .cover-control button:hover {
    background: #4a5568;
  }
  
  .toolbar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 15px !important;
    background: rgba(150,185,207,0.08) !important;
    border-bottom: 1px solid rgba(150,185,207,0.15) !important;
    overflow-x: auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  .toolbar button,
  .toolbar select {
    padding: 12px 16px;
    font-size: 16px;
    min-height: 44px;
    min-width: 44px;
    border: 1px solid rgba(150,185,207,0.2);
    border-radius: 6px;
    background: rgba(150,185,207,0.1);
    color: #e1f0ff;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    /* Garantir que os botões funcionem */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }
  
  .toolbar button:hover,
  .toolbar select:hover {
    background: rgba(150,185,207,0.2);
    box-shadow: 0 0 10px rgba(150,185,207,0.2);
  }
  
  .toolbar select {
    min-width: 120px;
  }
  
  .editor-container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 15px;
  }
  
  #editor {
    min-height: 400px !important;
    background: rgba(150,185,207,0.05) !important;
    padding: 20px !important;
    border-radius: 16px !important;
    font-size: 16px !important;
    line-height: 1.6 !important;
    outline: none !important;
    border: 1px solid rgba(150,185,207,0.15) !important;
    /* Melhorar funcionalidade do editor */
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    color: #e1f0ff !important;
    font-family: Inter, system-ui, sans-serif !important;
  }
  
  #editor:focus {
    box-shadow: 0 0 0 2px rgba(150,185,207,0.4), 0 0 20px rgba(150,185,207,0.2);
  }
  
  /* Preview inline - estilo LinkedIn */
  .preview-content {
    display: none;
    min-height: 400px;
    background: white;
    padding: 0;
    border-radius: 16px;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    font-family: Inter, system-ui;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
  }
  
  .preview-content img:first-child {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 16px 16px 0 0;
  }
  
  .preview-content > *:not(img:first-child) {
    padding: 0 30px;
  }
  
  .preview-content > *:last-child {
    padding-bottom: 30px;
  }
  
  /* Estilos para elementos dentro do editor */
  #editor code {
    background: #2d3748;
    color: #e1f0ff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
  }
  
  #editor pre {
    background: #1a2332;
    color: #e1f0ff;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    margin: 10px 0;
    border: 1px solid #2d3748;
  }
  
  #editor pre code {
    background: transparent;
    padding: 0;
  }
  
  /* Preview inline - estilos do conteúdo */
  .preview-content pre {
    background: #1a2332;
    color: #e1f0ff;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
  }
  
  .preview-content code {
    font-family: 'Courier New', monospace;
    background: #2d3748;
    color: #e1f0ff;
    padding: 2px 6px;
    border-radius: 4px;
  }
  
  .preview-content pre code {
    background: transparent;
    padding: 0;
  }
  
  .preview-content span[style*="background-color: rgb(0, 0, 0)"],
  .preview-content span[style*="background-color: #000000"] {
    background-color: #000000 !important;
    color: #ffffff !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    display: inline-block !important;
    margin: 2px !important;
    font-weight: normal !important;
  }
  
  .preview-content h2 {
    color: #2d3748;
    margin-top: 30px;
  }
  
  .preview-content h3 {
    color: #4a5568;
    margin-top: 25px;
  }
  
  .preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
  }
  
  /* Imagens inseridas no conteúdo */
  #editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
    display: block;
  }
  
  .preview-content div img {
    border-radius: 8px;
    margin: 10px 0;
    display: block;
  }
  #editor span[style*="background-color: rgb(0, 0, 0)"],
  #editor span[style*="background-color: #000000"] {
    background-color: #000000 !important;
    color: #ffffff !important;
    padding: 6px 10px !important;
    border-radius: 4px !important;
    display: inline-block !important;
    margin: 2px !important;
    font-weight: normal !important;
  }
  
  /* Botão de editar caixa ativo */
  #editBoxBtn {
    transition: all 0.3s ease;
  }
  
  /* Dropdown de publicação */
  .publish-dropdown {
    position: relative;
    display: inline-block;
  }
  
  .publish-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #2d3748;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 150px;
    margin-top: 5px;
  }
  
  .publish-menu.show {
    display: block;
  }
  
  .publish-menu button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: #e1f0ff;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    font-size: 16px;
    min-height: 44px;
  }
  
  .publish-menu button:hover {
    background: #4a5568;
  }
  
  .publish-menu button:first-child {
    border-radius: 8px 8px 0 0;
  }
  
  .publish-menu button:last-child {
    border-radius: 0 0 8px 8px;
  }
  
  iframe {
    display: none;
    width: 100%;
    height: 100vh;
    border: none;
  }
  
  /* Estilos para texto indentado */
  #editor div[style*="margin-left"] {
    margin: 10px 0;
    transition: margin 0.2s ease;
  }
  
  #editor div[style*="border-left"] {
    border-left: 3px solid #4a5568 !important;
    padding-left: 20px !important;
    margin-left: 40px !important;
    background: rgba(74, 85, 104, 0.1);
    border-radius: 0 8px 8px 0;
  }
  
  body.light #editor {
    background: white;
    color: #111;
  }
  
  .cover-preview {
    max-width: 100%;
    display: none;
    margin: 20px auto;
    border-radius: 16px;
    padding: 0 15px;
  }
  
  iframe {
    display: none;
    width: 100%;
    height: 100vh;
    border: none;
  }
  
  /* Media queries para dispositivos móveis */
  @media (max-width: 768px) {
    .editor-header {
      padding: 12px 15px;
      flex-direction: column;
      align-items: stretch;
    }
    
    .editor-header h1 {
      font-size: 1.3rem;
      text-align: center;
      margin-bottom: 10px;
    }
    
    .actions {
      justify-content: center;
      flex-wrap: wrap;
      gap: 8px;
    }
    
    .publish-dropdown {
      width: 100%;
    }
    
    .publish-dropdown .publish {
      width: 100%;
      justify-content: center;
    }
    
    .publish-menu {
      left: 0;
      right: 0;
      min-width: auto;
    }
    
    .toolbar {
      padding: 12px;
      justify-content: flex-start;
      gap: 6px;
    }
    
    .toolbar button,
    .toolbar select {
      padding: 14px 18px;
      font-size: 16px;
      min-height: 48px;
      min-width: 48px;
    }
    
    .toolbar select {
      min-width: 140px;
    }
    
    .editor-container {
      margin: 15px auto;
      padding: 0 10px;
    }
    
    #editor {
      padding: 15px;
      font-size: 16px;
      min-height: 300px;
    }
    
    .preview-content {
      padding: 20px;
      min-height: 300px;
    }
    
    .cover-control {
      padding: 12px 15px;
      justify-content: center;
      flex-wrap: wrap;
    }
    
    .cover-control button {
      flex: 1;
      min-width: 140px;
      margin: 4px;
    }
    
    iframe {
      height: 70vh;
      margin-top: 15px;
    }
  }
  
  @media (max-width: 480px) {
    .editor-header {
      padding: 10px 12px;
    }
    
    .editor-header h1 {
      font-size: 1.2rem;
    }
    
    .actions {
      flex-direction: column;
      align-items: stretch;
    }
    
    .toolbar {
      padding: 10px;
      gap: 6px;
      justify-content: center;
    }
    
    .toolbar button,
    .toolbar select {
      padding: 16px 20px;
      font-size: 16px;
      min-height: 50px;
      min-width: 50px;
    }
    
    .toolbar select {
      min-width: 150px;
    }
    
    .editor-container {
      padding: 0 8px;
    }
    
    #editor {
      padding: 12px;
      border-radius: 12px;
      font-size: 16px;
    }
    
    .preview-content {
      padding: 15px;
      border-radius: 12px;
      font-size: 16px;
    }
    
    .cover-control {
      padding: 10px 12px;
      flex-direction: column;
    }
    
    .cover-control button {
      width: 100%;
      margin: 4px 0;
      padding: 14px 18px;
      font-size: 15px;
    }
    
    .publish-menu button {
      padding: 16px 20px;
      font-size: 16px;
      min-height: 50px;
    }
    
    iframe {
      height: 60vh;
    }
  }