/* Reset básico: remove margens/paddings e define box-sizing padrão */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Variáveis globais (tema, cores, espaçamentos, sombras, etc.) */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface2: #f0ede6;
  --border: #e2ddd4;
  --border-strong: #c8c2b6;
  --text: #1a1714;
  --text2: #5a5650;
  --text3: #9a948c;
  --accent: #262726;
  --accent2: #181818;
  --accent-bg: #e8f0e8;
  --tag-bg: #f0ede6;
  --danger: #c0392b;
  --danger-bg: #fdf0ee;
  --gold: #8b6914;
  --gold-bg: #fef8e7;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 280px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

/* Estilo base do corpo da página */
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Header (topo fixo) ── */
header {
  background: var(--accent);
  color: #fff;
  padding: 0 8px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Logo principal */
.logo {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  letter-spacing: -0.5px;
  color: #e8f4e8;
}

/* Parte destacada da logo */
.logo span {
  color: #a8d4a8;
  font-style: italic;
}

/* Área de ações no header (botões, etc.) */
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Botões padrão ── */
.btn {
  padding: 4px 5px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Botão principal */
.btn-primary {
  background: #fff;
  color: var(--accent);
}
.btn-primary:hover { background: #e8f4e8; }

/* Botão transparente (header) */
.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.25);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

/* Botão com borda */
.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover { background: var(--accent-bg); }

/* Botão de perigo (excluir) */
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: none;
}
.btn-danger:hover { background: #faddda; }

/* Botão pequeno */
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Layout principal (sidebar + conteúdo) ── */
.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* ── Sidebar lateral ── */
aside {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Seções da sidebar */
.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section:last-child {
  border-bottom: none;
  flex: 1;
}

/* Título da sidebar */
.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Item de categoria */
.category-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  color: var(--text2);
  position: relative;
}

/* Hover e estado ativo */
.category-item:hover { background: var(--surface2); color: var(--text); }
.category-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }

/* Bolinha de cor da categoria */
.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Contador de itens da categoria */
.category-count {
  margin-left: auto;
  font-size: 11px;
  background: var(--surface2);
  color: var(--text3);
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 500;
}

/* Estilo do contador quando ativo */
.category-item.active .category-count {
  background: var(--accent-bg);
  color: var(--accent);
}

/* Ações (editar/excluir) escondidas por padrão */
.cat-actions {
  display: none;
  gap: 2px;
  margin-left: auto;
}

/* Mostra ações ao passar mouse */
.category-item:hover .cat-actions { display: flex; }
.category-item:hover .category-count { display: none; }

/* Botões de ação da categoria */
.cat-actions button {
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.cat-actions button:hover { background: var(--border); color: var(--text); }
.cat-actions .del:hover { background: var(--danger-bg); color: var(--danger); }

/* Formulário de adicionar categoria */
.add-cat-form {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

/* Input de nova categoria */
.add-cat-form input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  min-width: 0;
}
.add-cat-form input:focus { border-color: var(--accent2); }

/* Input de edição de categoria */
.cat-edit-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--accent2);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  outline: none;
}

/* Botão confirmar edição */
.cat-edit-confirm {
  width: 22px;
  height: 22px;
  border: none;
  background: var(--accent-bg);
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cat-edit-confirm:hover { background: var(--accent); color: white; }

/* ── Conteúdo principal ── */
main {
  flex: 1;
  padding: 28px 32px;
  max-width: 860px;
}

/* Cabeçalho da página */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* Título da página */
.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  color: var(--text);
  line-height: 1.2;
}

/* Subtítulo */
.page-subtitle {
  font-size: 14px;
  color: var(--text3);
  margin-top: 3px;
}

/* ── Barra de classificação ── */
.sort-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 16px;
}

/* Botão de ordenação (filtros tipo "Recentes", "Antigos", etc.) */
.sort-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  transition: all 0.12s;
}
.sort-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sort-btn:hover:not(.active) { background: var(--surface2); }

/* ── Cards de Post ── */
.post-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 14px;
    transition: all 0.15s;
    cursor: pointer;
    text-overflow: ellipsis;
    max-height: 200px; /* limite */
    overflow: hidden;  /* esconde o excesso */
}

/* Efeito ao passar o mouse no card */
.post-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

/* Card fixado (pinned/destaque) */
.post-card.pinned {
  border-left: 3px solid var(--gold);
  background: linear-gradient(to right, var(--gold-bg), var(--surface));
}

