/* ============================================================
   ACHADOS PAINEL FRONTEND — CSS
   ============================================================ */
:root {
    --p-accent:      #6d5c6d;
    --p-hover:       #5c4d5c;
    --p-accent-soft: color-mix(in srgb, #6d5c6d 12%, white);
    --p-bg:          #f7f6f4;
    --p-surface:     #ffffff;
    --p-border:      #e8e6e2;
    --p-text:        #1a1a1a;
    --p-muted:       #888880;
    --p-danger:      #c0392b;
    --p-success:     #27ae60;
    --p-radius:      14px;
    --p-radius-sm:   8px;
    --p-shadow:      0 2px 16px rgba(0,0,0,0.07);
    --p-shadow-lg:   0 8px 32px rgba(0,0,0,0.12);
    --p-font-body:   'DM Sans', -apple-system, sans-serif;
    --p-font-display:'Lora', Georgia, serif;
    --p-nav-h:       60px;
    --p-sidebar-w:   220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--p-bg);
    font-family: var(--p-font-body);
    color: var(--p-text);
    -webkit-text-size-adjust: 100%;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--p-accent); text-decoration: none; }
a:hover { color: var(--p-hover); }

img { max-width: 100%; display: block; }

.p-layout { display: flex; min-height: 100dvh; }

.p-sidebar {
    width: var(--p-sidebar-w);
    background: var(--p-surface);
    border-right: 1px solid var(--p-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 50;
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
}

.p-sidebar-logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--p-border); }

.p-sidebar-logo span {
    font-family: var(--p-font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--p-text);
    letter-spacing: -0.02em;
}

.p-sidebar-logo small { display: block; font-size: 11px; color: var(--p-muted); margin-top: 2px; }

.p-sidebar-nav { padding: 14px 12px; flex: 1; }

.p-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--p-radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--p-muted);
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    margin-bottom: 2px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.p-nav-item:hover { background: var(--p-bg); color: var(--p-text); }
.p-nav-item.active { background: var(--p-accent-soft); color: var(--p-accent); font-weight: 600; }
.p-nav-item .ti { font-size: 18px; }

.p-sidebar-user { padding: 14px 16px; border-top: 1px solid var(--p-border); font-size: 13px; }
.p-sidebar-user .name { font-weight: 600; color: var(--p-text); }
.p-sidebar-user .role { color: var(--p-muted); font-size: 11px; }
.p-sidebar-user form button {
    background: none; border: none; color: var(--p-muted);
    font-size: 12px; cursor: pointer; margin-top: 8px;
    display: flex; align-items: center; gap: 4px; padding: 0;
    font-family: var(--p-font-body);
}
.p-sidebar-user form button:hover { color: var(--p-danger); }

.p-main { margin-left: var(--p-sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.p-topbar {
    display: none;
    height: var(--p-nav-h);
    background: var(--p-surface);
    border-bottom: 1px solid var(--p-border);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.p-topbar-logo { font-family: var(--p-font-display); font-size: 16px; font-weight: 600; color: var(--p-text); }

.p-menu-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--p-text); font-size: 22px;
    display: flex; align-items: center; padding: 6px; border-radius: 6px;
}
.p-menu-toggle:hover { background: var(--p-bg); }

.p-sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 45; }

.p-content { padding: 28px 28px 48px; flex: 1; }

