/* ═══════════════════════════════════════════════════════════════════════════
   AlphaClin · Bloco de Notas Colaborativo
   Design: Minimal Slate/Teal — foco total no conteúdo
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Variáveis ─────────────────────────────────────────────────────────── */
:root {
    --bg:          #0f1117;
    --bg2:         #171b24;
    --bg3:         #1e2330;
    --border:      #2a3045;
    --teal:        #0d9488;
    --teal-light:  #14b8a6;
    --teal-dim:    rgba(13,148,136,.15);
    --text:        #e2e8f0;
    --text-muted:  #64748b;
    --text-dim:    #94a3b8;
    --danger:      #ef4444;
    --warning:     #f59e0b;
    --radius:      10px;
    --radius-lg:   16px;
    --font:        'DM Sans', sans-serif;
    --mono:        'DM Mono', monospace;
    --sidebar-w:   280px;
    --transition:  .18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout principal ──────────────────────────────────────────────────── */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition);
    z-index: 20;
}

.sidebar-header {
    padding: 20px 18px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.logo-icon {
    width: 34px; height: 34px;
    background: var(--teal);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--text);
}
.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* Busca */
.search-wrap {
    position: relative;
}
.search-wrap svg {
    position: absolute;
    left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
#busca {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    padding: 8px 10px 8px 34px;
    outline: none;
    transition: border-color var(--transition);
}
#busca:focus { border-color: var(--teal); }
#busca::placeholder { color: var(--text-muted); }

/* Lista de notas */
#lista-notas {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
#lista-notas::-webkit-scrollbar { width: 4px; }
#lista-notas::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nota-item {
    padding: 12px 18px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background var(--transition), border-color var(--transition);
    position: relative;
}
.nota-item:hover { background: var(--bg3); }
.nota-item.ativa {
    background: var(--teal-dim);
    border-left-color: var(--teal);
}
.nota-item-titulo {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.nota-item-resumo {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.nota-item-data {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--mono);
}
.nota-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* Rodapé sidebar */
.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.user-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--teal);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
#nome-usuario {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 13px;
    cursor: text;
    min-width: 0;
}
#nome-usuario:focus { color: var(--text); }

/* ── Área principal ────────────────────────────────────────────────────── */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    position: relative;
}

/* Topo do editor */
#editor-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 62px;
}

#titulo-nota {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.01em;
    min-width: 0;
}
#titulo-nota::placeholder { color: var(--text-muted); }

/* Indicadores */
#indicadores {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.badge-editando {
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(245,158,11,.12);
    border: 1px solid rgba(245,158,11,.3);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--warning);
    animation: pulse-badge 2s infinite;
}
.badge-editando.visivel { display: flex; }
@keyframes pulse-badge {
    0%,100% { opacity: 1; }
    50%      { opacity: .7; }
}
.badge-editando::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--warning);
    animation: blink 1s step-start infinite;
}
@keyframes blink {
    0%,100% { opacity: 1; }
    50%      { opacity: 0; }
}

.btn-icone {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    flex-shrink: 0;
}
.btn-icone:hover {
    background: var(--bg3);
    color: var(--text);
    border-color: var(--teal);
}
.btn-icone.ativo {
    background: var(--teal-dim);
    color: var(--teal-light);
    border-color: var(--teal);
}

/* Barra de formatação */
#toolbar {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 8px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
    flex-wrap: wrap;
    flex-shrink: 0;
}
#toolbar.visivel { display: flex; }
.toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}
.btn-fmt {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-fmt:hover {
    background: var(--bg3);
    color: var(--text);
    border-color: var(--border);
}
.btn-fmt.ativo {
    background: var(--teal-dim);
    color: var(--teal-light);
    border-color: var(--teal);
}

/* Área de conteúdo */
#editor-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 28px 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
#editor-wrap::-webkit-scrollbar { width: 5px; }
#editor-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#conteudo {
    min-height: 100%;
    outline: none;
    color: var(--text);
    font-size: 15px;
    line-height: 1.75;
    max-width: 860px;
    caret-color: var(--teal-light);
}
#conteudo:empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}
#conteudo h1 { font-size: 22px; font-weight: 600; margin: 20px 0 10px; color: var(--text); }
#conteudo h2 { font-size: 18px; font-weight: 600; margin: 18px 0 8px; color: var(--text); }
#conteudo h3 { font-size: 16px; font-weight: 600; margin: 14px 0 6px; color: var(--text-dim); }
#conteudo p  { margin-bottom: 8px; }
#conteudo ul, #conteudo ol { padding-left: 22px; margin-bottom: 10px; }
#conteudo li { margin-bottom: 3px; }
#conteudo strong { color: var(--teal-light); font-weight: 600; }
#conteudo em { color: var(--text-dim); font-style: italic; }
#conteudo a {
    color: var(--teal-light);
    text-decoration: none;
    background: var(--teal-dim);
    padding: 2px 6px;
    margin: 0 2px;
    border-radius: 4px;
    font-weight: 500;
    transition: all var(--transition);
}
#conteudo a:hover {
    background: var(--teal);
    color: #ffffff;
}
#conteudo code {
    font-family: var(--mono);
    font-size: 13px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--teal-light);
}
#conteudo blockquote {
    border-left: 3px solid var(--teal);
    padding: 6px 14px;
    margin: 10px 0;
    color: var(--text-dim);
    font-style: italic;
    background: var(--teal-dim);
    border-radius: 0 6px 6px 0;
}
#conteudo img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 8px 0;
    border: 1px solid var(--border);
}
#conteudo hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* Status bar */
#status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg2);
    flex-shrink: 0;
}
.status-info {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--mono);
}
#status-salvando {
    font-size: 12px;
    color: var(--teal);
    font-weight: 500;
    opacity: 0;
    transition: opacity .3s;
}
#status-salvando.visivel { opacity: 1; }