/* Container interno do card */
.post-card-inner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

/* Corpo do card */
.post-card-body {
  flex: 1;
  min-width: 0;
}

/* Metadados do post (autor, data, tags) */
.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* Avatar do autor */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Nome do autor */
/* Data do post */
.author { font-weight: 500; font-size: 14px; }
.post-date { font-size: 13px; color: var(--text3); }

/* Tag padrão */
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--tag-bg);
  color: var(--text2);
  border: 1px solid var(--border);
  font-weight: 500;
}

/* Tag com destaque (colorida) */
.tag.tag-colored {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: #b8d4b8;
}

/* Badge de post fixado */
.pin-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid #e8d49a;
  font-weight: 500;
}

/* Título do post */
.post-title {
  font-family: 'DM Serif Display', serif;
  font-size: 19px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}

/* Resumo/preview do post */
.post-excerpt {
  font-size: 12px;
  color: var(--text2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.6;
}

/* Thumbnail de imagem do post */
.post-img-thumb {
  width: 80px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Indicador de mídia (imagem/vídeo) */
.media-indicator {
  font-size: 12px;
  color: var(--text3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

/* ── Estado vazio (sem posts) ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 17px; color: var(--text2); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ── Modal (janela popup) ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.overlay.open { display: flex; }

/* Estrutura principal do modal */
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: slideUp 0.2s ease;
}

/* Animação de entrada do modal */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Cabeçalho do modal */
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: 14px 14px 0 0;
  z-index: 1;
}

/* Título do modal */
.modal-title {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
}

/* Botão de fechar modal */
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  font-size: 20px;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body { padding: 20px 24px; }

/* Rodapé do modal (botões) */
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Formulários ── */
.form-group { margin-bottom: 16px; }

/* Label dos inputs */
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text2);
}

/* Inputs, selects e textarea */
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

/* Estado focus dos campos */
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent2);
  background: var(--surface);
}

/* Textarea */
.form-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--accent); }

/* ── Tabs de mídia (imagem/vídeo/url) ── */
.media-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* Botão de aba */
.media-tab {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text2);
  transition: all 0.12s;
  font-family: inherit;
}
.media-tab.active, .media-tab:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Conteúdo das abas */
.media-section { display: none; }
.media-section.active { display: block; }

/* Linha com input de URL */
.url-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.url-input-row input { flex: 1; }

/* Preview de imagem */
.img-preview {
  margin-top: 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.img-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

/* Área de upload (drag and drop) */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text3);
  font-size: 14px;
}
.upload-area:hover { border-color: var(--accent2); background: var(--accent-bg); color: var(--accent); }
.upload-area.dragover { border-color: var(--accent); background: var(--accent-bg); }

/* ── Visualização do post ── */
.post-view-content { padding: 24px; }

/* Título grande do post */
.post-view-title {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  margin-bottom: 14px;
  line-height: 1.25;
}

/* Corpo do post */
.post-view-body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Container de mídia */
.post-view-media {
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Imagem do post */
.post-view-media img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
  background: var(--bg);
}

/* Vídeo do post */
.post-view-media video {
  width: 100%;
  max-height: 480px;
  display: block;
}

/* Metadados abaixo do post */
.post-view-meta {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Toast (notificação) ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  display: none;
}
.toast.show { display: block; }

/* Animação do toast */
@keyframes toastIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Responsividade ── */
@media (max-width: 700px) {
  aside { display: contents; }
  main { padding: 16px; }
  .layout { flex-direction: column; }
  .media-tabs { gap: 4px; }
  .media-tab { padding: 4px 8px; font-size: 11px; }
}

/* ── Tela de autenticação ── */
#auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Container do auth */
.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

/* Caixa de login */
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Logo na tela de login */
.auth-box .logo {
  color: var(--accent);
  font-size: 26px;
  text-align: center;
}

/* Parte secundária da logo */
.auth-box .logo span { color: var(--text3); }

/* Mensagem de erro */
.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f5c6c2;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* Botão principal de login */
.auth-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 10px;
  background: var(--accent);
  color: #000000;
  font-size: 14px;
  margin-top: 4px;
}
.auth-submit-btn:hover { background: var(--accent2); }

/* Botão alternativo (ex: criar conta) */
.auth-alt-btn {
  width: 100%;
  justify-content: center;
  color: var(--text3);
  margin-top: 8px;
  font-size: 13px;
  background: transparent;
  border: none;
}
.auth-alt-btn:hover { color: var(--text); }