.p-page-title {
    font-family: var(--p-font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--p-text);
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

.p-alert {
    border-radius: var(--p-radius-sm);
    padding: 12px 16px;
    font-size: 13.5px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
}
.p-alert .ti { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.p-alert-success { background: #edfaf2; color: #1a6b3c; border: 1px solid #b6e8cc; }
.p-alert-error   { background: #fdf0ef; color: #8b1a13; border: 1px solid #f5c0bb; }

.p-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 28px; }

.p-stat-card { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius); padding: 20px; }
.p-stat-card .label { font-size: 12px; color: var(--p-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.p-stat-card .value { font-size: 32px; font-weight: 700; color: var(--p-accent); font-family: var(--p-font-display); line-height: 1; }

.p-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: none;
    border-radius: 22px;
    cursor: pointer;
    font-family: var(--p-font-body);
    font-weight: 600;
    transition: background 0.15s, transform 0.12s, opacity 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.p-btn:hover { transform: translateY(-1px); text-decoration: none; }
.p-btn:active { transform: translateY(0); }
.p-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.p-btn-primary { background: var(--p-accent); color: #fff; padding: 12px 22px; font-size: 14px; }
.p-btn-primary:hover { background: var(--p-hover); color: #fff; }

.p-btn-secondary { background: var(--p-bg); color: var(--p-text); border: 1px solid var(--p-border); padding: 10px 18px; font-size: 14px; }
.p-btn-secondary:hover { background: #eee; color: var(--p-text); }

.p-btn-danger { background: #fdf0ef; color: var(--p-danger); border: 1px solid #f5c0bb; padding: 8px 14px; font-size: 13px; }
.p-btn-danger:hover { background: #fbe3e1; color: var(--p-danger); }

.p-btn-sm { padding: 7px 14px; font-size: 13px; }
.p-btn-full { width: 100%; padding: 14px; font-size: 15px; }

.p-form-section { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius); padding: 24px; margin-bottom: 16px; }
.p-form-section h3 { font-size: 14px; font-weight: 600; color: var(--p-muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--p-border); }

.p-field { margin-bottom: 18px; }
.p-field:last-child { margin-bottom: 0; }
.p-field label { display: block; font-size: 13px; font-weight: 600; color: var(--p-text); margin-bottom: 7px; }
.p-field label .req { color: var(--p-danger); margin-left: 2px; }

.p-input, .p-select, .p-textarea {
    width: 100%;
    background: var(--p-bg);
    border: 1.5px solid var(--p-border);
    border-radius: var(--p-radius-sm);
    padding: 11px 14px;
    font-size: 16px;
    transform-origin: left top;
    font-family: var(--p-font-body);
    color: var(--p-text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
    touch-action: manipulation;
}
.p-input:focus, .p-select:focus, .p-textarea:focus {
    border-color: var(--p-accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--p-accent-soft);
}
.p-textarea { resize: vertical; min-height: 130px; font-family: 'Courier New', monospace; font-size: 16px; line-height: 1.6; }

.p-select-wrap { position: relative; }
.p-select-wrap::after { content: '\ea99'; font-family: 'tabler-icons'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--p-muted); font-size: 16px; }

.p-field .hint { font-size: 12px; color: var(--p-muted); margin-top: 6px; line-height: 1.4; }
.p-field .hint code { background: #f0ede8; padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

.p-upload-area { border: 2px dashed var(--p-border); border-radius: var(--p-radius-sm); padding: 24px; text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s; background: var(--p-bg); position: relative; }
.p-upload-area:hover { border-color: var(--p-accent); background: var(--p-accent-soft); }
.p-upload-area input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.p-upload-area .ti { font-size: 28px; color: var(--p-muted); display: block; margin-bottom: 6px; }
.p-upload-area span { font-size: 13px; color: var(--p-muted); }

.p-img-preview { margin-top: 12px; position: relative; display: inline-block; }
.p-img-preview img { width: 120px; aspect-ratio: 4/5; object-fit: cover; border-radius: var(--p-radius-sm); display: block; }

/* ── Grid de posts ── */
.p-posts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.p-post-card { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius); overflow: hidden; transition: box-shadow 0.15s; }
.p-post-card:hover { box-shadow: var(--p-shadow); }

.p-post-card-img { aspect-ratio: 4/5; background: #f0ede8; overflow: hidden; position: relative; }
.p-post-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.p-post-card-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.p-post-card-placeholder .ti { font-size: 36px; color: #c4a882; }

.p-card-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 6px; pointer-events: none; }

.p-drag-handle {
    align-self: flex-start;
    background: rgba(255,255,255,0.88);
    border: none; border-radius: 6px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    cursor: grab; pointer-events: all;
    color: #555; font-size: 14px;
    opacity: 0; transition: opacity 0.15s;
    touch-action: none;
}
.p-drag-handle:active { cursor: grabbing; }
.p-post-card:hover .p-drag-handle, .p-post-card.dragging .p-drag-handle { opacity: 1; }

@media (max-width: 768px) { .p-drag-handle { opacity: 0.7; } }

.p-pin-badge { align-self: flex-end; background: rgba(255,255,255,0.9); border-radius: 20px; font-size: 9px; color: #555; padding: 2px 7px; display: flex; align-items: center; gap: 3px; pointer-events: none; }

.p-post-card.is-fixed { border-color: var(--p-accent); box-shadow: 0 0 0 1.5px var(--p-accent); }
.p-btn-fixar.is-fixed { background: var(--p-accent-soft); color: var(--p-accent); border-color: var(--p-accent); }
.p-post-card.dragging { opacity: 0.45; transform: scale(0.97); }
.p-post-card.drag-over { outline: 2px dashed var(--p-accent); outline-offset: 2px; }

.p-ordem-salva { font-size: 12px; color: var(--p-success); display: flex; align-items: center; gap: 5px; opacity: 0; transition: opacity 0.3s; }
.p-ordem-salva.visible { opacity: 1; }

.p-post-card-body { padding: 10px 12px 12px; }

.p-post-card-title { font-size: 12.5px; font-weight: 500; color: var(--p-text); margin-bottom: 4px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.p-post-card-meta { font-size: 11px; color: var(--p-muted); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

/* ── Botões de ação do card — 3 ícones iguais ── */
.p-post-card-actions {
    display: flex;
    gap: 6px;
}

.p-post-card-actions .p-btn {
    flex: 1;
    padding: 9px 0;
    justify-content: center;
    font-size: 16px;
}

/* ── Empty state ── */
.p-empty { text-align: center; padding: 48px 20px; color: var(--p-muted); }
.p-empty .ti { font-size: 40px; display: block; margin-bottom: 12px; color: #d0ccc6; }
.p-empty h3 { font-size: 16px; font-weight: 600; color: var(--p-text); margin-bottom: 8px; }
.p-empty p { font-size: 14px; }

.p-color-row { display: flex; align-items: center; gap: 10px; }
.p-color-row input[type="color"] { width: 44px; height: 38px; border-radius: 6px; border: 1.5px solid var(--p-border); padding: 2px; cursor: pointer; background: none; }
.p-color-row input[type="text"] { width: 110px; }

.p-config-layout { display: grid; grid-template-columns: 400px 1fr; gap: 24px; align-items: start; }
.p-config-fields { min-width: 0; }
.p-preview-wrap { position: sticky; top: 80px; }
.p-preview-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--p-muted); margin-bottom: 10px; }
.p-preview-frame { background: #fff; border: 1px solid var(--p-border); border-radius: var(--p-radius); overflow: hidden; box-shadow: var(--p-shadow); }

.mock-header { padding: 12px 14px 10px; border-bottom: 0.5px solid #e8e8e8; background: #fff; }
.mock-title { font-size: 15px; font-weight: 600; text-align: center; margin-bottom: 8px; font-family: 'Lora', Georgia, serif; letter-spacing: -0.02em; transition: color 0.2s; }
.mock-search { background: #f5f5f3; border-radius: 18px; padding: 5px 11px; font-size: 10px; color: #bbb; display: flex; align-items: center; gap: 6px; }
.mock-tabs { display: flex; padding: 0 14px; border-bottom: 0.5px solid #e8e8e8; background: #fff; }
.mock-tab { font-size: 10px; padding: 7px 8px 7px 0; border-bottom: 2px solid transparent; color: #aaa; white-space: nowrap; }
.mock-tab.active { font-weight: 600; border-bottom-width: 2px; border-bottom-style: solid; transition: color 0.2s, border-color 0.2s; }
.mock-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 10px; transition: background 0.2s; }
.mock-card { border-radius: 8px; border: 0.5px solid #e8e8e8; overflow: hidden; transition: background 0.2s; }
.mock-card-img { aspect-ratio: 4/5; display: flex; align-items: center; justify-content: center; font-size: 20px; transition: background 0.2s; }
.mock-card-body { padding: 5px 6px 7px; }
.mock-card-title { font-size: 8px; font-weight: 500; margin-bottom: 5px; line-height: 1.3; transition: color 0.2s; }
.mock-btn { border-radius: 18px; padding: 4px 7px; font-size: 8px; color: #fff !important; border: none; display: flex; align-items: center; justify-content: space-between; width: 100%; cursor: default; transition: background 0.2s; gap: 4px; }
.mock-count { background: rgba(255,255,255,0.25); border-radius: 6px; padding: 1px 4px; flex-shrink: 0; }

@media (max-width: 900px) { .p-config-layout { grid-template-columns: 1fr; } .p-preview-wrap { position: static; margin-top: 8px; } }

.p-pagination { display: flex; gap: 6px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.p-page-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--p-border); background: var(--p-surface); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-family: var(--p-font-body); color: var(--p-text); transition: background 0.15s, border-color 0.15s; text-decoration: none; }
.p-page-btn:hover, .p-page-btn.active { background: var(--p-accent); border-color: var(--p-accent); color: #fff; }

.p-form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.p-login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: var(--p-bg); padding: 24px; }
.p-login-box { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius); padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: var(--p-shadow-lg); }
.p-login-logo { text-align: center; margin-bottom: 28px; }
.p-login-logo h1 { font-family: var(--p-font-display); font-size: 22px; font-weight: 600; color: var(--p-text); letter-spacing: -0.02em; }
.p-login-logo p { font-size: 13px; color: var(--p-muted); margin-top: 4px; }

.p-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--p-muted); cursor: pointer; user-select: none; }
.p-checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--p-accent); cursor: pointer; }

.p-cat-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 16px; }
.p-cat-modal-box { background: var(--p-surface); border-radius: var(--p-radius); padding: 28px 24px 22px; width: 100%; max-width: 360px; box-shadow: var(--p-shadow-lg); }
.p-cat-modal-box h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; font-family: var(--p-font-display); }
.p-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

@media (max-width: 768px) {
    .p-sidebar { transform: translateX(-100%); }
    .p-sidebar.open { transform: translateX(0); box-shadow: var(--p-shadow-lg); }
    .p-sidebar-overlay.open { display: block; }
    .p-main { margin-left: 0; }
    .p-topbar { display: flex; }
    .p-content { padding: 20px 16px 40px; }
    .p-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .p-stat-card { padding: 16px; }
    .p-stat-card .value { font-size: 26px; }
    .p-posts-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .p-login-box { padding: 28px 20px; }
    .p-form-section { padding: 18px 16px; }
    .p-page-title { font-size: 19px; margin-bottom: 18px; }
}

@media (min-width: 769px) and (max-width: 1024px) { .p-posts-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1025px) { .p-posts-grid { grid-template-columns: repeat(4, 1fr); } }