/* ── FAB ───────────────────────────────────────────────────────────────── */
#fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 100;
}
#fab-btn {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--teal);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(13,148,136,.4);
    transition: transform .2s, box-shadow .2s, background .2s;
}
#fab-btn:hover { background: var(--teal-light); transform: scale(1.07); }
#fab-btn.aberto { transform: rotate(45deg); background: #334155; }

#fab-menu {
    position: absolute;
    bottom: 60px; right: 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
    display: none;
    flex-direction: column;
    gap: 2px;
    animation: fab-in .15s ease;
}
#fab-menu.aberto { display: flex; }
@keyframes fab-in {
    from { opacity: 0; transform: translateY(8px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.fab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: background var(--transition), color var(--transition);
}
.fab-item:hover { background: var(--bg3); color: var(--text); }
.fab-item.perigo:hover { background: rgba(239,68,68,.12); color: var(--danger); }
.fab-item svg { flex-shrink: 0; }
.fab-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Tela vazia ────────────────────────────────────────────────────────── */
#empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}
#empty-state .empty-icon {
    font-size: 48px;
    opacity: .3;
}
#empty-state p { font-size: 15px; max-width: 300px; line-height: 1.6; }
#empty-state .btn-criar {
    margin-top: 8px;
    padding: 10px 22px;
    background: var(--teal);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
}
#empty-state .btn-criar:hover { background: var(--teal-light); }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}
.overlay.aberto { display: flex; }

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 440px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    animation: modal-in .2s ease;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(16px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--text);
}
.modal-field {
    margin-bottom: 16px;
}
.modal-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.modal-field input,
.modal-field select {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    padding: 9px 12px;
    outline: none;
    transition: border-color var(--transition);
}
.modal-field input:focus,
.modal-field select:focus { border-color: var(--teal); }

.modal-link {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}
.modal-link span {
    flex: 1;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--teal-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-copiar {
    background: var(--teal);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-family: var(--font);
    font-size: 12px;
    padding: 5px 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition);
}
.btn-copiar:hover { background: var(--teal-light); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}
.btn { padding: 9px 18px; border-radius: var(--radius); font-family: var(--font); font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all var(--transition); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-light); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,.12); }

/* ── Menções e Histórico ───────────────────────────────────────────────── */
#mencoes-lista {
    position: absolute;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,.5);
    z-index: 1000;
    min-width: 150px;
    display: none;
    flex-direction: column;
}
.mencao-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
    transition: background .1s;
}
.mencao-item:hover, .mencao-item.sel { background: var(--teal-dim); color: var(--teal-light); }

.versao-item {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.versao-item:hover { background: var(--bg3); }
.versao-info { font-size: 13px; color: var(--text); }
.versao-meta { font-size: 11px; color: var(--text-muted); }

.badge-notif {
    position: absolute;
    top: -2px; right: -2px;
    width: 10px; height: 10px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg2);
    display: none;
}
.badge-notif.visivel { display: block; }

.toggle-readonly {
    margin-top: 15px;
    padding: 10px;
    background: var(--bg3);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

/* ── Gestão de Imagens ─────────────────────────────────────────────────── */
.btn-remover-img, .btn-download-img {
    position: absolute;
    z-index: 100;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    transition: .2s;
    border: none;
}
.btn-remover-img { background: var(--danger); color: white; }
.btn-remover-img:hover { background: #991b1b; transform: scale(1.05); }

.btn-download-img { background: var(--primary); color: white; }
.btn-download-img:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast {
    position: fixed;
    bottom: 90px; right: 28px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
    z-index: 300;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
    max-width: 280px;
}
#toast.visivel { opacity: 1; transform: translateY(0); }
#toast.sucesso { border-color: var(--teal); color: var(--teal-light); }
#toast.erro    { border-color: var(--danger); color: var(--danger); }

/* ── Hambúrguer (mobile) ───────────────────────────────────────────────── */
#btn-menu {
    display: none;
    width: 34px; height: 34px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* ── Responsivo ────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    #btn-menu { display: flex; }
    #sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
    }
    #sidebar.aberta {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.4);
    }
    #main { width: 100%; }
    #editor-wrap { padding: 20px 16px; }
    #editor-top  { padding: 14px 16px; }
    #status-bar  { padding: 7px 16px; }
    #fab { bottom: 20px; right: 16px; }
    #toast { right: 16px; }
}

/* ── Ajuda ─────────────────────────────────────────────────────────────── */
.ajuda-sessao h4 {
    margin: 0 0 8px 0;
    color: var(--primary);
    font-size: 14px;
    font-family: 'Syne', sans-serif;
}
.ajuda-sessao p { margin: 0; }
.modal-corpo-scroll::-webkit-scrollbar { width: 4px; }
.modal-corpo-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
