/* ===== Admin Edit Mode — Universal ===== */

/* Bottom toolbar */
.admin-edit-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1e40af, #7c3aed);
    color: white;
    padding: 10px 20px;
    z-index: 2000;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 14px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.admin-edit-bar.show { display: flex; }
.admin-edit-bar .edit-status { display: flex; align-items: center; gap: 8px; }
.admin-edit-bar .edit-status .dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; animation: pulse-dot 1.5s infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.admin-edit-bar .edit-actions { display: flex; gap: 8px; }
.admin-edit-bar .edit-count { background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 12px; font-size: 12px; }

.admin-edit-bar button {
    padding: 6px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Noto Sans KR', sans-serif;
}
.admin-edit-bar .btn-save { background: #22c55e; color: white; }
.admin-edit-bar .btn-save:hover { background: #16a34a; transform: scale(1.05); }
.admin-edit-bar .btn-save:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.admin-edit-bar .btn-publish { background: #f59e0b; color: #1e293b; }
.admin-edit-bar .btn-publish:hover { background: #d97706; transform: scale(1.05); }
.admin-edit-bar .btn-publish:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.admin-edit-bar .btn-undo { background: rgba(255,255,255,0.2); color: white; }
.admin-edit-bar .btn-undo:hover { background: rgba(255,255,255,0.3); }
.admin-edit-bar .btn-close-edit { background: #ef4444; color: white; }
.admin-edit-bar .btn-close-edit:hover { background: #dc2626; }

/* ─── Override content-protection when admin editing ─── */
body.admin-editing,
body.admin-editing * {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}
body.admin-editing [contenteditable="true"] {
    pointer-events: auto !important;
    cursor: text !important;
}

/* ─── Universal editable highlight (targets anything with contenteditable) ─── */
body.admin-editing [contenteditable="true"] {
    outline: 2px dashed transparent;
    outline-offset: 3px;
    transition: outline-color 0.2s, background 0.2s;
    cursor: text;
    border-radius: 4px;
    min-height: 1em;
}
body.admin-editing [contenteditable="true"]:hover {
    outline-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}
body.admin-editing [contenteditable="true"]:focus {
    outline-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

/* Changed indicator */
body.admin-editing .admin-changed {
    outline-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.08) !important;
    position: relative;
}
body.admin-editing .admin-changed::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #f59e0b;
    border-radius: 50%;
    border: 2px solid white;
}

/* ─── Block delete buttons (universal via data-admin-block) ─── */
body.admin-editing [data-admin-block] {
    position: relative;
}

.admin-delete-btn {
    display: none;
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
.admin-delete-btn:hover { transform: scale(1.2); background: #dc2626; }
body.admin-editing [data-admin-block]:hover > .admin-delete-btn {
    display: block;
}

/* Deleted block */
.admin-deleted {
    opacity: 0.3;
    text-decoration: line-through;
    pointer-events: none;
    transition: opacity 0.3s;
}

/* Toast */
.admin-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s;
    font-family: 'Noto Sans KR', sans-serif;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    max-width: 90vw;
    text-align: center;
}
.admin-toast.success { background: #16a34a; }
.admin-toast.error { background: #dc2626; }
.admin-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
    .admin-edit-bar { flex-wrap: wrap; padding: 8px 12px; font-size: 12px; }
    .admin-edit-bar button { padding: 5px 10px; font-size: 11px; }
}
